├── tags └── .keep ├── .gitignore ├── tags_examples ├── 0 - 更多提示词列表.yml ├── 1 - 人物 │ └── 人物 │ │ └── 角色(Characters) │ │ ├── 老人.png │ │ ├── 老太太.png │ │ ├── 1个女孩.png │ │ ├── 1个男孩.png │ │ ├── 2个女性.png │ │ └── 多个女孩.png ├── 0 - 起手提示词.yml ├── 0 - 负面提示词.yml └── 1 - 人物.yml ├── scripts ├── settings.py ├── setup.py └── easy_prompt_selector.py ├── style.css ├── LICENSE ├── README.md └── javascript ├── easy_prompt_selector.js └── js-yaml.min.js /tags/.keep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | 4 | tags/** 5 | -------------------------------------------------------------------------------- /tags_examples/0 - 更多提示词列表.yml: -------------------------------------------------------------------------------- 1 | 更多提示词列表: 2 | - https://github.com/n714/stable-diffusion-webui-easy-prompt-selector-zh_CN -------------------------------------------------------------------------------- /tags_examples/1 - 人物/人物/角色(Characters)/老人.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/n714/sd-webui-easy-prompt-selector-zh_CN/HEAD/tags_examples/1 - 人物/人物/角色(Characters)/老人.png -------------------------------------------------------------------------------- /tags_examples/1 - 人物/人物/角色(Characters)/老太太.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/n714/sd-webui-easy-prompt-selector-zh_CN/HEAD/tags_examples/1 - 人物/人物/角色(Characters)/老太太.png -------------------------------------------------------------------------------- /tags_examples/1 - 人物/人物/角色(Characters)/1个女孩.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/n714/sd-webui-easy-prompt-selector-zh_CN/HEAD/tags_examples/1 - 人物/人物/角色(Characters)/1个女孩.png -------------------------------------------------------------------------------- /tags_examples/1 - 人物/人物/角色(Characters)/1个男孩.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/n714/sd-webui-easy-prompt-selector-zh_CN/HEAD/tags_examples/1 - 人物/人物/角色(Characters)/1个男孩.png -------------------------------------------------------------------------------- /tags_examples/1 - 人物/人物/角色(Characters)/2个女性.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/n714/sd-webui-easy-prompt-selector-zh_CN/HEAD/tags_examples/1 - 人物/人物/角色(Characters)/2个女性.png -------------------------------------------------------------------------------- /tags_examples/1 - 人物/人物/角色(Characters)/多个女孩.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/n714/sd-webui-easy-prompt-selector-zh_CN/HEAD/tags_examples/1 - 人物/人物/角色(Characters)/多个女孩.png -------------------------------------------------------------------------------- /scripts/settings.py: -------------------------------------------------------------------------------- 1 | from modules import script_callbacks, shared 2 | 3 | def on_ui_settings(): 4 | shared.opts.add_option("eps_enable_save_raw_prompt_to_pnginfo", shared.OptionInfo(False, "Save original prompt to pngninfo", section=("easy_prompt_selector", "EasyPromptSelector"))) 5 | 6 | script_callbacks.on_ui_settings(on_ui_settings) 7 | -------------------------------------------------------------------------------- /style.css: -------------------------------------------------------------------------------- 1 | .easy_prompt_selector_container { 2 | display: flex; 3 | flex-direction: row; 4 | gap: 0.5em; 5 | margin-top: 0.5em; 6 | } 7 | 8 | .easy_prompt_selector_button { 9 | flex: 1; 10 | } 11 | 12 | div.easy_prompt_selector_tag img { 13 | display: none; 14 | } 15 | 16 | div.easy_prompt_selector_tag:hover img { 17 | display: block; 18 | position: absolute; 19 | margin-top: 1rem; 20 | z-index: 100; 21 | max-width: 300px; 22 | } 23 | -------------------------------------------------------------------------------- /tags_examples/0 - 起手提示词.yml: -------------------------------------------------------------------------------- 1 | 启动提示: 2 | Photo 正面提示: (masterpiece, best quality:1.2), highres, (photorealistic:1.4), (depth of field:1.1) 3 | Lineart 正面提示: a line drawing, line art, line work 4 | CG 正面提示1: ((white background)) (8k,raw photo, masterpiece, best quality),(photon mapping, radiosity, physically-base rendering, automatic white balance),CG unity, Official art, amazing, finely detail, an extremely delicate and beautiful, extremally detailed,3d rendering, c4d, blender, octanerender, 5 | CG 正面提示2: masterpiece, best quality, highres, drawing , selfiemirror 6 | Toys 正面提示: popular toys, blind box toys, disney style 7 | 8 | 画质: 9 | 提高质量: HDR,UHD,8K 10 | 最佳质量: best quality 11 | 杰作: masterpiece 12 | 更多细节: Highly detailed 13 | 演播室灯光: Studio lighting 14 | 超精细绘画: ultra-fine painting 15 | 聚焦清晰: sharp focus 16 | 物理渲染: physically-based rendering 17 | 极详细刻画: extreme detail description 18 | 改善细节: Professional 19 | 添加鲜艳色彩: Vivid Colors 20 | 虚化模糊景: Bokeh 21 | 相机设置: (EOS R8,50mm,F1.2,8K,RAW photo:1.2) 22 | 老照片: High resolution scan 23 | 素描: Sketch 24 | 绘画: Painting -------------------------------------------------------------------------------- /scripts/setup.py: -------------------------------------------------------------------------------- 1 | from pathlib import Path 2 | import shutil 3 | import os 4 | 5 | from modules import scripts 6 | 7 | FILE_DIR = Path().absolute() 8 | BASE_DIR = Path(scripts.basedir()) 9 | TEMP_DIR = FILE_DIR.joinpath('tmp') 10 | 11 | TAGS_DIR = BASE_DIR.joinpath('tags') 12 | EXAMPLES_DIR = BASE_DIR.joinpath('tags_examples') 13 | 14 | FILENAME_LIST = 'easyPromptSelector.txt' 15 | 16 | os.makedirs(TEMP_DIR, exist_ok=True) 17 | 18 | def examples(): 19 | return EXAMPLES_DIR.rglob("*.yml") 20 | 21 | def copy_examples(): 22 | for file in examples(): 23 | file_path = str(file).replace('tags_examples', 'tags') 24 | shutil.copy2(file, file_path) 25 | 26 | def tags(): 27 | return TAGS_DIR.rglob("*.yml") 28 | 29 | def write_filename_list(): 30 | filepaths = map(lambda path: path.relative_to(FILE_DIR).as_posix(), list(tags())) 31 | 32 | with open(TEMP_DIR.joinpath(FILENAME_LIST), 'w', encoding="utf-8") as f: 33 | f.write('\n'.join(sorted(filepaths))) 34 | 35 | if len(list(TAGS_DIR.rglob("*.yml"))) == 0: 36 | copy_examples() 37 | 38 | write_filename_list() 39 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 n714 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /tags_examples/0 - 负面提示词.yml: -------------------------------------------------------------------------------- 1 | 负面提示: 2 | NSFW: nsfw,logo,text 3 | embeddings: badhandv4,EasyNegative,ng_deepnegative_v1_75t,rev2-badprompt,verybadimagenegative_v1.3,negative_hand-neg,bad-picture-chill-75v 4 | 变异手指: mutated hands and fingers 5 | 畸形的: deformed 6 | 解剖不良: bad anatomy 7 | 毁容: disfigured 8 | 脸不好: poorly drawn face 9 | 变异的: mutated 10 | 多余肢体: extra limb 11 | 丑陋: ugly 12 | 手画得差: poorly drawn hands 13 | 缺少的肢体: missing limb 14 | 漂浮的四肢: floating limbs 15 | 肢体不连贯: disconnected limbs 16 | 畸形的手: malformed hands 17 | 脱离焦点: out of focus 18 | 长颈: long neck 19 | 身体长: long body 20 | 全选: nsfw,logo,text,badhandv4,EasyNegative,ng_deepnegative_v1_75t,rev2-badprompt,verybadimagenegative_v1.3,negative_hand-neg,mutated hands and fingers,poorly drawn face,extra limb,missing limb,disconnected limbs,malformed hands,ugly 21 | 负面提示1: easynegative, paintings, sketches, (worst quality:2), (low quality:2), (normal quality:2), lowres, normal quality, ((monochrome)), ((grayscale)), extra fingers, fewer fingers, strange fingers, bad hand, bad anatomy, fused fingers, missing leg, mutated hand, malformed limbs, missing feet,(Fake eyelashes:1.5),(masculine:1.5), strange lips,strange eyes,(wide mouth:1.5), 22 | 负面提示2: (worst quality:2), (low quality:2), (normal quality:2), ((monochrome)), ((grayscale)),paintings, sketches, skin spots, acnes, skin blemishes, bad anatomy, facing away, looking away, tilted head, multiple girls, lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, blurry, bad feet, cropped, poorly drawn hands, poorly drawn face, mutation, deformed, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, extra fingers, fewer digits, extra limbs, extra arms, extra legs, malformed limbs, fused fingers, too many fingers, long neck, cross-eyed, mutated hands, polar lowres, bad body, bad proportions, gross, extra breasts, ng_deepnegative_v1_75t, bad-hands-5 -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # sd-webui-easy-prompt-selector-zh_CN 2 | 3 | [!["Buy Me A Coffee"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/n714mc) 4 | 5 | # 增加新功能提示图 6 | ![tagImg](https://github.com/n714/sd-webui-easy-prompt-selector-zh_CN/assets/45053630/490b6f3e-c940-4254-b8b4-214fb0ef52ea) 7 | - 当鼠标悬停于提示词上,下方将会显示显示有关图像。 8 | 9 | [Video](https://github.com/n714/sd-webui-easy-prompt-selector-zh_CN/assets/45053630/67102b31-84b2-49fa-8dc7-e3cb0d86b552) 10 | 11 | - 新增提示词库和新疆图像安装如下: 12 | - 举例说明: 13 | - 人物提示词加上图表示, 14 | - 在`tags`档案夹内新增档案夹新建 `人物`/ `角色(Characters)`,把图片放进档案夹里,图片名称须根描述词一致. 15 | - 如果图像党不是JPG格式,需要加上下面两句,如果是JPG格式的话不需要加。 16 | - 以这个例子为例,我上传了六个图片,档案夹和档案的分分布如下: 17 | 18 | ``` 19 | ├── 人物 20 | │ └── 角色(Characters) 21 | │ ├── 1个女孩.png 22 | │ ├── 1个男孩.png 23 | │ ├── 2个女性.png 24 | │ ├── 多个女孩.png 25 | │ ├── 老太太.png 26 | │ └── 老人.png 27 | └── 1 - 人物.yml 28 | ``` 29 | 30 | = 如果图像党不是JPG格式,需要在yml档案内加上下面两句, 切记每一行前面需要留有适当的空间。 31 | ``` 32 | .settings: 33 | fileFormatForImages: png 34 | 35 | 人物: 36 | 角色(Characters): 37 | 1个女孩: 1girl 38 | 1个男孩: 1boy 39 | 2个女性: 2girls 40 | 多个女孩: multiple girls 41 | 老太太: Old lady 42 | 老人: Old man 43 | ``` 44 | ## 使用方法 45 | - 选中需要的提示词,滑鼠`左键`是加入,`右键`是删除。 46 | 47 | # 如何安装 stable diffusion webui easy prompt selector zh_CN 简体中文 48 | 49 | ## 1.通过网址安装 50 | 51 | - 点击 `Extension` 选项卡,点击 `Install from URL` 子选项卡 52 | - 复制本 git 仓库网址: 53 | 54 | ``` 55 | https://github.com/n714/sd-webui-easy-prompt-selector-zh_CN 56 | ``` 57 | ![2](https://github.com/n714/sd-webui-easy-prompt-selector-zh_CN/assets/45053630/bbd0f896-3d9b-4b93-b76f-6fd1422c758c) 58 | 59 | - 粘贴进 URL 栏,点击 `Install`,如图 60 | - 安装完成, 61 | 62 | ## 2. 又或者,直接下载然后放在对应路径 63 | [下载本 git 仓库](https://github.com/n714/sd-web-easy-prompt-selector-cn/archive/refs/heads/main.zip) 为 zip 档案 64 | ``` 65 | git clone https://github.com/n714/sd-webui-easy-prompt-selector-zh_CN 66 | ``` 67 | 68 | - 解压,并把文件夹放置在 webui 根目录下的 `extensions` 文件夹中,放好之后, 重新webui. 69 | - 安装完成. 70 | 71 | # 提示词库内容 72 | - 0 - 起手提示词 73 | - 0 - 负面提示词 74 | - 1 - 人物 75 | 76 | ## 安装附加提示词库 77 | - [简体中文提示词库](https://github.com/n714/stable-diffusion-prompt-library-zh_CN) 78 | - [繁體中文提示詞庫](https://github.com/n714/stable-diffusion-prompt-library-zh_TW) 79 | 80 | 81 | ## 下载然后放在对应路径 82 | - [Prompt libaray ](https://github.com/n714/stable-diffusion-prompt-library-zh_CN) 83 | - 直接下载然后,解压,并把文件夹放置在 webui 根目录下的 `extensions/sd-webui-easy-prompt-selector-zh_CN/tags/` 文件夹中, 84 | - 安装完成. 85 | 86 | ------------------------------------------------------------------------------------------ 87 | ## Original creator 88 | [Original creator instructions](https://blue-pen5805.fanbox.cc/posts/5306601) 89 | -------------------------------------------------------------------------------- /tags_examples/1 - 人物.yml: -------------------------------------------------------------------------------- 1 | .settings: 2 | fileFormatForImages: png 3 | 4 | 人物: 5 | 角色(Characters): 6 | 1个女孩: 1girl 7 | 1个男孩: 1boy 8 | 2个女性: 2girls 9 | 多个女孩: multiple girls 10 | 老太太: Old lady 11 | 老人: Old man 12 | 13 | 年龄(Age): 14 | 十几岁: teen 15 | 少年: early teen 16 | 成年人: adult 17 | 老人: elder 18 | 小儿: child 19 | 幼儿园儿: kindergartener 20 | 幼儿: toddler 21 | 萝莉: loli 22 | 正太: shota 23 | 24 | 体形(Body shape): 25 | 苗条: Slim 26 | 胖: fat 27 | 高: tall 28 | 纤弱: petite 29 | 矮: chibi 30 | 肌肉型: Muscular 31 | 瘦长型: Skinny 32 | 胖乎乎: Chubby 33 | 结实型: Solid 34 | 高大威猛: Tall and sturdy 35 | 曲线优美: Curvy 36 | 英俊威武: Handsome and strong 37 | 细腻型: Delicate 38 | 粗壮型: Strong and sturdy 39 | 清秀型: Graceful 40 | 坚毅型: Firm and resolute 41 | 体态匀称: Well-proportioned 42 | 强健型: Robust 43 | 柔美型: Tender and beautiful 44 | 束腰型: Hourglass 45 | 富态型: Wealthy-looking 46 | 粗犷型: Rough and bold 47 | 丰满型: Plump 48 | 诱惑: glamor 49 | 怀孕: pregnant 50 | 细腰: narrow waist 51 | 大屁股: wide hips 52 | 运动员: athlete 53 | 54 | 身体部位(Body Parts): 55 | 腋: armpits 56 | 锁骨: collarbone 57 | 肚脐: navel 58 | 屁股: ass 59 | 大腿: thighs 60 | 头部: Head 61 | 眼睛: Eyes 62 | 耳朵: Ears 63 | 鼻子: Nose 64 | 嘴巴: Mouth 65 | 颈部: Neck 66 | 肩膀: Shoulders 67 | 脚: Feet 68 | 脚趾: Toes 69 | 关节: Joints 70 | 肌肉: Muscles 71 | 皮肤: Skin 72 | 小腿: Calves 73 | 手臂: Arms 74 | 手指: Fingers 75 | 腹部: Abdomen 76 | 臀部: Hips 77 | 腿部: Legs 78 | 背部: Back 79 | 80 | 女性胸部(Felmale chest): 81 | 平胸: flat chest 82 | 贫乳: small breasts 83 | 普通: medium breasts 84 | 大胸: Large Chest 85 | 巨乳: big boobs 86 | 爆乳: huge breasts 87 | 垂乳: hanging breasts巨乳 88 | 球型: Spherical-shaped Chest 89 | 锥形: Cone-shaped Chest 90 | 半球型: Hemispherical-shaped Chest 91 | 高耸: Perky Chest 92 | 下垂: Saggy Chest 93 | 对称: Symmetrical Chest 94 | 不对称: Asymmetrical Chest 95 | 自然形状: Natural-shaped Chest 96 | 高台: High-profile Chest 97 | 宽杯型: Wide-cup shaped Chest 98 | 窄杯型: Narrow-cup shaped Chest 99 | 上扬: Upward-lifting Chest 100 | 舒展型: Broad-structured Chest 101 | 紧凑型: Compact Chest 102 | 丰满: Full-bodied Chest 103 | 温柔曲线: Gentle Curved Chest 104 | 105 | 男性肌肉(man muscle): 106 | 胸肌: Pectoralis Major 107 | 背阔肌: Latissimus Dorsi 108 | 斜方肌: Trapezius 109 | 三头肌: Triceps 110 | 肱二头肌: Biceps 111 | 腹直肌: Rectus Abdominis 112 | 外斜肌: External Obliques 113 | 内斜肌: Internal Obliques 114 | 臀大肌: Gluteus Maximus 115 | 腿四头肌: Quadriceps 116 | 腓肠肌: Soleus 117 | 桡骨二头肌: Brachioradialis 118 | 肩袖肌群: Rotator Cuff Muscles 119 | 斜方肌后束: Lower Trapezius 120 | 腰方肌: Erector Spinae 121 | 腘绳肌: Hamstrings 122 | 胫骨前肌: Tibialis Anterior (Shins) 123 | 124 | 皮肤(Skin): 125 | 肤色(Skin color): 126 | 白: white skin 127 | 色白: pale skin 128 | 褐色: dark skin 129 | 明亮: shiny skin 130 | 有色: colored skin 131 | 132 | 皮肤性质(skin conditions): 133 | 日晒: tan 134 | 晒痕: tanlines 135 | 纹身: tattoo 136 | 油性: oil -------------------------------------------------------------------------------- /scripts/easy_prompt_selector.py: -------------------------------------------------------------------------------- 1 | from pathlib import Path 2 | import random 3 | import re 4 | import yaml 5 | import gradio as gr 6 | 7 | import modules.scripts as scripts 8 | from modules.scripts import AlwaysVisible, basedir 9 | from modules import shared 10 | from scripts.setup import write_filename_list 11 | 12 | FILE_DIR = Path().absolute() 13 | BASE_DIR = Path(basedir()) 14 | TAGS_DIR = BASE_DIR.joinpath('tags') 15 | 16 | def tag_files(): 17 | return TAGS_DIR.rglob("*.yml") 18 | 19 | def load_tags(): 20 | tags = {} 21 | for filepath in tag_files(): 22 | with open(filepath, "r", encoding="utf-8") as file: 23 | yml = yaml.safe_load(file) 24 | tags[filepath.stem] = yml 25 | 26 | return tags 27 | 28 | def find_tag(tags, location): 29 | if type(location) == str: 30 | return tags[location] 31 | 32 | value = '' 33 | if len(location) > 0: 34 | value = tags 35 | for tag in location: 36 | value = value[tag] 37 | 38 | if type(value) == dict: 39 | key = random.choice(list(value.keys())) 40 | tag = value[key] 41 | if type(tag) == dict: 42 | value = find_tag(tag, [random.choice(list(tag.keys()))]) 43 | else: 44 | value = find_tag(value, key) 45 | 46 | if (type(value) == list): 47 | value = random.choice(value) 48 | 49 | return value 50 | 51 | def replace_template(tags, prompt, seed = None): 52 | random.seed(seed) 53 | 54 | count = 0 55 | while count < 100: 56 | if not '@' in prompt: 57 | break 58 | 59 | for match in re.finditer(r'(@((?P\d+(-\d+)?)\$\$)?(?P[^>]+?)@)', prompt): 60 | template = match.group() 61 | try: 62 | try: 63 | result = list(map(lambda x: int(x), match.group('num').split('-'))) 64 | min_count = min(result) 65 | max_count = max(result) 66 | except Exception as e: 67 | min_count, max_count = 1, 1 68 | count = random.randint(min_count, max_count) 69 | 70 | values = list(map(lambda x: find_tag(tags, match.group('ref').split(':')), list(range(count)))) 71 | prompt = prompt.replace(template, ', '.join(values), 1) 72 | except Exception as e: 73 | prompt = prompt.replace(template, '', 1) 74 | count += 1 75 | 76 | random.seed() 77 | return prompt 78 | 79 | class Script(scripts.Script): 80 | tags = {} 81 | 82 | def __init__(self): 83 | super().__init__() 84 | self.tags = load_tags() 85 | 86 | def title(self): 87 | return "EasyPromptSelector" 88 | 89 | def show(self, is_img2img): 90 | return AlwaysVisible 91 | 92 | def ui(self, is_img2img): 93 | if (is_img2img): 94 | return None 95 | 96 | reload_button = gr.Button('🔄', variant='secondary', elem_id='easy_prompt_selector_reload_button') 97 | # reload_button.style(size='sm') 98 | 99 | def reload(): 100 | self.tags = load_tags() 101 | write_filename_list() 102 | 103 | reload_button.click(fn=reload) 104 | 105 | return [reload_button] 106 | 107 | def replace_template_tags(self, p): 108 | prompts = [ 109 | [p.prompt, p.all_prompts, 'Input Prompt'], 110 | [p.negative_prompt, p.all_negative_prompts, 'Input NegativePrompt'], 111 | ] 112 | if getattr(p, 'hr_prompt', None): prompts.append([p.hr_prompt, p.all_hr_prompts, 'Input Prompt(Hires)']) 113 | if getattr(p, 'hr_negative_prompt', None): prompts.append([p.hr_negative_prompt, p.all_hr_negative_prompts, 'Input NegativePrompt(Hires)']) 114 | 115 | for i in range(len(p.all_prompts)): 116 | seed = random.random() 117 | for [prompt, all_prompts, raw_prompt_param_name] in prompts: 118 | if '@' not in prompt: continue 119 | 120 | self.save_prompt_to_pnginfo(p, prompt, raw_prompt_param_name) 121 | 122 | replaced = "".join(replace_template(self.tags, all_prompts[i], seed)) 123 | all_prompts[i] = replaced 124 | 125 | def save_prompt_to_pnginfo(self, p, prompt, name): 126 | if shared.opts.eps_enable_save_raw_prompt_to_pnginfo == False: 127 | return 128 | 129 | p.extra_generation_params.update({name: prompt.replace('\n', ' ')}) 130 | 131 | def process(self, p, *args): 132 | self.replace_template_tags(p) 133 | -------------------------------------------------------------------------------- /javascript/easy_prompt_selector.js: -------------------------------------------------------------------------------- 1 | class EPSElementBuilder { 2 | // Templates 3 | static baseButton(text, { size = 'sm', color = 'primary', image = null }) { 4 | const button = gradioApp().getElementById('txt2img_generate').cloneNode() 5 | button.id = '' 6 | button.classList.remove('gr-button-lg', 'gr-button-primary', 'lg', 'primary') 7 | button.classList.add( 8 | // gradio 3.16 9 | `gr-button-${size}`, 10 | `gr-button-${color}`, 11 | // gradio 3.22 12 | size, 13 | color 14 | ) 15 | if (image) { 16 | const div = document.createElement('div') 17 | div.classList.add('easy_prompt_selector_tag') 18 | const img = document.createElement('img') 19 | img.src = "/file/extensions/sd-webui-easy-prompt-selector-zh_CN/tags/" + image 20 | img.alt = '' 21 | img.onerror = function () { this.onerror = null; this.src=''; } 22 | button.addEventListener('mouseover', function (e) { 23 | if (e.clientX / window.innerWidth <= 0.5) { 24 | img.classList.remove('right') 25 | img.classList.add('left') 26 | } else { 27 | img.classList.remove('left') 28 | img.classList.add('right') 29 | } 30 | }); 31 | div.appendChild(document.createTextNode(text)) 32 | div.appendChild(img) 33 | button.appendChild(div) 34 | } else { 35 | button.textContent = text 36 | } 37 | 38 | return button 39 | } 40 | 41 | static tagFields() { 42 | const fields = document.createElement('div') 43 | fields.style.display = 'flex' 44 | fields.style.flexDirection = 'row' 45 | fields.style.flexWrap = 'wrap' 46 | fields.style.minWidth = 'min(320px, 100%)' 47 | fields.style.maxWidth = '100%' 48 | fields.style.flex = '1 calc(50% - 20px)' 49 | fields.style.borderWidth = '1px' 50 | fields.style.borderColor = 'var(--block-border-color,#374151)' 51 | fields.style.borderRadius = 'var(--block-radius,8px)' 52 | fields.style.padding = '8px' 53 | fields.style.height = 'fit-content' 54 | 55 | return fields 56 | } 57 | 58 | // Elements 59 | static openButton({ onClick }) { 60 | const button = EPSElementBuilder.baseButton('🔯提示词', { size: 'sm', color: 'secondary' }) 61 | button.classList.add('easy_prompt_selector_button') 62 | button.addEventListener('click', onClick) 63 | 64 | return button 65 | } 66 | 67 | static areaContainer(id = undefined) { 68 | const container = gradioApp().getElementById('txt2img_results').cloneNode() 69 | container.id = id 70 | container.style.gap = 0 71 | container.style.display = 'none' 72 | 73 | return container 74 | } 75 | 76 | static tagButton({ imagePath, imageFormat, title, onClick, onRightClick, color = 'primary' }) { 77 | const image = imagePath ? imagePath + '/' + title + '.' + imageFormat : null 78 | const button = EPSElementBuilder.baseButton(title, { color, image }) 79 | button.style.height = '2rem' 80 | button.style.flexGrow = '0' 81 | button.style.margin = '2px' 82 | 83 | button.addEventListener('click', onClick) 84 | button.addEventListener('contextmenu', onRightClick) 85 | 86 | return button 87 | } 88 | 89 | static dropDown(id, options, { onChange }) { 90 | const select = document.createElement('select') 91 | select.id = id 92 | 93 | // gradio 3.16 94 | select.classList.add('gr-box', 'gr-input') 95 | 96 | // gradio 3.22 97 | select.style.color = 'var(--body-text-color)' 98 | select.style.backgroundColor = 'var(--input-background-fill)' 99 | select.style.borderColor = 'var(--block-border-color)' 100 | select.style.borderRadius = 'var(--block-radius)' 101 | select.style.margin = '2px' 102 | select.addEventListener('change', (event) => { onChange(event.target.value) }) 103 | 104 | const none = ['空'] 105 | none.concat(options).forEach((key) => { 106 | const option = document.createElement('option') 107 | option.value = key 108 | option.textContent = key 109 | select.appendChild(option) 110 | }) 111 | 112 | return select 113 | } 114 | 115 | static checkbox(text, { onChange }) { 116 | const label = document.createElement('label') 117 | label.style.display = 'flex' 118 | label.style.alignItems = 'center' 119 | 120 | const checkbox = gradioApp().querySelector('input[type=checkbox]').cloneNode() 121 | checkbox.checked = false 122 | checkbox.addEventListener('change', (event) => { 123 | onChange(event.target.checked) 124 | }) 125 | 126 | const span = document.createElement('span') 127 | span.style.marginLeft = 'var(--size-2, 8px)' 128 | span.textContent = text 129 | 130 | label.appendChild(checkbox) 131 | label.appendChild(span) 132 | 133 | return label 134 | } 135 | } 136 | 137 | class EasyPromptSelector { 138 | PATH_FILE = 'tmp/easyPromptSelector.txt' 139 | AREA_ID = 'easy-prompt-selector' 140 | SELECT_ID = 'easy-prompt-selector-select' 141 | CONTENT_ID = 'easy-prompt-selector-content' 142 | TO_NEGATIVE_PROMPT_ID = 'easy-prompt-selector-to-negative-prompt' 143 | 144 | constructor(yaml, gradioApp) { 145 | this.yaml = yaml 146 | this.gradioApp = gradioApp 147 | this.visible = false 148 | this.toNegative = false 149 | this.tags = undefined 150 | this.settings = undefined 151 | } 152 | 153 | async init() { 154 | [this.tags, this.settings] = await this.parseFiles() 155 | 156 | const tagArea = gradioApp().querySelector(`#${this.AREA_ID}`) 157 | if (tagArea != null) { 158 | this.visible = false 159 | this.changeVisibility(tagArea, this.visible) 160 | tagArea.remove() 161 | } 162 | 163 | gradioApp() 164 | .getElementById('txt2img_toprow') 165 | .after(this.render()) 166 | } 167 | 168 | async readFile(filepath) { 169 | const response = await fetch(`file=${filepath}?${new Date().getTime()}`); 170 | 171 | return await response.text(); 172 | } 173 | 174 | async parseFiles() { 175 | const text = await this.readFile(this.PATH_FILE); 176 | if (text === '') { return {} } 177 | 178 | const paths = text.split(/\r\n|\n/) 179 | 180 | const tags = {} 181 | const settings = {} 182 | for (const path of paths) { 183 | const filename = path.split('/').pop().split('.').slice(0, -1).join('.') 184 | const data = await this.readFile(path) 185 | yaml.loadAll(data, function (doc) { 186 | settings[filename] = doc['.settings'] 187 | delete doc['.settings'] 188 | tags[filename] = doc 189 | }) 190 | } 191 | 192 | return [tags, settings] 193 | } 194 | 195 | // Render 196 | render() { 197 | const row = document.createElement('div') 198 | row.style.display = 'flex' 199 | row.style.alignItems = 'center' 200 | row.style.gap = '10px' 201 | 202 | const dropDown = this.renderDropdown() 203 | dropDown.style.flex = '1' 204 | dropDown.style.minWidth = '1' 205 | row.appendChild(dropDown) 206 | 207 | const settings = document.createElement('div') 208 | const checkbox = EPSElementBuilder.checkbox('负面提示词', { 209 | onChange: (checked) => { this.toNegative = checked } 210 | }) 211 | settings.style.flex = '1' 212 | settings.appendChild(checkbox) 213 | 214 | row.appendChild(settings) 215 | 216 | const container = EPSElementBuilder.areaContainer(this.AREA_ID) 217 | 218 | container.appendChild(row) 219 | container.appendChild(this.renderContent()) 220 | 221 | return container 222 | } 223 | 224 | renderDropdown() { 225 | const dropDown = EPSElementBuilder.dropDown( 226 | this.SELECT_ID, 227 | Object.keys(this.tags), { 228 | onChange: (selected) => { 229 | const content = gradioApp().getElementById(this.CONTENT_ID) 230 | Array.from(content.childNodes).forEach((node) => { 231 | const visible = node.id === `easy-prompt-selector-container-${selected}` 232 | this.changeVisibility(node, visible) 233 | }) 234 | } 235 | } 236 | ) 237 | 238 | return dropDown 239 | } 240 | 241 | renderContent() { 242 | const content = document.createElement('div') 243 | content.id = this.CONTENT_ID 244 | 245 | Object.keys(this.tags).forEach((key) => { 246 | const values = this.tags[key] 247 | 248 | const fields = EPSElementBuilder.tagFields() 249 | fields.id = `easy-prompt-selector-container-${key}` 250 | fields.style.display = 'none' 251 | fields.style.flexDirection = 'row' 252 | fields.style.marginTop = '10px' 253 | 254 | const imageFormat = this.settings[key]?.fileFormatForImages || 'jpg' 255 | this.renderTagButtons(key, imageFormat, values, key).forEach((group) => { 256 | fields.appendChild(group) 257 | }) 258 | 259 | content.appendChild(fields) 260 | }) 261 | 262 | return content 263 | } 264 | 265 | renderTagButtons(imagePath, imageFormat, tags, prefix = '') { 266 | if (Array.isArray(tags)) { 267 | return tags.map((tag) => this.renderTagButton(tag, tag, 'secondary')) 268 | } else { 269 | return Object.keys(tags).map((key) => { 270 | const values = tags[key] 271 | const randomKey = `${prefix}:${key}` 272 | 273 | if (typeof values === 'string') { return this.renderTagButton(imagePath, imageFormat, key, values, 'secondary') } 274 | 275 | const fields = EPSElementBuilder.tagFields() 276 | fields.style.flexDirection = 'column' 277 | 278 | fields.append(this.renderTagButton(null, imageFormat, key, `@${randomKey}@`)) 279 | 280 | const buttons = EPSElementBuilder.tagFields() 281 | buttons.id = 'buttons' 282 | fields.append(buttons) 283 | this.renderTagButtons(imagePath + '/' + key, imageFormat, values, randomKey).forEach((button) => { 284 | buttons.appendChild(button) 285 | }) 286 | 287 | return fields 288 | }) 289 | } 290 | } 291 | 292 | renderTagButton(imagePath, imageFormat, title, value, color = 'primary') { 293 | return EPSElementBuilder.tagButton({ 294 | imagePath, imageFormat, title, 295 | onClick: (e) => { 296 | e.preventDefault(); 297 | 298 | this.addTag(value, this.toNegative || e.metaKey || e.ctrlKey) 299 | }, 300 | onRightClick: (e) => { 301 | e.preventDefault(); 302 | 303 | this.removeTag(value, this.toNegative || e.metaKey || e.ctrlKey) 304 | }, 305 | color 306 | }) 307 | } 308 | 309 | // Util 310 | changeVisibility(node, visible) { 311 | node.style.display = visible ? 'flex' : 'none' 312 | } 313 | 314 | addTag(tag, toNegative = false) { 315 | const id = toNegative ? 'txt2img_neg_prompt' : 'txt2img_prompt' 316 | const textarea = gradioApp().getElementById(id).querySelector('textarea') 317 | 318 | if (textarea.value.trim() === '') { 319 | textarea.value = tag 320 | } else if (textarea.value.trim().endsWith(',')) { 321 | textarea.value += ' ' + tag 322 | } else { 323 | textarea.value += ', ' + tag 324 | } 325 | 326 | updateInput(textarea) 327 | } 328 | 329 | removeTag(tag, toNegative = false) { 330 | const id = toNegative ? 'txt2img_neg_prompt' : 'txt2img_prompt' 331 | const textarea = gradioApp().getElementById(id).querySelector('textarea') 332 | 333 | if (textarea.value.trimStart().startsWith(tag)) { 334 | const matched = textarea.value.match(new RegExp(`${tag.replace(/[-\/\\^$*+?.()|\[\]{}]/g, '\\$&') },*`)) 335 | textarea.value = textarea.value.replace(matched[0], '').trimStart() 336 | } else { 337 | textarea.value = textarea.value.replace(`, ${tag}`, '') 338 | } 339 | 340 | updateInput(textarea) 341 | } 342 | } 343 | 344 | onUiLoaded(async () => { 345 | yaml = window.jsyaml 346 | const easyPromptSelector = new EasyPromptSelector(yaml, gradioApp()) 347 | 348 | const button = EPSElementBuilder.openButton({ 349 | onClick: () => { 350 | const tagArea = gradioApp().querySelector(`#${easyPromptSelector.AREA_ID}`) 351 | easyPromptSelector.changeVisibility(tagArea, easyPromptSelector.visible = !easyPromptSelector.visible) 352 | } 353 | }) 354 | 355 | const reloadButton = gradioApp().getElementById('easy_prompt_selector_reload_button') 356 | reloadButton.addEventListener('click', async () => { 357 | await easyPromptSelector.init() 358 | }) 359 | 360 | const txt2imgActionColumn = gradioApp().getElementById('txt2img_actions_column') 361 | const container = document.createElement('div') 362 | container.classList.add('easy_prompt_selector_container') 363 | container.appendChild(button) 364 | container.appendChild(reloadButton) 365 | 366 | txt2imgActionColumn.appendChild(container) 367 | 368 | await easyPromptSelector.init() 369 | }) 370 | -------------------------------------------------------------------------------- /javascript/js-yaml.min.js: -------------------------------------------------------------------------------- 1 | /*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */ 2 | !function (e, t) { "object" == typeof exports && "undefined" != typeof module ? t(exports) : "function" == typeof define && define.amd ? define(["exports"], t) : t((e = "undefined" != typeof globalThis ? globalThis : e || self).jsyaml = {}) }(this, (function (e) { "use strict"; function t(e) { return null == e } var n = { isNothing: t, isObject: function (e) { return "object" == typeof e && null !== e }, toArray: function (e) { return Array.isArray(e) ? e : t(e) ? [] : [e] }, repeat: function (e, t) { var n, i = ""; for (n = 0; n < t; n += 1)i += e; return i }, isNegativeZero: function (e) { return 0 === e && Number.NEGATIVE_INFINITY === 1 / e }, extend: function (e, t) { var n, i, r, o; if (t) for (n = 0, i = (o = Object.keys(t)).length; n < i; n += 1)e[r = o[n]] = t[r]; return e } }; function i(e, t) { var n = "", i = e.reason || "(unknown reason)"; return e.mark ? (e.mark.name && (n += 'in "' + e.mark.name + '" '), n += "(" + (e.mark.line + 1) + ":" + (e.mark.column + 1) + ")", !t && e.mark.snippet && (n += "\n\n" + e.mark.snippet), i + " " + n) : i } function r(e, t) { Error.call(this), this.name = "YAMLException", this.reason = e, this.mark = t, this.message = i(this, !1), Error.captureStackTrace ? Error.captureStackTrace(this, this.constructor) : this.stack = (new Error).stack || "" } r.prototype = Object.create(Error.prototype), r.prototype.constructor = r, r.prototype.toString = function (e) { return this.name + ": " + i(this, e) }; var o = r; function a(e, t, n, i, r) { var o = "", a = "", l = Math.floor(r / 2) - 1; return i - t > l && (t = i - l + (o = " ... ").length), n - i > l && (n = i + l - (a = " ...").length), { str: o + e.slice(t, n).replace(/\t/g, "→") + a, pos: i - t + o.length } } function l(e, t) { return n.repeat(" ", t - e.length) + e } var c = function (e, t) { if (t = Object.create(t || null), !e.buffer) return null; t.maxLength || (t.maxLength = 79), "number" != typeof t.indent && (t.indent = 1), "number" != typeof t.linesBefore && (t.linesBefore = 3), "number" != typeof t.linesAfter && (t.linesAfter = 2); for (var i, r = /\r?\n|\r|\0/g, o = [0], c = [], s = -1; i = r.exec(e.buffer);)c.push(i.index), o.push(i.index + i[0].length), e.position <= i.index && s < 0 && (s = o.length - 2); s < 0 && (s = o.length - 1); var u, p, f = "", d = Math.min(e.line + t.linesAfter, c.length).toString().length, h = t.maxLength - (t.indent + d + 3); for (u = 1; u <= t.linesBefore && !(s - u < 0); u++)p = a(e.buffer, o[s - u], c[s - u], e.position - (o[s] - o[s - u]), h), f = n.repeat(" ", t.indent) + l((e.line - u + 1).toString(), d) + " | " + p.str + "\n" + f; for (p = a(e.buffer, o[s], c[s], e.position, h), f += n.repeat(" ", t.indent) + l((e.line + 1).toString(), d) + " | " + p.str + "\n", f += n.repeat("-", t.indent + d + 3 + p.pos) + "^\n", u = 1; u <= t.linesAfter && !(s + u >= c.length); u++)p = a(e.buffer, o[s + u], c[s + u], e.position - (o[s] - o[s + u]), h), f += n.repeat(" ", t.indent) + l((e.line + u + 1).toString(), d) + " | " + p.str + "\n"; return f.replace(/\n$/, "") }, s = ["kind", "multi", "resolve", "construct", "instanceOf", "predicate", "represent", "representName", "defaultStyle", "styleAliases"], u = ["scalar", "sequence", "mapping"]; var p = function (e, t) { if (t = t || {}, Object.keys(t).forEach((function (t) { if (-1 === s.indexOf(t)) throw new o('Unknown option "' + t + '" is met in definition of "' + e + '" YAML type.') })), this.options = t, this.tag = e, this.kind = t.kind || null, this.resolve = t.resolve || function () { return !0 }, this.construct = t.construct || function (e) { return e }, this.instanceOf = t.instanceOf || null, this.predicate = t.predicate || null, this.represent = t.represent || null, this.representName = t.representName || null, this.defaultStyle = t.defaultStyle || null, this.multi = t.multi || !1, this.styleAliases = function (e) { var t = {}; return null !== e && Object.keys(e).forEach((function (n) { e[n].forEach((function (e) { t[String(e)] = n })) })), t }(t.styleAliases || null), -1 === u.indexOf(this.kind)) throw new o('Unknown kind "' + this.kind + '" is specified for "' + e + '" YAML type.') }; function f(e, t) { var n = []; return e[t].forEach((function (e) { var t = n.length; n.forEach((function (n, i) { n.tag === e.tag && n.kind === e.kind && n.multi === e.multi && (t = i) })), n[t] = e })), n } function d(e) { return this.extend(e) } d.prototype.extend = function (e) { var t = [], n = []; if (e instanceof p) n.push(e); else if (Array.isArray(e)) n = n.concat(e); else { if (!e || !Array.isArray(e.implicit) && !Array.isArray(e.explicit)) throw new o("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })"); e.implicit && (t = t.concat(e.implicit)), e.explicit && (n = n.concat(e.explicit)) } t.forEach((function (e) { if (!(e instanceof p)) throw new o("Specified list of YAML types (or a single Type object) contains a non-Type object."); if (e.loadKind && "scalar" !== e.loadKind) throw new o("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported."); if (e.multi) throw new o("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.") })), n.forEach((function (e) { if (!(e instanceof p)) throw new o("Specified list of YAML types (or a single Type object) contains a non-Type object.") })); var i = Object.create(d.prototype); return i.implicit = (this.implicit || []).concat(t), i.explicit = (this.explicit || []).concat(n), i.compiledImplicit = f(i, "implicit"), i.compiledExplicit = f(i, "explicit"), i.compiledTypeMap = function () { var e, t, n = { scalar: {}, sequence: {}, mapping: {}, fallback: {}, multi: { scalar: [], sequence: [], mapping: [], fallback: [] } }; function i(e) { e.multi ? (n.multi[e.kind].push(e), n.multi.fallback.push(e)) : n[e.kind][e.tag] = n.fallback[e.tag] = e } for (e = 0, t = arguments.length; e < t; e += 1)arguments[e].forEach(i); return n }(i.compiledImplicit, i.compiledExplicit), i }; var h = d, g = new p("tag:yaml.org,2002:str", { kind: "scalar", construct: function (e) { return null !== e ? e : "" } }), m = new p("tag:yaml.org,2002:seq", { kind: "sequence", construct: function (e) { return null !== e ? e : [] } }), y = new p("tag:yaml.org,2002:map", { kind: "mapping", construct: function (e) { return null !== e ? e : {} } }), b = new h({ explicit: [g, m, y] }); var A = new p("tag:yaml.org,2002:null", { kind: "scalar", resolve: function (e) { if (null === e) return !0; var t = e.length; return 1 === t && "~" === e || 4 === t && ("null" === e || "Null" === e || "NULL" === e) }, construct: function () { return null }, predicate: function (e) { return null === e }, represent: { canonical: function () { return "~" }, lowercase: function () { return "null" }, uppercase: function () { return "NULL" }, camelcase: function () { return "Null" }, empty: function () { return "" } }, defaultStyle: "lowercase" }); var v = new p("tag:yaml.org,2002:bool", { kind: "scalar", resolve: function (e) { if (null === e) return !1; var t = e.length; return 4 === t && ("true" === e || "True" === e || "TRUE" === e) || 5 === t && ("false" === e || "False" === e || "FALSE" === e) }, construct: function (e) { return "true" === e || "True" === e || "TRUE" === e }, predicate: function (e) { return "[object Boolean]" === Object.prototype.toString.call(e) }, represent: { lowercase: function (e) { return e ? "true" : "false" }, uppercase: function (e) { return e ? "TRUE" : "FALSE" }, camelcase: function (e) { return e ? "True" : "False" } }, defaultStyle: "lowercase" }); function w(e) { return 48 <= e && e <= 55 } function k(e) { return 48 <= e && e <= 57 } var C = new p("tag:yaml.org,2002:int", { kind: "scalar", resolve: function (e) { if (null === e) return !1; var t, n, i = e.length, r = 0, o = !1; if (!i) return !1; if ("-" !== (t = e[r]) && "+" !== t || (t = e[++r]), "0" === t) { if (r + 1 === i) return !0; if ("b" === (t = e[++r])) { for (r++; r < i; r++)if ("_" !== (t = e[r])) { if ("0" !== t && "1" !== t) return !1; o = !0 } return o && "_" !== t } if ("x" === t) { for (r++; r < i; r++)if ("_" !== (t = e[r])) { if (!(48 <= (n = e.charCodeAt(r)) && n <= 57 || 65 <= n && n <= 70 || 97 <= n && n <= 102)) return !1; o = !0 } return o && "_" !== t } if ("o" === t) { for (r++; r < i; r++)if ("_" !== (t = e[r])) { if (!w(e.charCodeAt(r))) return !1; o = !0 } return o && "_" !== t } } if ("_" === t) return !1; for (; r < i; r++)if ("_" !== (t = e[r])) { if (!k(e.charCodeAt(r))) return !1; o = !0 } return !(!o || "_" === t) }, construct: function (e) { var t, n = e, i = 1; if (-1 !== n.indexOf("_") && (n = n.replace(/_/g, "")), "-" !== (t = n[0]) && "+" !== t || ("-" === t && (i = -1), t = (n = n.slice(1))[0]), "0" === n) return 0; if ("0" === t) { if ("b" === n[1]) return i * parseInt(n.slice(2), 2); if ("x" === n[1]) return i * parseInt(n.slice(2), 16); if ("o" === n[1]) return i * parseInt(n.slice(2), 8) } return i * parseInt(n, 10) }, predicate: function (e) { return "[object Number]" === Object.prototype.toString.call(e) && e % 1 == 0 && !n.isNegativeZero(e) }, represent: { binary: function (e) { return e >= 0 ? "0b" + e.toString(2) : "-0b" + e.toString(2).slice(1) }, octal: function (e) { return e >= 0 ? "0o" + e.toString(8) : "-0o" + e.toString(8).slice(1) }, decimal: function (e) { return e.toString(10) }, hexadecimal: function (e) { return e >= 0 ? "0x" + e.toString(16).toUpperCase() : "-0x" + e.toString(16).toUpperCase().slice(1) } }, defaultStyle: "decimal", styleAliases: { binary: [2, "bin"], octal: [8, "oct"], decimal: [10, "dec"], hexadecimal: [16, "hex"] } }), x = new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"); var I = /^[-+]?[0-9]+e/; var S = new p("tag:yaml.org,2002:float", { kind: "scalar", resolve: function (e) { return null !== e && !(!x.test(e) || "_" === e[e.length - 1]) }, construct: function (e) { var t, n; return n = "-" === (t = e.replace(/_/g, "").toLowerCase())[0] ? -1 : 1, "+-".indexOf(t[0]) >= 0 && (t = t.slice(1)), ".inf" === t ? 1 === n ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY : ".nan" === t ? NaN : n * parseFloat(t, 10) }, predicate: function (e) { return "[object Number]" === Object.prototype.toString.call(e) && (e % 1 != 0 || n.isNegativeZero(e)) }, represent: function (e, t) { var i; if (isNaN(e)) switch (t) { case "lowercase": return ".nan"; case "uppercase": return ".NAN"; case "camelcase": return ".NaN" } else if (Number.POSITIVE_INFINITY === e) switch (t) { case "lowercase": return ".inf"; case "uppercase": return ".INF"; case "camelcase": return ".Inf" } else if (Number.NEGATIVE_INFINITY === e) switch (t) { case "lowercase": return "-.inf"; case "uppercase": return "-.INF"; case "camelcase": return "-.Inf" } else if (n.isNegativeZero(e)) return "-0.0"; return i = e.toString(10), I.test(i) ? i.replace("e", ".e") : i }, defaultStyle: "lowercase" }), O = b.extend({ implicit: [A, v, C, S] }), j = O, T = new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"), N = new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$"); var F = new p("tag:yaml.org,2002:timestamp", { kind: "scalar", resolve: function (e) { return null !== e && (null !== T.exec(e) || null !== N.exec(e)) }, construct: function (e) { var t, n, i, r, o, a, l, c, s = 0, u = null; if (null === (t = T.exec(e)) && (t = N.exec(e)), null === t) throw new Error("Date resolve error"); if (n = +t[1], i = +t[2] - 1, r = +t[3], !t[4]) return new Date(Date.UTC(n, i, r)); if (o = +t[4], a = +t[5], l = +t[6], t[7]) { for (s = t[7].slice(0, 3); s.length < 3;)s += "0"; s = +s } return t[9] && (u = 6e4 * (60 * +t[10] + +(t[11] || 0)), "-" === t[9] && (u = -u)), c = new Date(Date.UTC(n, i, r, o, a, l, s)), u && c.setTime(c.getTime() - u), c }, instanceOf: Date, represent: function (e) { return e.toISOString() } }); var E = new p("tag:yaml.org,2002:merge", { kind: "scalar", resolve: function (e) { return "<<" === e || null === e } }), M = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r"; var L = new p("tag:yaml.org,2002:binary", { kind: "scalar", resolve: function (e) { if (null === e) return !1; var t, n, i = 0, r = e.length, o = M; for (n = 0; n < r; n++)if (!((t = o.indexOf(e.charAt(n))) > 64)) { if (t < 0) return !1; i += 6 } return i % 8 == 0 }, construct: function (e) { var t, n, i = e.replace(/[\r\n=]/g, ""), r = i.length, o = M, a = 0, l = []; for (t = 0; t < r; t++)t % 4 == 0 && t && (l.push(a >> 16 & 255), l.push(a >> 8 & 255), l.push(255 & a)), a = a << 6 | o.indexOf(i.charAt(t)); return 0 === (n = r % 4 * 6) ? (l.push(a >> 16 & 255), l.push(a >> 8 & 255), l.push(255 & a)) : 18 === n ? (l.push(a >> 10 & 255), l.push(a >> 2 & 255)) : 12 === n && l.push(a >> 4 & 255), new Uint8Array(l) }, predicate: function (e) { return "[object Uint8Array]" === Object.prototype.toString.call(e) }, represent: function (e) { var t, n, i = "", r = 0, o = e.length, a = M; for (t = 0; t < o; t++)t % 3 == 0 && t && (i += a[r >> 18 & 63], i += a[r >> 12 & 63], i += a[r >> 6 & 63], i += a[63 & r]), r = (r << 8) + e[t]; return 0 === (n = o % 3) ? (i += a[r >> 18 & 63], i += a[r >> 12 & 63], i += a[r >> 6 & 63], i += a[63 & r]) : 2 === n ? (i += a[r >> 10 & 63], i += a[r >> 4 & 63], i += a[r << 2 & 63], i += a[64]) : 1 === n && (i += a[r >> 2 & 63], i += a[r << 4 & 63], i += a[64], i += a[64]), i } }), _ = Object.prototype.hasOwnProperty, D = Object.prototype.toString; var U = new p("tag:yaml.org,2002:omap", { kind: "sequence", resolve: function (e) { if (null === e) return !0; var t, n, i, r, o, a = [], l = e; for (t = 0, n = l.length; t < n; t += 1) { if (i = l[t], o = !1, "[object Object]" !== D.call(i)) return !1; for (r in i) if (_.call(i, r)) { if (o) return !1; o = !0 } if (!o) return !1; if (-1 !== a.indexOf(r)) return !1; a.push(r) } return !0 }, construct: function (e) { return null !== e ? e : [] } }), q = Object.prototype.toString; var Y = new p("tag:yaml.org,2002:pairs", { kind: "sequence", resolve: function (e) { if (null === e) return !0; var t, n, i, r, o, a = e; for (o = new Array(a.length), t = 0, n = a.length; t < n; t += 1) { if (i = a[t], "[object Object]" !== q.call(i)) return !1; if (1 !== (r = Object.keys(i)).length) return !1; o[t] = [r[0], i[r[0]]] } return !0 }, construct: function (e) { if (null === e) return []; var t, n, i, r, o, a = e; for (o = new Array(a.length), t = 0, n = a.length; t < n; t += 1)i = a[t], r = Object.keys(i), o[t] = [r[0], i[r[0]]]; return o } }), R = Object.prototype.hasOwnProperty; var B = new p("tag:yaml.org,2002:set", { kind: "mapping", resolve: function (e) { if (null === e) return !0; var t, n = e; for (t in n) if (R.call(n, t) && null !== n[t]) return !1; return !0 }, construct: function (e) { return null !== e ? e : {} } }), K = j.extend({ implicit: [F, E], explicit: [L, U, Y, B] }), P = Object.prototype.hasOwnProperty, W = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/, H = /[\x85\u2028\u2029]/, $ = /[,\[\]\{\}]/, G = /^(?:!|!!|![a-z\-]+!)$/i, V = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i; function Z(e) { return Object.prototype.toString.call(e) } function J(e) { return 10 === e || 13 === e } function Q(e) { return 9 === e || 32 === e } function z(e) { return 9 === e || 32 === e || 10 === e || 13 === e } function X(e) { return 44 === e || 91 === e || 93 === e || 123 === e || 125 === e } function ee(e) { var t; return 48 <= e && e <= 57 ? e - 48 : 97 <= (t = 32 | e) && t <= 102 ? t - 97 + 10 : -1 } function te(e) { return 48 === e ? "\0" : 97 === e ? "" : 98 === e ? "\b" : 116 === e || 9 === e ? "\t" : 110 === e ? "\n" : 118 === e ? "\v" : 102 === e ? "\f" : 114 === e ? "\r" : 101 === e ? "" : 32 === e ? " " : 34 === e ? '"' : 47 === e ? "/" : 92 === e ? "\\" : 78 === e ? "Â…" : 95 === e ? " " : 76 === e ? "\u2028" : 80 === e ? "\u2029" : "" } function ne(e) { return e <= 65535 ? String.fromCharCode(e) : String.fromCharCode(55296 + (e - 65536 >> 10), 56320 + (e - 65536 & 1023)) } for (var ie = new Array(256), re = new Array(256), oe = 0; oe < 256; oe++)ie[oe] = te(oe) ? 1 : 0, re[oe] = te(oe); function ae(e, t) { this.input = e, this.filename = t.filename || null, this.schema = t.schema || K, this.onWarning = t.onWarning || null, this.legacy = t.legacy || !1, this.json = t.json || !1, this.listener = t.listener || null, this.implicitTypes = this.schema.compiledImplicit, this.typeMap = this.schema.compiledTypeMap, this.length = e.length, this.position = 0, this.line = 0, this.lineStart = 0, this.lineIndent = 0, this.firstTabInLine = -1, this.documents = [] } function le(e, t) { var n = { name: e.filename, buffer: e.input.slice(0, -1), position: e.position, line: e.line, column: e.position - e.lineStart }; return n.snippet = c(n), new o(t, n) } function ce(e, t) { throw le(e, t) } function se(e, t) { e.onWarning && e.onWarning.call(null, le(e, t)) } var ue = { YAML: function (e, t, n) { var i, r, o; null !== e.version && ce(e, "duplication of %YAML directive"), 1 !== n.length && ce(e, "YAML directive accepts exactly one argument"), null === (i = /^([0-9]+)\.([0-9]+)$/.exec(n[0])) && ce(e, "ill-formed argument of the YAML directive"), r = parseInt(i[1], 10), o = parseInt(i[2], 10), 1 !== r && ce(e, "unacceptable YAML version of the document"), e.version = n[0], e.checkLineBreaks = o < 2, 1 !== o && 2 !== o && se(e, "unsupported YAML version of the document") }, TAG: function (e, t, n) { var i, r; 2 !== n.length && ce(e, "TAG directive accepts exactly two arguments"), i = n[0], r = n[1], G.test(i) || ce(e, "ill-formed tag handle (first argument) of the TAG directive"), P.call(e.tagMap, i) && ce(e, 'there is a previously declared suffix for "' + i + '" tag handle'), V.test(r) || ce(e, "ill-formed tag prefix (second argument) of the TAG directive"); try { r = decodeURIComponent(r) } catch (t) { ce(e, "tag prefix is malformed: " + r) } e.tagMap[i] = r } }; function pe(e, t, n, i) { var r, o, a, l; if (t < n) { if (l = e.input.slice(t, n), i) for (r = 0, o = l.length; r < o; r += 1)9 === (a = l.charCodeAt(r)) || 32 <= a && a <= 1114111 || ce(e, "expected valid JSON character"); else W.test(l) && ce(e, "the stream contains non-printable characters"); e.result += l } } function fe(e, t, i, r) { var o, a, l, c; for (n.isObject(i) || ce(e, "cannot merge mappings; the provided source object is unacceptable"), l = 0, c = (o = Object.keys(i)).length; l < c; l += 1)a = o[l], P.call(t, a) || (t[a] = i[a], r[a] = !0) } function de(e, t, n, i, r, o, a, l, c) { var s, u; if (Array.isArray(r)) for (s = 0, u = (r = Array.prototype.slice.call(r)).length; s < u; s += 1)Array.isArray(r[s]) && ce(e, "nested arrays are not supported inside keys"), "object" == typeof r && "[object Object]" === Z(r[s]) && (r[s] = "[object Object]"); if ("object" == typeof r && "[object Object]" === Z(r) && (r = "[object Object]"), r = String(r), null === t && (t = {}), "tag:yaml.org,2002:merge" === i) if (Array.isArray(o)) for (s = 0, u = o.length; s < u; s += 1)fe(e, t, o[s], n); else fe(e, t, o, n); else e.json || P.call(n, r) || !P.call(t, r) || (e.line = a || e.line, e.lineStart = l || e.lineStart, e.position = c || e.position, ce(e, "duplicated mapping key")), "__proto__" === r ? Object.defineProperty(t, r, { configurable: !0, enumerable: !0, writable: !0, value: o }) : t[r] = o, delete n[r]; return t } function he(e) { var t; 10 === (t = e.input.charCodeAt(e.position)) ? e.position++ : 13 === t ? (e.position++, 10 === e.input.charCodeAt(e.position) && e.position++) : ce(e, "a line break is expected"), e.line += 1, e.lineStart = e.position, e.firstTabInLine = -1 } function ge(e, t, n) { for (var i = 0, r = e.input.charCodeAt(e.position); 0 !== r;) { for (; Q(r);)9 === r && -1 === e.firstTabInLine && (e.firstTabInLine = e.position), r = e.input.charCodeAt(++e.position); if (t && 35 === r) do { r = e.input.charCodeAt(++e.position) } while (10 !== r && 13 !== r && 0 !== r); if (!J(r)) break; for (he(e), r = e.input.charCodeAt(e.position), i++, e.lineIndent = 0; 32 === r;)e.lineIndent++, r = e.input.charCodeAt(++e.position) } return -1 !== n && 0 !== i && e.lineIndent < n && se(e, "deficient indentation"), i } function me(e) { var t, n = e.position; return !(45 !== (t = e.input.charCodeAt(n)) && 46 !== t || t !== e.input.charCodeAt(n + 1) || t !== e.input.charCodeAt(n + 2) || (n += 3, 0 !== (t = e.input.charCodeAt(n)) && !z(t))) } function ye(e, t) { 1 === t ? e.result += " " : t > 1 && (e.result += n.repeat("\n", t - 1)) } function be(e, t) { var n, i, r = e.tag, o = e.anchor, a = [], l = !1; if (-1 !== e.firstTabInLine) return !1; for (null !== e.anchor && (e.anchorMap[e.anchor] = a), i = e.input.charCodeAt(e.position); 0 !== i && (-1 !== e.firstTabInLine && (e.position = e.firstTabInLine, ce(e, "tab characters must not be used in indentation")), 45 === i) && z(e.input.charCodeAt(e.position + 1));)if (l = !0, e.position++, ge(e, !0, -1) && e.lineIndent <= t) a.push(null), i = e.input.charCodeAt(e.position); else if (n = e.line, we(e, t, 3, !1, !0), a.push(e.result), ge(e, !0, -1), i = e.input.charCodeAt(e.position), (e.line === n || e.lineIndent > t) && 0 !== i) ce(e, "bad indentation of a sequence entry"); else if (e.lineIndent < t) break; return !!l && (e.tag = r, e.anchor = o, e.kind = "sequence", e.result = a, !0) } function Ae(e) { var t, n, i, r, o = !1, a = !1; if (33 !== (r = e.input.charCodeAt(e.position))) return !1; if (null !== e.tag && ce(e, "duplication of a tag property"), 60 === (r = e.input.charCodeAt(++e.position)) ? (o = !0, r = e.input.charCodeAt(++e.position)) : 33 === r ? (a = !0, n = "!!", r = e.input.charCodeAt(++e.position)) : n = "!", t = e.position, o) { do { r = e.input.charCodeAt(++e.position) } while (0 !== r && 62 !== r); e.position < e.length ? (i = e.input.slice(t, e.position), r = e.input.charCodeAt(++e.position)) : ce(e, "unexpected end of the stream within a verbatim tag") } else { for (; 0 !== r && !z(r);)33 === r && (a ? ce(e, "tag suffix cannot contain exclamation marks") : (n = e.input.slice(t - 1, e.position + 1), G.test(n) || ce(e, "named tag handle cannot contain such characters"), a = !0, t = e.position + 1)), r = e.input.charCodeAt(++e.position); i = e.input.slice(t, e.position), $.test(i) && ce(e, "tag suffix cannot contain flow indicator characters") } i && !V.test(i) && ce(e, "tag name cannot contain such characters: " + i); try { i = decodeURIComponent(i) } catch (t) { ce(e, "tag name is malformed: " + i) } return o ? e.tag = i : P.call(e.tagMap, n) ? e.tag = e.tagMap[n] + i : "!" === n ? e.tag = "!" + i : "!!" === n ? e.tag = "tag:yaml.org,2002:" + i : ce(e, 'undeclared tag handle "' + n + '"'), !0 } function ve(e) { var t, n; if (38 !== (n = e.input.charCodeAt(e.position))) return !1; for (null !== e.anchor && ce(e, "duplication of an anchor property"), n = e.input.charCodeAt(++e.position), t = e.position; 0 !== n && !z(n) && !X(n);)n = e.input.charCodeAt(++e.position); return e.position === t && ce(e, "name of an anchor node must contain at least one character"), e.anchor = e.input.slice(t, e.position), !0 } function we(e, t, i, r, o) { var a, l, c, s, u, p, f, d, h, g = 1, m = !1, y = !1; if (null !== e.listener && e.listener("open", e), e.tag = null, e.anchor = null, e.kind = null, e.result = null, a = l = c = 4 === i || 3 === i, r && ge(e, !0, -1) && (m = !0, e.lineIndent > t ? g = 1 : e.lineIndent === t ? g = 0 : e.lineIndent < t && (g = -1)), 1 === g) for (; Ae(e) || ve(e);)ge(e, !0, -1) ? (m = !0, c = a, e.lineIndent > t ? g = 1 : e.lineIndent === t ? g = 0 : e.lineIndent < t && (g = -1)) : c = !1; if (c && (c = m || o), 1 !== g && 4 !== i || (d = 1 === i || 2 === i ? t : t + 1, h = e.position - e.lineStart, 1 === g ? c && (be(e, h) || function (e, t, n) { var i, r, o, a, l, c, s, u = e.tag, p = e.anchor, f = {}, d = Object.create(null), h = null, g = null, m = null, y = !1, b = !1; if (-1 !== e.firstTabInLine) return !1; for (null !== e.anchor && (e.anchorMap[e.anchor] = f), s = e.input.charCodeAt(e.position); 0 !== s;) { if (y || -1 === e.firstTabInLine || (e.position = e.firstTabInLine, ce(e, "tab characters must not be used in indentation")), i = e.input.charCodeAt(e.position + 1), o = e.line, 63 !== s && 58 !== s || !z(i)) { if (a = e.line, l = e.lineStart, c = e.position, !we(e, n, 2, !1, !0)) break; if (e.line === o) { for (s = e.input.charCodeAt(e.position); Q(s);)s = e.input.charCodeAt(++e.position); if (58 === s) z(s = e.input.charCodeAt(++e.position)) || ce(e, "a whitespace character is expected after the key-value separator within a block mapping"), y && (de(e, f, d, h, g, null, a, l, c), h = g = m = null), b = !0, y = !1, r = !1, h = e.tag, g = e.result; else { if (!b) return e.tag = u, e.anchor = p, !0; ce(e, "can not read an implicit mapping pair; a colon is missed") } } else { if (!b) return e.tag = u, e.anchor = p, !0; ce(e, "can not read a block mapping entry; a multiline key may not be an implicit key") } } else 63 === s ? (y && (de(e, f, d, h, g, null, a, l, c), h = g = m = null), b = !0, y = !0, r = !0) : y ? (y = !1, r = !0) : ce(e, "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"), e.position += 1, s = i; if ((e.line === o || e.lineIndent > t) && (y && (a = e.line, l = e.lineStart, c = e.position), we(e, t, 4, !0, r) && (y ? g = e.result : m = e.result), y || (de(e, f, d, h, g, m, a, l, c), h = g = m = null), ge(e, !0, -1), s = e.input.charCodeAt(e.position)), (e.line === o || e.lineIndent > t) && 0 !== s) ce(e, "bad indentation of a mapping entry"); else if (e.lineIndent < t) break } return y && de(e, f, d, h, g, null, a, l, c), b && (e.tag = u, e.anchor = p, e.kind = "mapping", e.result = f), b }(e, h, d)) || function (e, t) { var n, i, r, o, a, l, c, s, u, p, f, d, h = !0, g = e.tag, m = e.anchor, y = Object.create(null); if (91 === (d = e.input.charCodeAt(e.position))) a = 93, s = !1, o = []; else { if (123 !== d) return !1; a = 125, s = !0, o = {} } for (null !== e.anchor && (e.anchorMap[e.anchor] = o), d = e.input.charCodeAt(++e.position); 0 !== d;) { if (ge(e, !0, t), (d = e.input.charCodeAt(e.position)) === a) return e.position++, e.tag = g, e.anchor = m, e.kind = s ? "mapping" : "sequence", e.result = o, !0; h ? 44 === d && ce(e, "expected the node content, but found ','") : ce(e, "missed comma between flow collection entries"), f = null, l = c = !1, 63 === d && z(e.input.charCodeAt(e.position + 1)) && (l = c = !0, e.position++, ge(e, !0, t)), n = e.line, i = e.lineStart, r = e.position, we(e, t, 1, !1, !0), p = e.tag, u = e.result, ge(e, !0, t), d = e.input.charCodeAt(e.position), !c && e.line !== n || 58 !== d || (l = !0, d = e.input.charCodeAt(++e.position), ge(e, !0, t), we(e, t, 1, !1, !0), f = e.result), s ? de(e, o, y, p, u, f, n, i, r) : l ? o.push(de(e, null, y, p, u, f, n, i, r)) : o.push(u), ge(e, !0, t), 44 === (d = e.input.charCodeAt(e.position)) ? (h = !0, d = e.input.charCodeAt(++e.position)) : h = !1 } ce(e, "unexpected end of the stream within a flow collection") }(e, d) ? y = !0 : (l && function (e, t) { var i, r, o, a, l, c = 1, s = !1, u = !1, p = t, f = 0, d = !1; if (124 === (a = e.input.charCodeAt(e.position))) r = !1; else { if (62 !== a) return !1; r = !0 } for (e.kind = "scalar", e.result = ""; 0 !== a;)if (43 === (a = e.input.charCodeAt(++e.position)) || 45 === a) 1 === c ? c = 43 === a ? 3 : 2 : ce(e, "repeat of a chomping mode identifier"); else { if (!((o = 48 <= (l = a) && l <= 57 ? l - 48 : -1) >= 0)) break; 0 === o ? ce(e, "bad explicit indentation width of a block scalar; it cannot be less than one") : u ? ce(e, "repeat of an indentation width identifier") : (p = t + o - 1, u = !0) } if (Q(a)) { do { a = e.input.charCodeAt(++e.position) } while (Q(a)); if (35 === a) do { a = e.input.charCodeAt(++e.position) } while (!J(a) && 0 !== a) } for (; 0 !== a;) { for (he(e), e.lineIndent = 0, a = e.input.charCodeAt(e.position); (!u || e.lineIndent < p) && 32 === a;)e.lineIndent++, a = e.input.charCodeAt(++e.position); if (!u && e.lineIndent > p && (p = e.lineIndent), J(a)) f++; else { if (e.lineIndent < p) { 3 === c ? e.result += n.repeat("\n", s ? 1 + f : f) : 1 === c && s && (e.result += "\n"); break } for (r ? Q(a) ? (d = !0, e.result += n.repeat("\n", s ? 1 + f : f)) : d ? (d = !1, e.result += n.repeat("\n", f + 1)) : 0 === f ? s && (e.result += " ") : e.result += n.repeat("\n", f) : e.result += n.repeat("\n", s ? 1 + f : f), s = !0, u = !0, f = 0, i = e.position; !J(a) && 0 !== a;)a = e.input.charCodeAt(++e.position); pe(e, i, e.position, !1) } } return !0 }(e, d) || function (e, t) { var n, i, r; if (39 !== (n = e.input.charCodeAt(e.position))) return !1; for (e.kind = "scalar", e.result = "", e.position++, i = r = e.position; 0 !== (n = e.input.charCodeAt(e.position));)if (39 === n) { if (pe(e, i, e.position, !0), 39 !== (n = e.input.charCodeAt(++e.position))) return !0; i = e.position, e.position++, r = e.position } else J(n) ? (pe(e, i, r, !0), ye(e, ge(e, !1, t)), i = r = e.position) : e.position === e.lineStart && me(e) ? ce(e, "unexpected end of the document within a single quoted scalar") : (e.position++, r = e.position); ce(e, "unexpected end of the stream within a single quoted scalar") }(e, d) || function (e, t) { var n, i, r, o, a, l, c; if (34 !== (l = e.input.charCodeAt(e.position))) return !1; for (e.kind = "scalar", e.result = "", e.position++, n = i = e.position; 0 !== (l = e.input.charCodeAt(e.position));) { if (34 === l) return pe(e, n, e.position, !0), e.position++, !0; if (92 === l) { if (pe(e, n, e.position, !0), J(l = e.input.charCodeAt(++e.position))) ge(e, !1, t); else if (l < 256 && ie[l]) e.result += re[l], e.position++; else if ((a = 120 === (c = l) ? 2 : 117 === c ? 4 : 85 === c ? 8 : 0) > 0) { for (r = a, o = 0; r > 0; r--)(a = ee(l = e.input.charCodeAt(++e.position))) >= 0 ? o = (o << 4) + a : ce(e, "expected hexadecimal character"); e.result += ne(o), e.position++ } else ce(e, "unknown escape sequence"); n = i = e.position } else J(l) ? (pe(e, n, i, !0), ye(e, ge(e, !1, t)), n = i = e.position) : e.position === e.lineStart && me(e) ? ce(e, "unexpected end of the document within a double quoted scalar") : (e.position++, i = e.position) } ce(e, "unexpected end of the stream within a double quoted scalar") }(e, d) ? y = !0 : !function (e) { var t, n, i; if (42 !== (i = e.input.charCodeAt(e.position))) return !1; for (i = e.input.charCodeAt(++e.position), t = e.position; 0 !== i && !z(i) && !X(i);)i = e.input.charCodeAt(++e.position); return e.position === t && ce(e, "name of an alias node must contain at least one character"), n = e.input.slice(t, e.position), P.call(e.anchorMap, n) || ce(e, 'unidentified alias "' + n + '"'), e.result = e.anchorMap[n], ge(e, !0, -1), !0 }(e) ? function (e, t, n) { var i, r, o, a, l, c, s, u, p = e.kind, f = e.result; if (z(u = e.input.charCodeAt(e.position)) || X(u) || 35 === u || 38 === u || 42 === u || 33 === u || 124 === u || 62 === u || 39 === u || 34 === u || 37 === u || 64 === u || 96 === u) return !1; if ((63 === u || 45 === u) && (z(i = e.input.charCodeAt(e.position + 1)) || n && X(i))) return !1; for (e.kind = "scalar", e.result = "", r = o = e.position, a = !1; 0 !== u;) { if (58 === u) { if (z(i = e.input.charCodeAt(e.position + 1)) || n && X(i)) break } else if (35 === u) { if (z(e.input.charCodeAt(e.position - 1))) break } else { if (e.position === e.lineStart && me(e) || n && X(u)) break; if (J(u)) { if (l = e.line, c = e.lineStart, s = e.lineIndent, ge(e, !1, -1), e.lineIndent >= t) { a = !0, u = e.input.charCodeAt(e.position); continue } e.position = o, e.line = l, e.lineStart = c, e.lineIndent = s; break } } a && (pe(e, r, o, !1), ye(e, e.line - l), r = o = e.position, a = !1), Q(u) || (o = e.position + 1), u = e.input.charCodeAt(++e.position) } return pe(e, r, o, !1), !!e.result || (e.kind = p, e.result = f, !1) }(e, d, 1 === i) && (y = !0, null === e.tag && (e.tag = "?")) : (y = !0, null === e.tag && null === e.anchor || ce(e, "alias node should not have any properties")), null !== e.anchor && (e.anchorMap[e.anchor] = e.result)) : 0 === g && (y = c && be(e, h))), null === e.tag) null !== e.anchor && (e.anchorMap[e.anchor] = e.result); else if ("?" === e.tag) { for (null !== e.result && "scalar" !== e.kind && ce(e, 'unacceptable node kind for ! tag; it should be "scalar", not "' + e.kind + '"'), s = 0, u = e.implicitTypes.length; s < u; s += 1)if ((f = e.implicitTypes[s]).resolve(e.result)) { e.result = f.construct(e.result), e.tag = f.tag, null !== e.anchor && (e.anchorMap[e.anchor] = e.result); break } } else if ("!" !== e.tag) { if (P.call(e.typeMap[e.kind || "fallback"], e.tag)) f = e.typeMap[e.kind || "fallback"][e.tag]; else for (f = null, s = 0, u = (p = e.typeMap.multi[e.kind || "fallback"]).length; s < u; s += 1)if (e.tag.slice(0, p[s].tag.length) === p[s].tag) { f = p[s]; break } f || ce(e, "unknown tag !<" + e.tag + ">"), null !== e.result && f.kind !== e.kind && ce(e, "unacceptable node kind for !<" + e.tag + '> tag; it should be "' + f.kind + '", not "' + e.kind + '"'), f.resolve(e.result, e.tag) ? (e.result = f.construct(e.result, e.tag), null !== e.anchor && (e.anchorMap[e.anchor] = e.result)) : ce(e, "cannot resolve a node with !<" + e.tag + "> explicit tag") } return null !== e.listener && e.listener("close", e), null !== e.tag || null !== e.anchor || y } function ke(e) { var t, n, i, r, o = e.position, a = !1; for (e.version = null, e.checkLineBreaks = e.legacy, e.tagMap = Object.create(null), e.anchorMap = Object.create(null); 0 !== (r = e.input.charCodeAt(e.position)) && (ge(e, !0, -1), r = e.input.charCodeAt(e.position), !(e.lineIndent > 0 || 37 !== r));) { for (a = !0, r = e.input.charCodeAt(++e.position), t = e.position; 0 !== r && !z(r);)r = e.input.charCodeAt(++e.position); for (i = [], (n = e.input.slice(t, e.position)).length < 1 && ce(e, "directive name must not be less than one character in length"); 0 !== r;) { for (; Q(r);)r = e.input.charCodeAt(++e.position); if (35 === r) { do { r = e.input.charCodeAt(++e.position) } while (0 !== r && !J(r)); break } if (J(r)) break; for (t = e.position; 0 !== r && !z(r);)r = e.input.charCodeAt(++e.position); i.push(e.input.slice(t, e.position)) } 0 !== r && he(e), P.call(ue, n) ? ue[n](e, n, i) : se(e, 'unknown document directive "' + n + '"') } ge(e, !0, -1), 0 === e.lineIndent && 45 === e.input.charCodeAt(e.position) && 45 === e.input.charCodeAt(e.position + 1) && 45 === e.input.charCodeAt(e.position + 2) ? (e.position += 3, ge(e, !0, -1)) : a && ce(e, "directives end mark is expected"), we(e, e.lineIndent - 1, 4, !1, !0), ge(e, !0, -1), e.checkLineBreaks && H.test(e.input.slice(o, e.position)) && se(e, "non-ASCII line breaks are interpreted as content"), e.documents.push(e.result), e.position === e.lineStart && me(e) ? 46 === e.input.charCodeAt(e.position) && (e.position += 3, ge(e, !0, -1)) : e.position < e.length - 1 && ce(e, "end of the stream or a document separator is expected") } function Ce(e, t) { t = t || {}, 0 !== (e = String(e)).length && (10 !== e.charCodeAt(e.length - 1) && 13 !== e.charCodeAt(e.length - 1) && (e += "\n"), 65279 === e.charCodeAt(0) && (e = e.slice(1))); var n = new ae(e, t), i = e.indexOf("\0"); for (-1 !== i && (n.position = i, ce(n, "null byte is not allowed in input")), n.input += "\0"; 32 === n.input.charCodeAt(n.position);)n.lineIndent += 1, n.position += 1; for (; n.position < n.length - 1;)ke(n); return n.documents } var xe = { loadAll: function (e, t, n) { null !== t && "object" == typeof t && void 0 === n && (n = t, t = null); var i = Ce(e, n); if ("function" != typeof t) return i; for (var r = 0, o = i.length; r < o; r += 1)t(i[r]) }, load: function (e, t) { var n = Ce(e, t); if (0 !== n.length) { if (1 === n.length) return n[0]; throw new o("expected a single document in the stream, but found more") } } }, Ie = Object.prototype.toString, Se = Object.prototype.hasOwnProperty, Oe = 65279, je = { 0: "\\0", 7: "\\a", 8: "\\b", 9: "\\t", 10: "\\n", 11: "\\v", 12: "\\f", 13: "\\r", 27: "\\e", 34: '\\"', 92: "\\\\", 133: "\\N", 160: "\\_", 8232: "\\L", 8233: "\\P" }, Te = ["y", "Y", "yes", "Yes", "YES", "on", "On", "ON", "n", "N", "no", "No", "NO", "off", "Off", "OFF"], Ne = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/; function Fe(e) { var t, i, r; if (t = e.toString(16).toUpperCase(), e <= 255) i = "x", r = 2; else if (e <= 65535) i = "u", r = 4; else { if (!(e <= 4294967295)) throw new o("code point within a string may not be greater than 0xFFFFFFFF"); i = "U", r = 8 } return "\\" + i + n.repeat("0", r - t.length) + t } function Ee(e) { this.schema = e.schema || K, this.indent = Math.max(1, e.indent || 2), this.noArrayIndent = e.noArrayIndent || !1, this.skipInvalid = e.skipInvalid || !1, this.flowLevel = n.isNothing(e.flowLevel) ? -1 : e.flowLevel, this.styleMap = function (e, t) { var n, i, r, o, a, l, c; if (null === t) return {}; for (n = {}, r = 0, o = (i = Object.keys(t)).length; r < o; r += 1)a = i[r], l = String(t[a]), "!!" === a.slice(0, 2) && (a = "tag:yaml.org,2002:" + a.slice(2)), (c = e.compiledTypeMap.fallback[a]) && Se.call(c.styleAliases, l) && (l = c.styleAliases[l]), n[a] = l; return n }(this.schema, e.styles || null), this.sortKeys = e.sortKeys || !1, this.lineWidth = e.lineWidth || 80, this.noRefs = e.noRefs || !1, this.noCompatMode = e.noCompatMode || !1, this.condenseFlow = e.condenseFlow || !1, this.quotingType = '"' === e.quotingType ? 2 : 1, this.forceQuotes = e.forceQuotes || !1, this.replacer = "function" == typeof e.replacer ? e.replacer : null, this.implicitTypes = this.schema.compiledImplicit, this.explicitTypes = this.schema.compiledExplicit, this.tag = null, this.result = "", this.duplicates = [], this.usedDuplicates = null } function Me(e, t) { for (var i, r = n.repeat(" ", t), o = 0, a = -1, l = "", c = e.length; o < c;)-1 === (a = e.indexOf("\n", o)) ? (i = e.slice(o), o = c) : (i = e.slice(o, a + 1), o = a + 1), i.length && "\n" !== i && (l += r), l += i; return l } function Le(e, t) { return "\n" + n.repeat(" ", e.indent * t) } function _e(e) { return 32 === e || 9 === e } function De(e) { return 32 <= e && e <= 126 || 161 <= e && e <= 55295 && 8232 !== e && 8233 !== e || 57344 <= e && e <= 65533 && e !== Oe || 65536 <= e && e <= 1114111 } function Ue(e) { return De(e) && e !== Oe && 13 !== e && 10 !== e } function qe(e, t, n) { var i = Ue(e), r = i && !_e(e); return (n ? i : i && 44 !== e && 91 !== e && 93 !== e && 123 !== e && 125 !== e) && 35 !== e && !(58 === t && !r) || Ue(t) && !_e(t) && 35 === e || 58 === t && r } function Ye(e, t) { var n, i = e.charCodeAt(t); return i >= 55296 && i <= 56319 && t + 1 < e.length && (n = e.charCodeAt(t + 1)) >= 56320 && n <= 57343 ? 1024 * (i - 55296) + n - 56320 + 65536 : i } function Re(e) { return /^\n* /.test(e) } function Be(e, t, n, i, r, o, a, l) { var c, s, u = 0, p = null, f = !1, d = !1, h = -1 !== i, g = -1, m = De(s = Ye(e, 0)) && s !== Oe && !_e(s) && 45 !== s && 63 !== s && 58 !== s && 44 !== s && 91 !== s && 93 !== s && 123 !== s && 125 !== s && 35 !== s && 38 !== s && 42 !== s && 33 !== s && 124 !== s && 61 !== s && 62 !== s && 39 !== s && 34 !== s && 37 !== s && 64 !== s && 96 !== s && function (e) { return !_e(e) && 58 !== e }(Ye(e, e.length - 1)); if (t || a) for (c = 0; c < e.length; u >= 65536 ? c += 2 : c++) { if (!De(u = Ye(e, c))) return 5; m = m && qe(u, p, l), p = u } else { for (c = 0; c < e.length; u >= 65536 ? c += 2 : c++) { if (10 === (u = Ye(e, c))) f = !0, h && (d = d || c - g - 1 > i && " " !== e[g + 1], g = c); else if (!De(u)) return 5; m = m && qe(u, p, l), p = u } d = d || h && c - g - 1 > i && " " !== e[g + 1] } return f || d ? n > 9 && Re(e) ? 5 : a ? 2 === o ? 5 : 2 : d ? 4 : 3 : !m || a || r(e) ? 2 === o ? 5 : 2 : 1 } function Ke(e, t, n, i, r) { e.dump = function () { if (0 === t.length) return 2 === e.quotingType ? '""' : "''"; if (!e.noCompatMode && (-1 !== Te.indexOf(t) || Ne.test(t))) return 2 === e.quotingType ? '"' + t + '"' : "'" + t + "'"; var a = e.indent * Math.max(1, n), l = -1 === e.lineWidth ? -1 : Math.max(Math.min(e.lineWidth, 40), e.lineWidth - a), c = i || e.flowLevel > -1 && n >= e.flowLevel; switch (Be(t, c, e.indent, l, (function (t) { return function (e, t) { var n, i; for (n = 0, i = e.implicitTypes.length; n < i; n += 1)if (e.implicitTypes[n].resolve(t)) return !0; return !1 }(e, t) }), e.quotingType, e.forceQuotes && !i, r)) { case 1: return t; case 2: return "'" + t.replace(/'/g, "''") + "'"; case 3: return "|" + Pe(t, e.indent) + We(Me(t, a)); case 4: return ">" + Pe(t, e.indent) + We(Me(function (e, t) { var n, i, r = /(\n+)([^\n]*)/g, o = (l = e.indexOf("\n"), l = -1 !== l ? l : e.length, r.lastIndex = l, He(e.slice(0, l), t)), a = "\n" === e[0] || " " === e[0]; var l; for (; i = r.exec(e);) { var c = i[1], s = i[2]; n = " " === s[0], o += c + (a || n || "" === s ? "" : "\n") + He(s, t), a = n } return o }(t, l), a)); case 5: return '"' + function (e) { for (var t, n = "", i = 0, r = 0; r < e.length; i >= 65536 ? r += 2 : r++)i = Ye(e, r), !(t = je[i]) && De(i) ? (n += e[r], i >= 65536 && (n += e[r + 1])) : n += t || Fe(i); return n }(t) + '"'; default: throw new o("impossible error: invalid scalar style") } }() } function Pe(e, t) { var n = Re(e) ? String(t) : "", i = "\n" === e[e.length - 1]; return n + (i && ("\n" === e[e.length - 2] || "\n" === e) ? "+" : i ? "" : "-") + "\n" } function We(e) { return "\n" === e[e.length - 1] ? e.slice(0, -1) : e } function He(e, t) { if ("" === e || " " === e[0]) return e; for (var n, i, r = / [^ ]/g, o = 0, a = 0, l = 0, c = ""; n = r.exec(e);)(l = n.index) - o > t && (i = a > o ? a : l, c += "\n" + e.slice(o, i), o = i + 1), a = l; return c += "\n", e.length - o > t && a > o ? c += e.slice(o, a) + "\n" + e.slice(a + 1) : c += e.slice(o), c.slice(1) } function $e(e, t, n, i) { var r, o, a, l = "", c = e.tag; for (r = 0, o = n.length; r < o; r += 1)a = n[r], e.replacer && (a = e.replacer.call(n, String(r), a)), (Ve(e, t + 1, a, !0, !0, !1, !0) || void 0 === a && Ve(e, t + 1, null, !0, !0, !1, !0)) && (i && "" === l || (l += Le(e, t)), e.dump && 10 === e.dump.charCodeAt(0) ? l += "-" : l += "- ", l += e.dump); e.tag = c, e.dump = l || "[]" } function Ge(e, t, n) { var i, r, a, l, c, s; for (a = 0, l = (r = n ? e.explicitTypes : e.implicitTypes).length; a < l; a += 1)if (((c = r[a]).instanceOf || c.predicate) && (!c.instanceOf || "object" == typeof t && t instanceof c.instanceOf) && (!c.predicate || c.predicate(t))) { if (n ? c.multi && c.representName ? e.tag = c.representName(t) : e.tag = c.tag : e.tag = "?", c.represent) { if (s = e.styleMap[c.tag] || c.defaultStyle, "[object Function]" === Ie.call(c.represent)) i = c.represent(t, s); else { if (!Se.call(c.represent, s)) throw new o("!<" + c.tag + '> tag resolver accepts not "' + s + '" style'); i = c.represent[s](t, s) } e.dump = i } return !0 } return !1 } function Ve(e, t, n, i, r, a, l) { e.tag = null, e.dump = n, Ge(e, n, !1) || Ge(e, n, !0); var c, s = Ie.call(e.dump), u = i; i && (i = e.flowLevel < 0 || e.flowLevel > t); var p, f, d = "[object Object]" === s || "[object Array]" === s; if (d && (f = -1 !== (p = e.duplicates.indexOf(n))), (null !== e.tag && "?" !== e.tag || f || 2 !== e.indent && t > 0) && (r = !1), f && e.usedDuplicates[p]) e.dump = "*ref_" + p; else { if (d && f && !e.usedDuplicates[p] && (e.usedDuplicates[p] = !0), "[object Object]" === s) i && 0 !== Object.keys(e.dump).length ? (!function (e, t, n, i) { var r, a, l, c, s, u, p = "", f = e.tag, d = Object.keys(n); if (!0 === e.sortKeys) d.sort(); else if ("function" == typeof e.sortKeys) d.sort(e.sortKeys); else if (e.sortKeys) throw new o("sortKeys must be a boolean or a function"); for (r = 0, a = d.length; r < a; r += 1)u = "", i && "" === p || (u += Le(e, t)), c = n[l = d[r]], e.replacer && (c = e.replacer.call(n, l, c)), Ve(e, t + 1, l, !0, !0, !0) && ((s = null !== e.tag && "?" !== e.tag || e.dump && e.dump.length > 1024) && (e.dump && 10 === e.dump.charCodeAt(0) ? u += "?" : u += "? "), u += e.dump, s && (u += Le(e, t)), Ve(e, t + 1, c, !0, s) && (e.dump && 10 === e.dump.charCodeAt(0) ? u += ":" : u += ": ", p += u += e.dump)); e.tag = f, e.dump = p || "{}" }(e, t, e.dump, r), f && (e.dump = "&ref_" + p + e.dump)) : (!function (e, t, n) { var i, r, o, a, l, c = "", s = e.tag, u = Object.keys(n); for (i = 0, r = u.length; i < r; i += 1)l = "", "" !== c && (l += ", "), e.condenseFlow && (l += '"'), a = n[o = u[i]], e.replacer && (a = e.replacer.call(n, o, a)), Ve(e, t, o, !1, !1) && (e.dump.length > 1024 && (l += "? "), l += e.dump + (e.condenseFlow ? '"' : "") + ":" + (e.condenseFlow ? "" : " "), Ve(e, t, a, !1, !1) && (c += l += e.dump)); e.tag = s, e.dump = "{" + c + "}" }(e, t, e.dump), f && (e.dump = "&ref_" + p + " " + e.dump)); else if ("[object Array]" === s) i && 0 !== e.dump.length ? (e.noArrayIndent && !l && t > 0 ? $e(e, t - 1, e.dump, r) : $e(e, t, e.dump, r), f && (e.dump = "&ref_" + p + e.dump)) : (!function (e, t, n) { var i, r, o, a = "", l = e.tag; for (i = 0, r = n.length; i < r; i += 1)o = n[i], e.replacer && (o = e.replacer.call(n, String(i), o)), (Ve(e, t, o, !1, !1) || void 0 === o && Ve(e, t, null, !1, !1)) && ("" !== a && (a += "," + (e.condenseFlow ? "" : " ")), a += e.dump); e.tag = l, e.dump = "[" + a + "]" }(e, t, e.dump), f && (e.dump = "&ref_" + p + " " + e.dump)); else { if ("[object String]" !== s) { if ("[object Undefined]" === s) return !1; if (e.skipInvalid) return !1; throw new o("unacceptable kind of an object to dump " + s) } "?" !== e.tag && Ke(e, e.dump, t, a, u) } null !== e.tag && "?" !== e.tag && (c = encodeURI("!" === e.tag[0] ? e.tag.slice(1) : e.tag).replace(/!/g, "%21"), c = "!" === e.tag[0] ? "!" + c : "tag:yaml.org,2002:" === c.slice(0, 18) ? "!!" + c.slice(18) : "!<" + c + ">", e.dump = c + " " + e.dump) } return !0 } function Ze(e, t) { var n, i, r = [], o = []; for (Je(e, r, o), n = 0, i = o.length; n < i; n += 1)t.duplicates.push(r[o[n]]); t.usedDuplicates = new Array(i) } function Je(e, t, n) { var i, r, o; if (null !== e && "object" == typeof e) if (-1 !== (r = t.indexOf(e))) -1 === n.indexOf(r) && n.push(r); else if (t.push(e), Array.isArray(e)) for (r = 0, o = e.length; r < o; r += 1)Je(e[r], t, n); else for (r = 0, o = (i = Object.keys(e)).length; r < o; r += 1)Je(e[i[r]], t, n) } function Qe(e, t) { return function () { throw new Error("Function yaml." + e + " is removed in js-yaml 4. Use yaml." + t + " instead, which is now safe by default.") } } var ze = p, Xe = h, et = b, tt = O, nt = j, it = K, rt = xe.load, ot = xe.loadAll, at = { dump: function (e, t) { var n = new Ee(t = t || {}); n.noRefs || Ze(e, n); var i = e; return n.replacer && (i = n.replacer.call({ "": i }, "", i)), Ve(n, 0, i, !0, !0) ? n.dump + "\n" : "" } }.dump, lt = o, ct = { binary: L, float: S, map: y, null: A, pairs: Y, set: B, timestamp: F, bool: v, int: C, merge: E, omap: U, seq: m, str: g }, st = Qe("safeLoad", "load"), ut = Qe("safeLoadAll", "loadAll"), pt = Qe("safeDump", "dump"), ft = { Type: ze, Schema: Xe, FAILSAFE_SCHEMA: et, JSON_SCHEMA: tt, CORE_SCHEMA: nt, DEFAULT_SCHEMA: it, load: rt, loadAll: ot, dump: at, YAMLException: lt, types: ct, safeLoad: st, safeLoadAll: ut, safeDump: pt }; e.CORE_SCHEMA = nt, e.DEFAULT_SCHEMA = it, e.FAILSAFE_SCHEMA = et, e.JSON_SCHEMA = tt, e.Schema = Xe, e.Type = ze, e.YAMLException = lt, e.default = ft, e.dump = at, e.load = rt, e.loadAll = ot, e.safeDump = pt, e.safeLoad = st, e.safeLoadAll = ut, e.types = ct, Object.defineProperty(e, "__esModule", { value: !0 }) })); 3 | --------------------------------------------------------------------------------