@enslo/sd-metadata-lite 1.6.1 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,27 @@ All notable changes to `@enslo/sd-metadata-lite` will be documented in this file
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/).
7
7
 
8
+ ## [1.7.0] - 2026-11-28
9
+
10
+ A Kilobyte Lighter
11
+
12
+ ### Added
13
+
14
+ - **Tool names for C2PA images** (#354): the name comes from the tool an
15
+ image declares, so Kling AI and Dreamina images are named, and ChatGPT
16
+ images return `ChatGPT` in place of `OpenAI Media Service API`.
17
+ - **Size from any `resolution` text** (#356): `1024x1024` and `(1024, 1024)`
18
+ are read in every JSON format, not only Fooocus and HF Space.
19
+
20
+ ### Fixed
21
+
22
+ - **NovelAI JPEG with a comment segment** (#357): the comment no longer
23
+ replaces the NovelAI metadata.
24
+
25
+ ### Maintenance
26
+
27
+ - IIFE bundle size: 7,257 → 6,177 bytes (#354, #355, #356, #357, #358)
28
+
8
29
  ## [1.6.1] - 2026-11-09
9
30
 
10
31
  Steady on Unexpected Text
package/README.ja.md CHANGED
@@ -10,7 +10,7 @@
10
10
  AI生成画像のメタデータを読み取る軽量パーサーです。
11
11
  バンドルサイズが重要なブックマークレットやユーザースクリプト向けに設計されています。
12
12
 
13
- - **超軽量**: **7,257 bytes** のminified IIFEビルド
13
+ - **超軽量**: **6,177 bytes** のminified IIFEビルド
14
14
  - **読み取り専用**: メタデータを抽出し、A1111形式のテキストで返却
15
15
  - **ゼロ依存**: Node.jsとブラウザの両方で動作
16
16
  - **18以上のツール対応**: 主要なAI画像生成ツールをサポート
@@ -66,7 +66,7 @@ if (text) {
66
66
  // ==UserScript==
67
67
  // @name My Script
68
68
  // @namespace https://example.com
69
- // @require https://cdn.jsdelivr.net/npm/@enslo/sd-metadata-lite@1.6.1/dist/index.global.js
69
+ // @require https://cdn.jsdelivr.net/npm/@enslo/sd-metadata-lite@1.7.0/dist/index.global.js
70
70
  // ==/UserScript==
71
71
 
72
72
  const response = await fetch(imageUrl);
@@ -85,7 +85,7 @@ if (text) {
85
85
 
86
86
  多くのサイトではCSPにより外部スクリプトの読み込みがブロックされます。代わりに、IIFEバンドルをインラインで貼り付けてください:
87
87
 
88
- 1. `dist/index.global.js` の内容をコピー(または[npm](https://cdn.jsdelivr.net/npm/@enslo/sd-metadata-lite@1.6.1/dist/index.global.js)からダウンロード)
88
+ 1. `dist/index.global.js` の内容をコピー(または[npm](https://cdn.jsdelivr.net/npm/@enslo/sd-metadata-lite@1.7.0/dist/index.global.js)からダウンロード)
89
89
  2. コードをインラインでブックマークレットに組み込みます:
90
90
 
91
91
  ```javascript
@@ -107,7 +107,7 @@ IIFEは `var sdml` に代入するため、インラインコードの直後か
107
107
  **戻り値:**
108
108
 
109
109
  - メタデータが見つかった場合はA1111形式のテキスト
110
- - 生成パラメータを持たないPNG・JPEGでは、C2PA Content Credentialsの生成元名(例: `OpenAI Media Service API`、`Google C2PA Core Generator Library`、`Grok Imagine`)があればそれを返却
110
+ - 生成パラメータを持たないPNG・JPEGでは、C2PA Content Credentialsに記された生成ツール名(例: `ChatGPT`、`Kling AI`、`Grok Imagine`)があればそれを返却
111
111
  - メタデータが見つからない、またはフォーマットが認識できない場合は空文字列(`""`)
112
112
 
113
113
  ### 出力フォーマット
@@ -147,13 +147,15 @@ PNG、JPEG、WebPのメタデータを読み取り可能:
147
147
 
148
148
  ### Content Credentials (C2PA)
149
149
 
150
- [C2PA](https://c2pa.org/) Content Credentialsで署名された商用ツールのPNGとJPEGは、生成パラメータの代わりに生成元名で判別します:
150
+ [C2PA](https://c2pa.org/) Content Credentialsで署名された商用ツールのPNGとJPEGは、生成パラメータの代わりに、マニフェストに記されたツール名で判別します:
151
151
 
152
152
  - OpenAI ChatGPT
153
153
  - Google Gemini
154
154
  - xAI Grok Imagine
155
+ - Kuaishou Kling AI
156
+ - ByteDance Dreamina
155
157
 
156
- これらの画像では `parse()` が生成元名(例: `OpenAI Media Service API`)を返します。判別はベストエフォートです。Content Credentialsは再保存や再アップロードで簡単に失われ、また存在する場合も署名検証は行いません。
158
+ これらの画像では `parse()` が画像に記されたツール名(例: `ChatGPT`、`Kling AI`、`Dreamina/7.5.0`)を返します。ツール名が記されていない場合は署名したプログラムの名前(Gemini: `Google C2PA Core Generator Library`)を返します。判別はベストエフォートです。Content Credentialsは再保存や再アップロードで簡単に失われ、また存在する場合も署名検証は行いません。
157
159
 
158
160
  ## グローバル変数
159
161
 
package/README.md CHANGED
@@ -10,7 +10,7 @@
10
10
  A lightweight, read-only metadata parser for AI-generated images.
11
11
  Designed for bookmarklets and userscripts where bundle size matters.
12
12
 
13
- - **Tiny**: **7,257 bytes** minified IIFE build
13
+ - **Tiny**: **6,177 bytes** minified IIFE build
14
14
  - **Read-only**: Extracts metadata and returns A1111-format text
15
15
  - **Zero dependencies**: Works in Node.js and browsers
16
16
  - **18+ tools**: Supports all major AI image generation tools
@@ -66,7 +66,7 @@ Load the IIFE build via `@require`:
66
66
  // ==UserScript==
67
67
  // @name My Script
68
68
  // @namespace https://example.com
69
- // @require https://cdn.jsdelivr.net/npm/@enslo/sd-metadata-lite@1.6.1/dist/index.global.js
69
+ // @require https://cdn.jsdelivr.net/npm/@enslo/sd-metadata-lite@1.7.0/dist/index.global.js
70
70
  // ==/UserScript==
71
71
 
72
72
  const response = await fetch(imageUrl);
@@ -85,7 +85,7 @@ if (text) {
85
85
 
86
86
  Most sites block external script loading via CSP. Instead, paste the IIFE bundle inline:
87
87
 
88
- 1. Copy the contents of `dist/index.global.js` (or download from [npm](https://cdn.jsdelivr.net/npm/@enslo/sd-metadata-lite@1.6.1/dist/index.global.js))
88
+ 1. Copy the contents of `dist/index.global.js` (or download from [npm](https://cdn.jsdelivr.net/npm/@enslo/sd-metadata-lite@1.7.0/dist/index.global.js))
89
89
  2. Build your bookmarklet with the code inlined:
90
90
 
91
91
  ```javascript
@@ -107,7 +107,7 @@ Parses metadata from an image and returns A1111-format text.
107
107
  **Returns:**
108
108
 
109
109
  - A1111-format metadata string if metadata is found
110
- - For PNG and JPEG files with no generation parameters, the C2PA Content Credentials generator name (e.g. `OpenAI Media Service API`, `Google C2PA Core Generator Library`, `Grok Imagine`) when present
110
+ - For PNG and JPEG files with no generation parameters, the name of the tool that made the image, from its C2PA Content Credentials (e.g. `ChatGPT`, `Kling AI`, `Grok Imagine`) when present
111
111
  - Empty string (`""`) if no metadata is found or the format is unrecognized
112
112
 
113
113
  ### Output Format
@@ -147,13 +147,15 @@ Reads PNG, JPEG, and WebP metadata from:
147
147
 
148
148
  ### Content Credentials (C2PA)
149
149
 
150
- PNG and JPEG files from commercial tools that sign their output with [C2PA](https://c2pa.org/) Content Credentials are detected by their generator name instead of generation parameters:
150
+ PNG and JPEG files from commercial tools that sign their output with [C2PA](https://c2pa.org/) Content Credentials are detected by the tool their manifest names instead of generation parameters:
151
151
 
152
152
  - OpenAI ChatGPT
153
153
  - Google Gemini
154
154
  - xAI Grok Imagine
155
+ - Kuaishou Kling AI
156
+ - ByteDance Dreamina
155
157
 
156
- For these images `parse()` returns the generator name (e.g. `OpenAI Media Service API`). Detection is best-effort: the credentials are easily stripped by re-saving or re-uploading, and a present manifest is not cryptographically verified.
158
+ For these images `parse()` returns the tool name as the image declares it (e.g. `ChatGPT`, `Kling AI`, `Dreamina/7.5.0`), or the name of the program that signed it when it declares none (Gemini: `Google C2PA Core Generator Library`). Detection is best-effort: the credentials are easily stripped by re-saving or re-uploading, and a present manifest is not cryptographically verified.
157
159
 
158
160
  ## Globals
159
161
 
package/dist/index.d.ts CHANGED
@@ -8,12 +8,14 @@
8
8
  * Parse AI-generated image metadata and return A1111-format text.
9
9
  *
10
10
  * Supports PNG, JPEG, and WebP formats across 18+ generation tools. For PNG
11
- * images with no generation parameters, falls back to C2PA Content Credentials
12
- * and returns the generator name (e.g. ChatGPT / Gemini exports).
11
+ * and JPEG images with no generation parameters, falls back to C2PA Content
12
+ * Credentials and returns the name of the tool that made the image
13
+ * (`ChatGPT`, `Kling AI`, `Grok Imagine`), or of the program that signed it
14
+ * when the manifest names no tool (Gemini exports).
13
15
  * Returns empty string if no metadata is found.
14
16
  *
15
17
  * @param input - Image file data
16
- * @returns A1111-format metadata text, the C2PA generator name, or empty string
18
+ * @returns A1111-format metadata text, a C2PA tool name, or empty string
17
19
  */
18
20
  export declare function parse(input: Uint8Array | ArrayBuffer): string;
19
21
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;;;;;;;wBAqBgB,MAAM,OAAO,aAAa"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;wBAuBgB,MAAM,OAAO,aAAa"}
@@ -1 +1 @@
1
- var sdml=(()=>{var e="class_type",t="parameters",r="use_stable_diffusion_model";function n(e,r){for(let n of["extraMetadata","invokeai_metadata","generation_data"])if(e[n]){let i={...r,[t]:r[t]??f(e[n]).replace(/(?<!\0)\0+$/,"")};return e.prompt&&(i.prompt??=f(e.prompt)),i}return r}function i(i){let p=function(e){if(e.Software?.startsWith("NovelAI"))return{...e,[t]:e[t]??e.Comment};let r=e.UserComment;if(!r)return n(e,e);if(!r.startsWith("{"))return r.includes("Steps:")?{...e,[t]:e[t]??r}:e;let i=o(r);if(!i)return e;let l=n(i,e);return l!==e?l:"prompt"in i&&"workflow"in i?{...e,prompt:e.prompt??f(i.prompt)}:t in i?{...e,[t]:e[t]??f(i[t])}:{...e,[t]:e[t]??r}}(i),m=p[t],h=p.prompt??p.Prompt;if(m?.includes("sui_image_params")){let e=o(m);if(e)return u(l(e.sui_image_params??e))}if(m&&!m.startsWith("{"))return m;if(m){let t=o(m);if(t){p.Source&&(t.Source=p.Source);let n=function(e,t){if(a(e.software).includes("RuinedFooocus")||r in e)return u(l(e));if(t.includes('"Model"')&&t.includes('"resolution"')){let[t,r]=c(a(e.resolution),/(?<!\d)(\d+)\s*x\s*(\d+)/);return u({...l(e),w:t,h:r})}if("base_model"in e){let[t,r]=c(a(e.resolution),/\(\s*(\d+)\s*,\s*(\d+)\s*\)/);return u({...l(e),w:t,h:r})}return"noise_schedule"in e?function(e){let t=e.v4_prompt?.caption,r=e.v4_negative_prompt?.caption,n=/^(.+) ([0-9A-F]{8})$/.exec(a(e.Source));return u({...l(e),p:(a(t?.base_caption)||a(e.prompt)).replace(/(^|, )teXt:(?!:).*/s,""),n:a(r?.base_caption)||a(e.uc),dn:a(e.strength),md:n?.[1]??a(e.Source),mh:n?.[2]})}(e):null}(t,m);if(n)return n;if(m.includes(e))return u(s(m));let i=l(t);return h?.includes(e)?u({...s(h),p:i.p,n:i.n,md:i.md,mh:i.mh}):u(i)}}return p[r]?u({...l(p),cs:""}):h?.includes(e)?u(s(h)):m??(function(e){if(!e)return"";let t=e.indexOf("claim_generator_info");if(t<0)return"";let r=e.indexOf("dname",t);if(r<0||r>t+256)return"";let n=r+5,i=e.charCodeAt(n);if(!(i>=96&&i<=120))return"";let l=120===i,s=l?e.charCodeAt(n+1)||0:i-96,u=n+(l?2:1);return u+s>e.length?"":e.slice(u,u+s)}(p.cabx)||(p.UserComment??p.Comment??p.ImageDescription??""))}function l(e){let t=a(e.sampler??e.sampler_name),n=a(e.scheduler??e.noise_schedule),i=e.model,l=e.baseModel,s=e.use_upscaler;return{p:e.full_prompt?.join?.(", ")||a(e.prompt??e.Prompt??e.positive_prompt),n:e.full_negative_prompt?.join?.(", ")||a(e.negative_prompt??e.Negative??e.negativeprompt??e.negativePrompt??e.uc),se:a(e.seed),st:a(e.steps??e.num_inference_steps),cf:a(e.cfg??e.cfg_scale??e.cfgScale??e.cfgscale??e.guidance_scale??e.scale),sa:t||n,sc:t?n:void 0,w:a(e.width),h:a(e.height),md:a(i)||a(e.Model)||a(e.base_model)||a(e.base_model_name)||a(l)||a(i?.name)||a(l?.modelFileName)||a(e[r]).split(/[\\/]/).pop(),mh:a(e.base_model_hash)||a(e["Model hash"])||a(i?.hash)||a(l?.hash),cs:a(e.clip_skip??e.clipSkip),hs:a(s?.upscale_by)||a(e.refinerupscale),hu:a(s?.upscale_method)||a(e.refinerupscalemethod),hd:a(s?.upscaler_strength)||a(e.refinercontrolpercentage),ht:a(s?.upscale_steps)}}function s(t){let r={},n="",i=o(t.replace(/(?<!\0)\0+$/,"").replace(/\bNaN\b/g,"null"));if(!i)return r;for(let t in i){let l=i[t];if(!l||"object"!=typeof l)continue;let s=a(l[e]),u=l.inputs;if(u){if(/User Prompt/.test(a(l._meta?.title))&&(n||=a(u.value)),/Text(Encode|.?Box)|ShowText|PromptStash/.test(s)){let e=a(u.text)||a(u.prompt)||a(u.Text)||a(u.prompt_text)||a(u.text_0);e&&(/neg/i.test(s)?r.n??=e:r.p?r.n||(r.n=e):r.p=e)}s.includes("Sampler")&&(r.se||=a(u.seed)||a(u.noise_seed),r.st||=a(u.steps),r.cf||=a(u.cfg),r.sa||=a(u.sampler_name),r.sc||=a(u.scheduler)),r.md||=a(u.ckpt_name)||a(u.unet_name),r.w||=a(u.width),r.h||=a(u.height)}}return r.p||=n,r}function u(e){let t=[];e.p&&t.push(e.p),e.n&&t.push("Negative prompt: "+e.n);let r=[],n=(e,t)=>{t&&r.push(`${e}: ${t}`)};return n("Steps",e.st),n("Sampler",e.sa),n("Schedule type",e.sc),n("CFG scale",e.cf),n("Seed",e.se),e.w&&e.h&&n("Size",`${e.w}x${e.h}`),n("Model hash",e.mh),n("Model",e.md),n("Clip skip",e.cs),n("Denoising strength",e.dn??e.hd),n("Hires upscale",e.hs),n("Hires steps",e.ht),n("Hires upscaler",e.hu),r.length&&t.push(r.join(", ")),t.join("\n")}function o(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function a(e){return"string"==typeof e?e:"number"==typeof e?e+"":""}function f(e){return"string"==typeof e?e:e&&"object"==typeof e?JSON.stringify(e):""}function c(e,t){if(!e)return[];let r=e.match(t);return r?[r[1],r[2]]:[]}function p(e){if(e.length<8)return{};let t=e[0],r=73===t;if(!r&&77!==t)return{};let n=h(e);if(42!==n.getUint16(2,r))return{};let i={},l=n.getUint32(4,r),s=0,u=e=>{let t=function(e){if(e.length<8)return null;let t=_(e,0,8),r=e.subarray(8);return"UNICODE\0"===t?r.length<2?null:function(e,t){let r="";for(let n=0;n+1<e.length;n+=2){let i=t?e[n]|e[n+1]<<8:e[n]<<8|e[n+1];if(!i)break;r+=g(i)}return r}(r,0!==r[0]&&0===r[1]):"ASCII\0\0\0"===t?y(r):b(e)}(e);if(t){if(t.startsWith("{"))try{let e=JSON.parse(t),r=e.Software,n=e.Comment;if("string"==typeof r&&r.startsWith("NovelAI")&&"string"==typeof n)return i.Software=r,i.Comment=n,void(i.Source=e.Source)}catch{}i.UserComment=t}};return m(e,n,l,r,(t,l)=>{if(t>269&&t<273){let e=y(l);if(e){let r=e.match(/^([A-Za-z]+):(?:\s|(?=\{))/);if(r){let t=r[1];t&&(i[t]=e.slice(r[0].length))}else i[270===t?"ImageDescription":271===t?"Make":"Model"]=e}}else 37510===t?u(l):34665===t&&(s=n.getUint32(l.byteOffset-e.byteOffset,r))}),s&&!i.UserComment&&!i.Software&&m(e,n,s,r,(e,t)=>{37510===e&&u(t)}),i}function m(e,t,r,n,i){let l=e=>t.getUint16(e,n),s=e=>t.getUint32(e,n);if(r+2>e.length)return;let u=l(r),o=r+2;for(let t=0;t<u;t++){if(o+12>e.length)return;let t=l(o),r=l(o+2),n=s(o+4)*([0,1,1,2,4,8,0,1][r]??1),u=n<=4?o+8:s(o+8);u+n<=e.length&&i(t,e.subarray(u,u+n)),o+=12}}function h(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}var d=new TextDecoder("utf-8",{fatal:!0}),g=String.fromCharCode;function _(e,t,r){let n="";for(let i=0;i<r;i++)n+=g(e[t+i]);return n}function b(e){try{return d.decode(e).replace(/\0$/,"")}catch{return null}}function y(e){let t=e.indexOf(0);return _(e,0,t<0?e.length:t).trim()||null}return{parse:function(e){let t=e instanceof ArrayBuffer?new Uint8Array(e):e;return 137===t[0]&&80===t[1]?i(function(e){let t={},r=h(e),n=8;for(;n+8<=e.length;){let i=r.getUint32(n),l=_(e,n+4,4);if(n+=8,n+i>e.length)break;if("caBX"===l&&(t.cabx=_(e,n,Math.min(i,8388608))),"eXIf"===l&&Object.assign(t,p(e.subarray(n,n+i))),"tEXt"===l||"iTXt"===l){let r=e.indexOf(0,n);if(r>n&&r<n+i){let s=_(e,n,r-n);if("tEXt"===l){let l=e.subarray(r+1,n+i);t[s]=b(l)??_(e,r+1,n+i-r-1)}else{let l=r+3,u=e.indexOf(0,l),o=u<0?-1:e.indexOf(0,u+1);if(u<0||o<0){n+=i+4;continue}t[s]=b(e.subarray(o+1,n+i))??""}}}if("IEND"===l)break;n+=i+4}return t}(t)):255===t[0]&&216===t[1]?i(function(e){let t={},r=2;for(;r+4<=e.length;){let n=e[r+1];if(255!==e[r]||255===n){r++;continue}if(n>216&&n<219)break;let i=e[r+2]<<8|e[r+3];if(225===n&&r+10<=e.length&&"Exif\0\0"===_(e,r+4,6)&&Object.assign(t,p(e.subarray(r+10,r+2+i))),235===n&&(t.cabx=(t.cabx??"")+_(e,r+12,i-10)),254===n){let n=b(e.subarray(r+4,r+2+i));n&&(t.Comment=n)}r+=2+i}return t}(t)):82===t[0]&&73===t[1]?i(function(e){let t=h(e),r=12;for(;r+8<=e.length;){let n=_(e,r,4),i=t.getUint32(r+4,!0);if(r+=8,"EXIF"===n&&r+i<=e.length)return p(e.subarray(r,r+i));r+=i+i%2}return{}}(t)):""}}})();
1
+ var sdml=(()=>{function e(e){let r={},i=e[0],c=73===i,f=t(e),p=e=>f.getUint16(e,c),h=e=>f.getUint32(e,c);if(e.length<8||!c&&77!==i||42!==p(2))return r;let d=(t,r)=>{for(let n=t+2,l=n>e.length?0:p(t);l--&&n+12<=e.length;n+=12){let t=[0,1,1,2,4,8,0,1][p(n+2)]??1,l=h(n+4)*t,i=l<=4?n+8:h(n+8);i+l<=e.length&&r(p(n),e.subarray(i,i+l),i)}},m=0,g=e=>{let t=(e=>{if(e.length<8)return null;let t=s(e,0,8),r=e.subarray(8);return"UNICODE\0"===t?((e,t)=>{let r="";for(let l=0;l+1<e.length;l+=2){let i=t?e[l]|e[l+1]<<8:e[l]<<8|e[l+1];if(!i)break;r+=n(i)}return r})(r,0===r[1]):"ASCII\0\0\0"===t?o(r):u(e)})(e);t&&(r[l]=t)};return d(h(4),(e,t,n)=>{if(e>269&&e<273){let n=o(t);if(n){let t=n.match(/^([A-Za-z]+):(?:\s|(?=\{))/);t?r[t[1]]=n.slice(t[0].length):r[[a,"Make","Model"][e-270]]=n}}else 37510===e?g(t):34665===e&&(m=h(n))}),m&&!r[l]&&d(m,(e,t)=>{37510===e&&g(t)}),r}function t(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}var r=new TextDecoder("utf-8",{fatal:!0}),n=String.fromCharCode,l="UserComment",i="Comment",a="ImageDescription";function s(e,t,r){let l="";for(let i=0;i<r;i++)l+=n(e[t+i]);return l}function u(e){try{return r.decode(e).replace(/\0$/,"")}catch{return null}}function o(e){let t=e.indexOf(0);return s(e,0,t<0?e.length:t).trim()||null}var c="class_type",f="parameters",p="use_stable_diffusion_model",h="prompt",d="Source",m="sui_image_params",g="noise_schedule",_="sampler_name",b="base_caption";function x(e,t){let r=["extraMetadata","invokeai_metadata","generation_data"].find(t=>e[t]);return r&&(t[f]??=N(e[r]).replace(/(?<!\0)\0+$/,""),e[h]&&(t[h]??=N(e[h]))),!!r}function y(e,t){let r=e.charCodeAt(t);if(!(r>=96&&r<=120))return"";let n=120===r,l=n?e.charCodeAt(t+1)||0:r-96,i=t+(n?2:1);return i+l>e.length?"":e.slice(i,i+l)}function S(e){let t=k(e.sampler??e[_]),r=k(e.scheduler??e[g]),n=e.model,l=e.baseModel,i=e.use_upscaler,a=k(e.resolution).match(/(?<!\d)(\d+)\s*[x,]\s*(\d+)/);return{p:e.full_prompt?.join?.(", ")||k(e[h]??e.Prompt??e.positive_prompt),n:e.full_negative_prompt?.join?.(", ")||k(e.negative_prompt??e.Negative??e.negativeprompt??e.negativePrompt??e.uc),se:k(e.seed),st:k(e.steps??e.num_inference_steps),cf:k(e.cfg??e.cfg_scale??e.cfgScale??e.cfgscale??e.guidance_scale??e.scale),sa:t||r,sc:t&&r,w:a?.[1]??k(e.width),h:a?.[2]??k(e.height),md:k(n,e.Model,e.base_model,e.base_model_name,l,n?.name,l?.modelFileName)||k(e[p]).split(/[\\/]/).pop(),mh:k(e.base_model_hash,e["Model hash"],n?.hash,l?.hash),cs:k(e.clip_skip??e.clipSkip),hs:k(i?.upscale_by,e.refinerupscale),hu:k(i?.upscale_method,e.refinerupscalemethod),hd:k(i?.upscaler_strength,e.refinercontrolpercentage),ht:k(i?.upscale_steps)}}function v(e){let t={},r="",n=O(e.replace(/(?<!\0)\0+$/,"").replace(/\bNaN\b/g,"null"));if(!n)return t;for(let e in n){let l=n[e],i=l?.inputs;if(!i)continue;let a=k(l[c]);if(/User Prompt/.test(k(l._meta?.title))&&(r||=k(i.value)),/Text(Encode|.?Box)|ShowText|PromptStash/.test(a)){let e=k(i.text,i[h],i.Text,i.prompt_text,i.text_0);e&&(/neg/i.test(a)?t.n??=e:t.p?t.n||(t.n=e):t.p=e)}a.includes("Sampler")&&(t.se||=k(i.seed,i.noise_seed),t.st||=k(i.steps),t.cf||=k(i.cfg),t.sa||=k(i[_]),t.sc||=k(i.scheduler)),t.md||=k(i.ckpt_name,i.unet_name),t.w||=k(i.width),t.h||=k(i.height)}return t.p||=r,t}function w(e){let t=(e,t)=>t?`${e}: ${t}`:"";return[e.p,t("Negative prompt",e.n),[t("Steps",e.st),t("Sampler",e.sa),t("Schedule type",e.sc),t("CFG scale",e.cf),t("Seed",e.se),t("Size",e.w&&e.h&&`${e.w}x${e.h}`),t("Model hash",e.mh),t("Model",e.md),t("Clip skip",e.cs),t("Denoising strength",e.dn??e.hd),t("Hires upscale",e.hs),t("Hires steps",e.ht),t("Hires upscaler",e.hu)].filter(Boolean).join(", ")].filter(Boolean).join("\n")}function O(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function k(...e){return""+(e.find(e=>"string"==typeof e&&e||"number"==typeof e)??"")}function N(e){return"string"==typeof e?e:e&&"object"==typeof e?JSON.stringify(e):""}return{parse:r=>{let n=r instanceof ArrayBuffer?new Uint8Array(r):r,o=n[0]<<8|n[1];return(e=>{let t=(e=>{let t={...e},r=t[l];if(t.Software?.startsWith("NovelAI"))t[f]??=t[i];else if(r)if(r.startsWith("{")){let e=O(r),n=e?.[i];k(e?.Software).startsWith("NovelAI")&&"string"==typeof n?(t[f]??=n,t[d]=e[d]):e&&!x(e,t)&&(h in e&&"workflow"in e?t[h]??=N(e[h]):t[f]??=f in e?N(e[f]):r)}else r.includes("Steps:")&&(t[f]??=r);else x(t,t);return t})(e),r=t[f],n=t[h]??t.Prompt,s=O(r);if(s&&r.includes(m))return w(S(s[m]??s));if(r&&!r.startsWith("{"))return r;if(s){if(t[d]&&(s[d]=t[d]),g in s)return(e=>{let t=e.v4_prompt?.caption,r=e.v4_negative_prompt?.caption,n=/^(.+) ([0-9A-F]{8})$/.exec(k(e[d]));return w({...S(e),p:k(t?.[b],e[h]).replace(/(^|, )teXt:(?!:).*/s,""),n:k(r?.[b],e.uc),dn:k(e.strength),md:n?.[1]??k(e[d]),mh:n?.[2]})})(s);if(r.includes(c))return w(v(r));let e=S(s);return n?.includes(c)?w({...v(n),p:e.p,n:e.n,md:e.md,mh:e.mh}):w(e)}return t[p]?w({...S(t),cs:""}):n?.includes(c)?w(v(n)):r??((e=>{if(!e)return"";let t=(t,r)=>{let n=e.indexOf("dname",t);return t<0||n<0||n>t+r?"":y(e,n+5)},r=e.indexOf("softwareAgent");return(r<0?"":y(e,r+13))||t(r,14)||t(e.indexOf("claim_generator_info"),256)})(t.cabx)||(t[l]??t[i]??t[a]??""))})(35152===o?(r=>{let n={},l=t(r),i=8;for(;i+8<=r.length;){let t=l.getUint32(i),a=s(r,i+4,4);if(i+=8,i+t>r.length)break;if("caBX"===a&&(n.cabx=s(r,i,Math.min(t,8388608))),"eXIf"===a&&Object.assign(n,e(r.subarray(i,i+t))),"tEXt"===a||"iTXt"===a){let e=r.indexOf(0,i);if(e>i&&e<i+t){let l=s(r,i,e-i);if("tEXt"===a){let a=r.subarray(e+1,i+t);n[l]=u(a)??s(r,e+1,i+t-e-1)}else{let a=r.indexOf(0,e+3),s=r.indexOf(0,a+1);a>=0&&s>=0&&(n[l]=u(r.subarray(s+1,i+t))??"")}}}if("IEND"===a)break;i+=t+4}return n})(n):65496===o?(t=>{let r={},n=2;for(;n+4<=t.length;){let l=t[n+1];if(255!==t[n]||255===l){n++;continue}if(l>216&&l<219)break;let a=t[n+2]<<8|t[n+3];if(225===l&&"Exif\0\0"===s(t,n+4,6)&&Object.assign(r,e(t.subarray(n+10,n+2+a))),235===l&&(r.cabx=(r.cabx??"")+s(t,n+12,a-10)),254===l){let e=u(t.subarray(n+4,n+2+a));e&&(r[i]=e)}n+=2+a}return r})(n):21065===o?(r=>{let n=t(r),l=12;for(;l+8<=r.length;){let t=s(r,l,4),i=n.getUint32(l+4,!0);if(l+=8,"EXIF"===t&&l+i<=r.length)return e(r.subarray(l,l+i));l+=i+i%2}return{}})(n):{})}}})();