@opencraw/studio 0.0.37 → 0.0.38
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.
|
@@ -15,7 +15,7 @@ Error generating stack: `+e.message+`
|
|
|
15
15
|
${String(e.value)}`:r?`Hidden row
|
|
16
16
|
${String(e.value)}`:String(e.value),truncate:!0,children:String(e.value)})}function WU({match:e}){let t=e.rows.slice(0,kU);return(0,F.jsxs)(I,{borderTopWidth:`1px`,maxH:`160px`,overflow:`auto`,flexShrink:0,children:[(0,F.jsx)(W,{px:2,py:1,gap:2,children:(0,F.jsx)(V,{fontSize:`xs`,color:`fg.muted`,children:`Live preview: ${String(e.rows.length)} row${e.rows.length===1?``:`s`} matched${e.title===``?``:` ("${e.title}")`}`})}),(0,F.jsxs)(hT,{size:`sm`,variant:`outline`,children:[(0,F.jsx)(vT,{children:(0,F.jsx)(gT,{children:e.header.map(e=>(0,F.jsx)(yT,{fontSize:`2xs`,children:e},e))})}),(0,F.jsx)(xT,{children:t.map((t,n)=>(0,F.jsx)(gT,{children:e.header.map(e=>(0,F.jsx)(bT,{fontSize:`2xs`,children:String(t[e]??``)},e))},n))})]})]})}function GU({format:e,override:t,onChange:n}){let r=t?.delimiter??e.delimiter,i=t?.encoding??e.encoding;return(0,F.jsxs)(W,{gap:2,children:[(0,F.jsx)(V,{fontSize:`xs`,color:`fg.muted`,children:`Delimiter`}),(0,F.jsx)(Dw,{size:`xs`,width:`40px`,defaultValue:r,onBlur:e=>{let i=e.target.value;i!==``&&i!==r&&n({delimiter:i,encoding:t?.encoding})}},r),(0,F.jsx)(V,{fontSize:`xs`,color:`fg.muted`,children:`Encoding`}),(0,F.jsx)(Dw,{size:`xs`,width:`110px`,defaultValue:i,onBlur:e=>{let r=e.target.value;r!==``&&r!==i&&n({delimiter:t?.delimiter,encoding:r})}},i)]})}var KU=2,qU=.15,JU=.6,YU=3,XU=40,ZU=1.15,QU=.95;function $U(e,t){let n=iW(t),r=e.rows.findIndex(e=>e.cells.includes(t));if(r===-1||e.rows[r]?.cells.length!==1)return n;let i=n,a=t;for(let t=r+1;t<e.rows.length;t+=1){let n=nW(e,t);if(n===void 0||!rW(a,n))break;i=aW(i,iW(n)),a=n}a=t;for(let t=r-1;t>=0;--t){let n=nW(e,t);if(n===void 0||!rW(n,a))break;i=aW(i,iW(n)),a=n}return i}function eW(e){let t=/^([A-Z][\w &()./-]*):\s*(\S.*)$/i.exec(e.trim());if(t===null)return;let[,n=``,r=``]=t,i=n.trim();if(!(i.length>XU||r.startsWith(`//`)))return{label:i,value:r.trim()}}function tW(e){let[t,...n]=e.toLowerCase().split(/[^\da-z]+/).filter(e=>e!==``);if(t===void 0)return`value`;let r=t+n.map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``);return/^\d/.test(r)?`value${r.charAt(0).toUpperCase()}${r.slice(1)}`:r}function nW(e,t){let n=e.rows[t]?.cells;return n?.length===1?n[0]:void 0}function rW(e,t){let n=e.y-(t.y+t.height),r=Math.abs(e.height-t.height)<=Math.max(e.height,t.height)*qU,i=Math.abs(e.x-t.x)<=KU,a=Math.abs(e.x+e.width/2-(t.x+t.width/2))<=YU;return(i||a)&&r&&n<=e.height*JU}function iW(e){return{x1:e.x,y1:e.y,x2:e.x+Math.max(e.width,1),y2:e.y+e.height}}function aW(e,t){return{x1:Math.min(e.x1,t.x1),y1:Math.min(e.y1,t.y1),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}}function oW(e,t,n){let r=e.flatMap(e=>e.rows.filter(e=>e.running!==!0).map(t=>({page:e.number,row:t}))),i=r.findIndex(e=>e.row.cells.includes(n)),a=r[i]?.row;if(a===void 0||sW(a))return;let o=cW(r,i,n.height);return o===-1?dW(t,r,i):uW(r,o,t.number,e.some(e=>e.rows.some(e=>e.running===!0)),n)}function sW(e){return e.cells.length>1&&e.cells.every(e=>eW(e.text)!==void 0)}function cW(e,t,n){for(let r=t-1;r>=0;--r){let t=e[r]?.row.cells??[],i=t[0];if(i!==void 0&&i.height>n*ZU&&t.length===1&&lW(e,r))return r}return-1}function lW(e,t){let n=e[t]?.row.cells[0]?.height??0;return e.some((e,r)=>r!==t&&e.row.cells.length===1&&Math.abs((e.row.cells[0]?.height??0)-n)<=n*.050000000000000044)}function uW(e,t,n,r,i){let a=e[t]?.row,o=a?.cells[0]?.height??0,s=a?.cells[0]?.text;if(s===void 0)return;let c=e.slice(t+1),l=c.findIndex(e=>Math.max(...e.row.cells.map(e=>e.height))>=o*QU),u=l===-1?c:c.slice(0,l),[d,...f]=u.filter(e=>e.page===n).flatMap(e=>e.row.cells).map(e=>iW(e));if(d===void 0)return;let p=l===-1?void 0:c[l]?.row.cells.map(e=>e.text).join(` `),m=u.map(e=>e.row),h=m.every(e=>e.cells.length===1)?m.findIndex(e=>e.cells[0]===i)+1:0;return{kind:`section`,heading:s,...p!==void 0&&{until:p},box:f.reduce((e,t)=>aW(e,t),d),ignoreHeadersFooters:r,...h>0&&{clickedLine:h}}}function dW(e,t,n){let r=t.filter(t=>t.page===e.number).map(e=>e.row),i=r.indexOf(t[n]?.row);if(r[i]?.cells.length!==1)return;let a=i;for(;a>0&&fW(r[a-1],r[a]);)--a;let o=i;for(;o<r.length-1&&fW(r[o],r[o+1]);)o+=1;let s=r[a-1],c=r.slice(a,o+1).map(e=>e.cells[0]).filter(e=>e!==void 0),[l,...u]=c;if(s!==void 0&&l!==void 0&&!(c.length>1&&l.height<=pW(r)*ZU))return{kind:`after`,previous:s.cells.map(e=>e.text).join(` `),lines:c.length,box:u.reduce((e,t)=>aW(e,iW(t)),iW(l)),page:e.number}}function fW(e,t){let n=e?.cells.length===1?e.cells[0]:void 0,r=t?.cells.length===1?t.cells[0]:void 0;return n!==void 0&&r!==void 0&&!n.text.trimEnd().endsWith(`:`)&&rW(n,r)}function pW(e){let t=e.map(e=>Math.max(...e.cells.map(e=>e.height))).sort((e,t)=>e-t);return t[Math.floor(t.length/2)]??0}var mW=[{name:`date`,test:/\b\d{1,2}\s+[A-Z]{3,9}\s+\d{4}\b/i,pattern:String.raw`(\d{1,2} [A-Za-z]{3,9} \d{4})`},{name:`date`,test:/\b\d{4}-\d{2}-\d{2}\b/,pattern:String.raw`(\d{4}-\d{2}-\d{2})`},{name:`email address`,test:/[\w.+-]+@[\w-]+(?:\.[\w-]+)+/,pattern:String.raw`([\w.+-]+@[\w-]+(?:\.[\w-]+)+)`},{name:`amount`,test:/[£$€]\s?\d[\d,.]*/,pattern:String.raw`([£$€]\s?\d[\d,.]*)`}];function hW(e){let t=mW.find(t=>t.test.test(e));return t===void 0?void 0:{name:t.name,pattern:t.pattern}}function gW(e,t,n,r){let i=oW(e,t,n),a=[{...i!==void 0&&{anchor:i},box:nH(i?.kind===`section`||i?.kind===`after`&&i.lines>1?i.box:r)}];if(i?.kind===`section`){let e=tH(n),t=hW(n.text);i.clickedLine!==void 0&&a.push({anchor:{...i,line:i.clickedLine,box:e},box:e}),t!==void 0&&a.push({anchor:{...i,match:t.pattern,matchName:t.name,box:e},box:e})}return i!==void 0&&a.push({box:nH(r)}),a}var _W=`modulepreload`,vW=function(e){return`/`+e},yW={},bW=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=vW(t,n),t=s(t),t in yW)return;yW[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:_W,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},xW=[],SW=1.5,CW=20,wW=`#8a8d94`,TW=1.2,EW=24,DW=4,OW=[`#2e86ab`,`#3bb273`],kW=`#e4572e`,AW=`rgba(59, 178, 115, 0.18)`,jW=`#1d4ed8`,MW=`#ea580c`;function NW({recipeId:e,stepPath:t,view:n,bytesUrl:r,zoom:i=1,onTablePick:a,onRegionPick:o,steps:s=xW,hoveredStepId:c,onHoverStepId:l}){let[u,d]=(0,P.useState)(0),[f,p]=(0,P.useState)(`text`),[m,h]=(0,P.useState)({}),[g,_]=(0,P.useState)(void 0),[v,y]=(0,P.useState)(void 0),[b,x]=(0,P.useState)(void 0),S=(0,P.useRef)(null),C=(0,P.useRef)(null),[w,T]=(0,P.useState)(1),E=w*i,D=(0,P.useRef)(void 0),O=n.pages[u],k=(0,P.useMemo)(()=>zH(s,`page`,O?.number??-1),[s,O?.number]),A=O===void 0?0:Math.ceil(O.width*SW),ee=O===void 0?0:Math.ceil(O.height*SW),te=sO(e,t,m.header===void 0?void 0:{header:m.header,until:m.until,columns:m.columns}),ne=(0,P.useMemo)(()=>te.data?.matches.find(e=>e.page===O?.number),[te.data,O?.number]),re=v===void 0?void 0:eH(`page`,v.page,v.box),ie=cO(e,t,re),ae=ie.data?.matches.find(e=>e.page===v?.page),oe=ae?.text;if((0,P.useEffect)(()=>{m.header!==void 0&&a($V(m,t,void 0,n.pages.some(e=>e.rows.some(e=>e.running===!0))))},[m]),(0,P.useEffect)(()=>{let e=C.current;if(e===null||A===0||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{let t=e.clientWidth-CW;T(t>0?Math.min(1,t/A):1)});return t.observe(e),()=>{t.disconnect()}},[A]),(0,P.useEffect)(()=>{let e=S.current;if(e===null||O===void 0)return;let t=new AbortController;return(async()=>{try{await YW(e,r,O.number,SW,t.signal)}catch(e){t.signal.aborted||console.error(`PDF canvas: could not render the page`,e)}})(),()=>{t.abort()}},[r,O?.number]),O===void 0)return(0,F.jsx)(I,{p:4,color:`fg.muted`,children:(0,F.jsx)(V,{children:`This PDF has no pages.`})});function se(e){let t=e.cells[0]?.text??``;if(f===`header`){h({header:ZV(t)});return}f===`until`&&m.header!==void 0&&h(e=>({...e,until:ZV(t)}))}function ce(e){m.header!==void 0&&h(t=>({...t,columns:{...t.columns,[QV(e)]:ZV(e)}}))}function j(e,t,n){let r=v;if(t&&r!==void 0&&r.page===O.number){y({page:O.number,box:rH(r.box,e)});return}let i=n?.[0];y({page:O.number,box:e,...i?.anchor!==void 0&&{anchor:i.anchor},...n!==void 0&&{choices:n,choice:0}})}function le(e){let t=v,n=t?.choices?.[e];t!==void 0&&n!==void 0&&y({page:t.page,box:n.box,choices:t.choices,choice:e,...n.anchor!==void 0&&{anchor:n.anchor}})}function ue(e){l!==void 0&&D.current!==e&&(D.current=e,l(e))}function de(e){if(f!==`text`)return;let t=zW(e);if(b!==void 0){x({...b,currentX:t.x,currentY:t.y});return}let n=WW(O,t);_(n),ue(n===void 0?void 0:VH(tH(n),k)[0])}function fe(e){if(f!==`text`||e.button!==0)return;let t=zW(e);x({startX:t.x,startY:t.y,currentX:t.x,currentY:t.y})}function pe(e){if(f!==`text`||b===void 0)return;let t=zW(e);if(x(void 0),Math.abs(t.x-b.startX)+Math.abs(t.y-b.startY)>DW){j(UW(O,b.startX,b.startY,t.x,t.y),e.shiftKey);return}let r=WW(O,t);if(r===void 0){e.shiftKey||y(void 0);return}if(e.shiftKey){j(nH($U(O,r)),!0);return}let i=gW(n.pages,O,r,$U(O,r));j(i[0]?.box??nH($U(O,r)),!1,i)}function me(){if(re===void 0||oe===void 0)return;let e=v?.anchor;if(e?.kind===`section`)return sH(e.heading,e.until,e.ignoreHeadersFooters,t,tW(e.matchName??(e.line===void 0?e.heading:`${e.heading} line ${String(e.line)}`)),{...e.line!==void 0&&{line:e.line},...e.match!==void 0&&{match:e.match}});if(e===void 0&&(v?.choices?.length??0)>1)return aH(re,t,iH(oe));let n=oe.includes(`
|
|
17
17
|
`)?void 0:eW(oe);return n===void 0?e?.kind===`after`?cH(e.previous,t,tW(e.previous),e.lines):aH(re,t,iH(oe)):oH(n.label,t,tW(n.label))}function he(){let e=me();e!==void 0&&(o(e),y(void 0))}function ge(e){let t=me();t!==void 0&&oe!==void 0&&(e.dataTransfer.setData(mk,hk(t)),e.dataTransfer.setData(`text/plain`,oe),e.dataTransfer.effectAllowed=`copy`)}let _e=f===`text`,ve=v!==void 0&&v.page===O.number?v:void 0;return(0,F.jsxs)(I,{h:`full`,display:`flex`,flexDirection:`column`,children:[(0,F.jsxs)(W,{px:3,py:2,borderBottomWidth:`1px`,gap:3,flexShrink:0,flexWrap:`wrap`,children:[n.pages.length>1&&(0,F.jsx)(KW,{pages:n.pages.length,value:u,onChange:d}),n.pages.length>1&&(0,F.jsx)(V,{fontSize:`sm`,color:`fg.muted`,children:`of ${String(n.pages.length)}`}),(0,F.jsx)(GW,{label:`Text`,active:_e,onClick:()=>{p(`text`)}}),(0,F.jsx)(GW,{label:`Header row`,tip:`The row that names the columns of a table: click it to say where the table starts.`,active:f===`header`,onClick:()=>{p(`header`)}}),(0,F.jsx)(GW,{label:`Last row (until)`,tip:`The line that comes right after the table: click it to say where the table stops.`,active:f===`until`,onClick:()=>{p(`until`)}}),(0,F.jsx)(GW,{label:`Column`,tip:`Click a column to collect everything under it.`,active:f===`column`,onClick:()=>{p(`column`)}}),(0,F.jsx)(V,{fontSize:`xs`,color:`fg.muted`,children:`${String(O.rowCount)} rows, ${String(O.cellCount)} cells${O.hasTextLayer?``:` — no text layer (a scan?)`}`}),_e&&(0,F.jsx)(V,{fontSize:`xs`,color:`fg.muted`,visibility:v===void 0?`visible`:`hidden`,children:`Click a line (shift+click to extend) or drag a box, then add it to the recipe or drag it onto the Steps tab.`}),m.header!==void 0&&(0,F.jsx)(LC,{size:`sm`,colorPalette:`green`,children:`table: ${m.header}${m.until===void 0?``:` until ${m.until}`}`}),te.data?.error!==void 0&&(0,F.jsx)(LC,{size:`sm`,colorPalette:`orange`,children:te.data.error}),ie.data?.error!==void 0&&(0,F.jsx)(LC,{size:`sm`,colorPalette:`orange`,children:ie.data.error})]}),(0,F.jsx)(I,{ref:C,flex:`1`,minH:`0`,overflow:`auto`,position:`relative`,style:{background:wW},onContextMenu:e=>{e.preventDefault()},children:(0,F.jsx)(I,{position:`relative`,width:`${String(Math.ceil(A*E))}px`,height:`${String(Math.ceil(ee*E))}px`,style:{boxShadow:`0 0 0 1px rgba(128,128,128,0.5), 0 2px 10px rgba(0,0,0,0.22)`},children:(0,F.jsxs)(I,{position:`absolute`,top:0,left:0,width:`${String(A)}px`,height:`${String(ee)}px`,style:{transform:`scale(${String(E)})`,transformOrigin:`top left`},children:[(0,F.jsx)(`canvas`,{ref:S,width:A,height:ee,style:{position:`absolute`,top:0,left:0}}),(0,F.jsxs)(`svg`,{"data-testid":`pdf-overlay`,width:A,height:ee,style:{position:`absolute`,top:0,left:0,cursor:_e?`crosshair`:`pointer`},onMouseMove:de,onMouseDown:fe,onMouseUp:pe,onMouseLeave:()=>{_(void 0),ue(void 0)},children:[k.map(e=>(0,F.jsx)(`rect`,{"data-testid":`recipe-region`,"data-step-id":e.id,"data-highlighted":e.id===c,...HW(e.box,O.height),fill:e.id===c?`rgba(234, 88, 12, 0.22)`:`rgba(234, 88, 12, 0.05)`,stroke:MW,strokeWidth:e.id===c?2:1,strokeDasharray:e.id===c?void 0:`4 3`,pointerEvents:`none`,children:(0,F.jsx)(`title`,{children:`In the recipe: ${e.id}`})},`recipe:${e.id}`)),O.rows.map((e,t)=>(0,F.jsx)(qW,{row:e,colour:e.cells[0]?.text!==void 0&&ne?.headerRowIndex===t?kW:OW[t%2],highlighted:ne?.matchedRowIndices.includes(t)??!1,scale:SW,pageHeight:O.height,cursor:_e?`crosshair`:`pointer`,onClick:_e?void 0:()=>{se(e)}},`${String(e.top)}:${String(e.bottom)}`)),f===`column`&&ne!==void 0&&ne.bands.map(e=>(0,F.jsx)(JW,{band:e,scale:SW,pageHeight:O.height,onClick:()=>{ce(e.name)}},e.column)),_e&&g!==void 0&&b===void 0&&(0,F.jsx)(`rect`,{"data-testid":`snap-target`,...VW(g,O.height),fill:`rgba(29, 78, 216, 0.08)`,stroke:jW,strokeWidth:1.5,strokeDasharray:`3 2`,pointerEvents:`none`}),ve!==void 0&&(0,F.jsx)(`rect`,{"data-testid":`staged-region`,...HW(ve.box,O.height),fill:`rgba(155, 93, 229, 0.12)`,stroke:`#9b5de5`,strokeWidth:1.5,pointerEvents:`none`}),ve!==void 0&&ae?.cells.map(e=>(0,F.jsx)(`rect`,{"data-testid":`staged-cell`,...VW(e,O.height),fill:`rgba(155, 93, 229, 0.28)`,pointerEvents:`none`},BW(e))),b!==void 0&&(0,F.jsx)(`rect`,{x:Math.min(b.startX,b.currentX),y:Math.min(b.startY,b.currentY),width:Math.abs(b.currentX-b.startX),height:Math.abs(b.currentY-b.startY),fill:`rgba(155, 93, 229, 0.2)`,stroke:`#9b5de5`,strokeDasharray:`4 2`,pointerEvents:`none`})]}),ve!==void 0&&(0,F.jsx)(MH,{left:Math.min(ve.box.x1,ve.box.x2)*SW,top:FW(ve.box,O.height),text:IW(ve.anchor,oe),note:RW(ve.anchor,oe),choices:ve.choices?.map(e=>LW(e)),choice:ve.choice,onChoose:le,loading:ie.isPending,onAdd:he,onClear:()=>{y(void 0)},onDragStart:ge})]})})})]})}var PW=56;function FW(e,t){let n=(t-Math.max(e.y1,e.y2))*SW,r=(t-Math.min(e.y1,e.y2))*SW;return n>=PW?n-PW:r+6}function IW(e,t){if(t===void 0||e?.kind!==`section`||e.match===void 0)return t;let n=new RegExp(e.match,`i`).exec(t);return n===null?void 0:n[1]??n[0]}function LW(e){let{anchor:t}=e;return t?.kind===`section`?t.line===void 0?t.matchName===void 0?t.until===void 0?`The whole block below “${t.heading}”`:`The whole block between “${t.heading}” and “${t.until}”`:`Only the ${t.matchName} in the block`:`Only this line (line ${String(t.line)} of the block)`:t?.kind===`after`?t.lines>1?`The ${String(t.lines)} lines after “${t.previous}”`:`The line after “${t.previous}”`:`A fixed position on the page (breaks if the layout moves)`}function RW(e,t){let n=t!==void 0&&!t.includes(`
|
|
18
|
-
`)&&eW(t)!==void 0;return e?.kind===`section`&&e.line!==void 0?`Reads line ${String(e.line)} of what is between “${e.heading}” and ${e.until===void 0?`the end`:`“${e.until}”`}`:e?.kind===`section`&&e.matchName!==void 0?`Reads the ${e.matchName} in what is below “${e.heading}”, wherever it sits`:e?.kind===`section`?e.until===void 0?`Reads everything below “${e.heading}”`:`Reads what is between “${e.heading}” and “${e.until}”`:n?`Reads the value after its label`:e?.kind===`after`?e.lines>1?`Reads the ${String(e.lines)} lines after “${e.previous}”`:`Reads the line after “${e.previous}”`:`Reads a fixed position on the page: it breaks when the layout moves`}function zW(e){let t=e.currentTarget.getBoundingClientRect(),n=Number(e.currentTarget.getAttribute(`width`)),r=t.width>0&&n>0?t.width/n:1;return{x:(e.clientX-t.left)/r,y:(e.clientY-t.top)/r}}function BW(e){return`staged:${String(e.x)}:${String(e.y)}`}function VW(e,t){return{x:e.x*SW,y:(t-e.y-e.height)*SW,width:Math.max(e.width,1)*SW,height:e.height*SW*TW}}function HW(e,t){let[n,r]=[Math.min(e.x1,e.x2),Math.max(e.x1,e.x2)],[i,a]=[Math.min(e.y1,e.y2),Math.max(e.y1,e.y2)];return{x:n*SW,y:(t-a)*SW,width:(r-n)*SW,height:(a-i)*SW}}function UW(e,t,n,r,i){return{x1:t/SW,y1:e.height-n/SW,x2:r/SW,y2:e.height-i/SW}}function WW(e,t){let n;for(let r of e.rows)for(let i of r.cells){let r=VW(i,e.height),a=Math.max(r.x-t.x,0,t.x-(r.x+r.width)),o=Math.max(r.y-t.y,0,t.y-(r.y+r.height)),s=Math.hypot(a,o);s<=EW&&(n===void 0||s<n.distance)&&(n={cell:i,distance:s})}return n?.cell}function GW({label:e,tip:t,active:n,onClick:r}){return(0,F.jsx)(V,{as:`button`,title:t,fontSize:`sm`,fontWeight:n?`semibold`:`normal`,color:n?`colorPalette.fg`:`fg`,colorPalette:`brand`,cursor:`pointer`,onClick:r,children:e})}function KW({pages:e,value:t,onChange:n}){let r=a_({items:Array.from({length:e},(e,t)=>({label:`Page ${String(t+1)}`,value:String(t)}))});return(0,F.jsxs)(Hw,{collection:r,size:`sm`,width:`140px`,value:[String(t)],onValueChange:e=>{n(Number(e.value[0]))},children:[(0,F.jsx)(Yw,{}),(0,F.jsx)(Jw,{children:(0,F.jsx)(Uw,{children:(0,F.jsx)(Kw,{})})}),(0,F.jsx)(Ww,{children:(0,F.jsx)(Gw,{children:r.items.map(e=>(0,F.jsx)(qw,{item:e,children:e.label},e.value))})})]})}function qW({row:e,colour:t,highlighted:n,scale:r,pageHeight:i,cursor:a,onClick:o}){return(0,F.jsxs)(`g`,{onClick:o,style:{cursor:a},children:[n&&e.cells.length>0&&(0,F.jsx)(`rect`,{x:Math.min(...e.cells.map(e=>e.x))*r,y:(i-e.top)*r,width:(Math.max(...e.cells.map(e=>e.x+e.width))-Math.min(...e.cells.map(e=>e.x)))*r,height:(e.top-e.bottom)*r,fill:AW}),e.cells.map(e=>(0,F.jsx)(`rect`,{x:e.x*r,y:(i-e.y-e.height)*r,width:Math.max(e.width,1)*r,height:e.height*r*TW,fill:`transparent`,stroke:t,strokeWidth:1.5},`${String(e.x)}:${String(e.y)}`))]})}function JW({band:e,scale:t,pageHeight:n,onClick:r}){return(0,F.jsx)(`rect`,{x:e.start*t,y:0,width:Math.max(e.end-e.start,1)*t,height:n*t,fill:`rgba(46, 134, 171, 0.08)`,stroke:`#2e86ab`,strokeDasharray:`4 2`,onClick:r,style:{cursor:`pointer`},children:(0,F.jsx)(`title`,{children:e.name})})}async function YW(e,t,n,r,i){let a=await bW(()=>import(`./pdf-
|
|
18
|
+
`)&&eW(t)!==void 0;return e?.kind===`section`&&e.line!==void 0?`Reads line ${String(e.line)} of what is between “${e.heading}” and ${e.until===void 0?`the end`:`“${e.until}”`}`:e?.kind===`section`&&e.matchName!==void 0?`Reads the ${e.matchName} in what is below “${e.heading}”, wherever it sits`:e?.kind===`section`?e.until===void 0?`Reads everything below “${e.heading}”`:`Reads what is between “${e.heading}” and “${e.until}”`:n?`Reads the value after its label`:e?.kind===`after`?e.lines>1?`Reads the ${String(e.lines)} lines after “${e.previous}”`:`Reads the line after “${e.previous}”`:`Reads a fixed position on the page: it breaks when the layout moves`}function zW(e){let t=e.currentTarget.getBoundingClientRect(),n=Number(e.currentTarget.getAttribute(`width`)),r=t.width>0&&n>0?t.width/n:1;return{x:(e.clientX-t.left)/r,y:(e.clientY-t.top)/r}}function BW(e){return`staged:${String(e.x)}:${String(e.y)}`}function VW(e,t){return{x:e.x*SW,y:(t-e.y-e.height)*SW,width:Math.max(e.width,1)*SW,height:e.height*SW*TW}}function HW(e,t){let[n,r]=[Math.min(e.x1,e.x2),Math.max(e.x1,e.x2)],[i,a]=[Math.min(e.y1,e.y2),Math.max(e.y1,e.y2)];return{x:n*SW,y:(t-a)*SW,width:(r-n)*SW,height:(a-i)*SW}}function UW(e,t,n,r,i){return{x1:t/SW,y1:e.height-n/SW,x2:r/SW,y2:e.height-i/SW}}function WW(e,t){let n;for(let r of e.rows)for(let i of r.cells){let r=VW(i,e.height),a=Math.max(r.x-t.x,0,t.x-(r.x+r.width)),o=Math.max(r.y-t.y,0,t.y-(r.y+r.height)),s=Math.hypot(a,o);s<=EW&&(n===void 0||s<n.distance)&&(n={cell:i,distance:s})}return n?.cell}function GW({label:e,tip:t,active:n,onClick:r}){return(0,F.jsx)(V,{as:`button`,title:t,fontSize:`sm`,fontWeight:n?`semibold`:`normal`,color:n?`colorPalette.fg`:`fg`,colorPalette:`brand`,cursor:`pointer`,onClick:r,children:e})}function KW({pages:e,value:t,onChange:n}){let r=a_({items:Array.from({length:e},(e,t)=>({label:`Page ${String(t+1)}`,value:String(t)}))});return(0,F.jsxs)(Hw,{collection:r,size:`sm`,width:`140px`,value:[String(t)],onValueChange:e=>{n(Number(e.value[0]))},children:[(0,F.jsx)(Yw,{}),(0,F.jsx)(Jw,{children:(0,F.jsx)(Uw,{children:(0,F.jsx)(Kw,{})})}),(0,F.jsx)(Ww,{children:(0,F.jsx)(Gw,{children:r.items.map(e=>(0,F.jsx)(qw,{item:e,children:e.label},e.value))})})]})}function qW({row:e,colour:t,highlighted:n,scale:r,pageHeight:i,cursor:a,onClick:o}){return(0,F.jsxs)(`g`,{onClick:o,style:{cursor:a},children:[n&&e.cells.length>0&&(0,F.jsx)(`rect`,{x:Math.min(...e.cells.map(e=>e.x))*r,y:(i-e.top)*r,width:(Math.max(...e.cells.map(e=>e.x+e.width))-Math.min(...e.cells.map(e=>e.x)))*r,height:(e.top-e.bottom)*r,fill:AW}),e.cells.map(e=>(0,F.jsx)(`rect`,{x:e.x*r,y:(i-e.y-e.height)*r,width:Math.max(e.width,1)*r,height:e.height*r*TW,fill:`transparent`,stroke:t,strokeWidth:1.5},`${String(e.x)}:${String(e.y)}`))]})}function JW({band:e,scale:t,pageHeight:n,onClick:r}){return(0,F.jsx)(`rect`,{x:e.start*t,y:0,width:Math.max(e.end-e.start,1)*t,height:n*t,fill:`rgba(46, 134, 171, 0.08)`,stroke:`#2e86ab`,strokeDasharray:`4 2`,onClick:r,style:{cursor:`pointer`},children:(0,F.jsx)(`title`,{children:e.name})})}async function YW(e,t,n,r,i){let a=await bW(()=>import(`./pdf-DsGxkxnt.js`),[]),o=await bW(()=>import(`./pdf.worker.min-D7i8o3wR.js`),[]);a.GlobalWorkerOptions.workerSrc=o.default;let s=a.getDocument({url:t}),c=await s.promise;try{let t=await c.getPage(n);if(i.aborted)return;let a=t.getViewport({scale:r});e.width=Math.ceil(a.width),e.height=Math.ceil(a.height);let o=e.getContext(`2d`);if(o===null)return;let s=t.render({canvas:e,canvasContext:o,viewport:a});i.addEventListener(`abort`,()=>{s.cancel()}),await s.promise}finally{await s.destroy()}}function XW(e,t){return{kind:`card`,path:t,stepType:`goto`,sentence:[{kind:`word`,text:`Go to`},{kind:`code`,text:e}],custom:!1,step:{type:`goto`,url:e}}}function ZW(e,t){return[{type:`goto`,url:e},...t]}function QW(e,t,n,r){return{...n,steps:ZW(e,t),keep:[`cookies`],saveTo:r}}function $W(e){let t=e.start;if(!Array.isArray(t))return;let n=t[0];if(typeof n!=`object`||!n)return;let r=n.url;return typeof r==`string`?r:void 0}function eG(e,t){let n=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`)),r=n===-1?`.`:e.slice(0,n),i=n===-1||e[n]===void 0?`/`:e[n];return`${r}${i}storage${i}${t}-session.json`}var tG={id:`by id`,"data-attr":`by test attribute`,class:`by class`,structure:`by place in the page tree`,position:`by position`};function nG(e){return tG[e]}function rG({recipeId:e,stepPath:t,heading:n,hint:r,groups:i,preview:a,collect:o,onAdd:s,onCancel:c,adding:l=!1}){return(0,F.jsxs)(I,{"data-testid":`selector-options`,borderWidth:`1px`,borderColor:`colorPalette.muted`,colorPalette:`brand`,bg:`bg.subtle`,rounded:`md`,mx:3,my:2,p:3,maxH:`45%`,overflowY:`auto`,flexShrink:0,children:[(0,F.jsxs)(W,{justify:`space-between`,align:`start`,gap:3,children:[(0,F.jsxs)(I,{minW:0,children:[(0,F.jsx)(V,{fontSize:`sm`,fontWeight:`semibold`,children:n}),a!==void 0&&a!==``&&(0,F.jsx)(V,{fontSize:`xs`,color:`fg.muted`,truncate:!0,title:a,children:`“${a}”`}),r!==void 0&&(0,F.jsx)(V,{fontSize:`xs`,color:`fg.muted`,children:r})]}),(0,F.jsxs)(W,{flexShrink:0,children:[(0,F.jsx)(UC,{size:`xs`,colorPalette:`brand`,onClick:s,loading:l,children:`Add to recipe`}),(0,F.jsx)(UC,{size:`xs`,variant:`ghost`,onClick:c,"aria-label":`Cancel this pick`,children:`Cancel`})]})]}),(0,F.jsxs)(rw,{gap:3,mt:2,children:[i.map(n=>(0,F.jsx)(aG,{recipeId:e,stepPath:t,group:n},n.title)),o!==void 0&&(0,F.jsx)(iG,{collect:o})]})]})}function iG({collect:e}){return(0,F.jsxs)(rw,{gap:1,role:`radiogroup`,"aria-label":`What to collect`,children:[(0,F.jsx)(V,{fontSize:`xs`,fontWeight:`medium`,color:`fg.muted`,children:`This matches ${String(e.matches)} elements on the page. Collect:`}),(0,F.jsxs)(I,{as:`label`,display:`flex`,alignItems:`center`,gap:2,px:2,py:1,rounded:`sm`,cursor:`pointer`,bg:e.many?void 0:`colorPalette.subtle`,children:[(0,F.jsx)(`input`,{type:`radio`,name:`collect-how-many`,checked:!e.many,onChange:()=>{e.onChange(!1)}}),(0,F.jsx)(V,{fontSize:`xs`,children:`Only the first one`})]}),(0,F.jsxs)(I,{as:`label`,display:`flex`,alignItems:`center`,gap:2,px:2,py:1,rounded:`sm`,cursor:`pointer`,bg:e.many?`colorPalette.subtle`:void 0,children:[(0,F.jsx)(`input`,{type:`radio`,name:`collect-how-many`,checked:e.many,onChange:()=>{e.onChange(!0)}}),(0,F.jsx)(V,{fontSize:`xs`,children:`All ${String(e.matches)}, as a list (an array of values)`})]})]})}function aG({recipeId:e,stepPath:t,group:n}){let r=n.options.some(e=>e.selector===n.selected);return(0,F.jsxs)(rw,{gap:1,role:`radiogroup`,"aria-label":n.title,children:[(0,F.jsx)(V,{fontSize:`xs`,fontWeight:`medium`,color:`fg.muted`,children:n.title}),n.generatedId!==void 0&&(0,F.jsx)(V,{fontSize:`xs`,color:`orange.fg`,children:`This element has the id “${n.generatedId}”, which looks generated, so it may change on the next visit and no option below uses it.`}),n.options.map((e,t)=>(0,F.jsxs)(I,{as:`label`,display:`flex`,alignItems:`center`,gap:2,px:2,py:1,rounded:`sm`,cursor:`pointer`,bg:e.selector===n.selected?`colorPalette.subtle`:void 0,_hover:{bg:`bg.emphasized`},children:[(0,F.jsx)(`input`,{type:`radio`,name:n.title,checked:e.selector===n.selected,onChange:()=>{n.onSelect(e.selector)}}),(0,F.jsx)(V,{as:`code`,fontSize:`xs`,fontFamily:`mono`,truncate:!0,flex:`1`,minW:0,title:e.selector,children:e.selector}),(0,F.jsx)(V,{fontSize:`2xs`,color:`fg.muted`,flexShrink:0,children:nG(e.tier)}),(0,F.jsx)(LC,{size:`xs`,flexShrink:0,colorPalette:e.matches===1?`green`:`gray`,children:`${String(e.matches)} match${e.matches===1?``:`es`}`}),t===0&&(0,F.jsx)(LC,{size:`xs`,colorPalette:`brand`,flexShrink:0,children:`suggested`})]},e.selector)),(0,F.jsx)(oG,{recipeId:e,stepPath:t,selected:r?``:n.selected,onUse:n.onSelect})]})}function oG({recipeId:e,stepPath:t,selected:n,onUse:r}){let[i,a]=(0,P.useState)(n),o=qte();function s(){let n=i.trim();n!==``&&(r(n),o.mutate({recipeId:e,path:t,selector:n}))}return(0,F.jsxs)(W,{gap:2,px:2,children:[(0,F.jsx)(Dw,{size:`xs`,fontFamily:`mono`,value:i,placeholder:`Or type your own selector, e.g. .price > span`,"aria-label":`Your own selector`,onChange:e=>{a(e.target.value)},onKeyDown:e=>{e.key===`Enter`&&s()}}),(0,F.jsx)(UC,{size:`xs`,variant:`outline`,onClick:s,loading:o.isPending,children:`Use`}),o.data!==void 0&&(0,F.jsx)(LC,{size:`xs`,colorPalette:o.data.snapshotMatches>0?`green`:`red`,children:`${String(o.data.snapshotMatches)} match${o.data.snapshotMatches===1?``:`es`}`})]})}function sG(e,t,n){let r=[`[data-oc-node] { cursor: ${e?`crosshair`:`inherit`}; }`,`[data-oc-node]:hover { outline: 2px solid #3182ce !important; outline-offset: -2px; }`];return n!==void 0&&n!==``&&r.push(`${n} { outline: 2px solid #dd6b20 !important; outline-offset: -2px; background: rgba(221,107,32,0.08) !important; }`),t?r.push(`[data-oc-overlay] { display: revert !important; opacity: 0.5 !important; outline: 1px dashed #ed8936 !important; }`):r.push(`[data-oc-overlay] { display: none !important; }`,`html:has([data-oc-overlay]), body:has([data-oc-overlay]) { overflow: auto !important; position: static !important; }`),t&&r.push(`[data-oc-hidden] { display: revert !important; visibility: visible !important; opacity: 0.5 !important; outline: 1px dashed #ed8936 !important; }`),r.join(`
|
|
19
19
|
`)}var cG=1e3,lG=`data-oc-node`,uG=`opencraw-picker-style`;function dG({html:e,pickMode:t,showHidden:n,hoveredSelector:r,onHoverNode:i,onPickNode:a}){let o=(0,P.useRef)(null),s=(0,P.useRef)(null),[c,l]=(0,P.useState)({width:0,height:0}),u=(0,P.useRef)({onHoverNode:i,onPickNode:a});u.current={onHoverNode:i,onPickNode:a},(0,P.useEffect)(()=>{let e=o.current;if(e===null)return;let t,n=e=>{u.current.onHoverNode(pG(e.target))},r=()=>{u.current.onHoverNode(void 0)},i=e=>{fG(e.target)!==void 0&&e.preventDefault();let t=pG(e.target);t!==void 0&&(e.preventDefault(),e.stopPropagation(),u.current.onPickNode(t))},a=e=>{e.preventDefault()},s=()=>{let o=e.contentDocument;o!==null&&(o.addEventListener(`mouseover`,n),o.addEventListener(`mouseout`,r),o.addEventListener(`click`,i,{capture:!0}),o.addEventListener(`contextmenu`,a),t=()=>{o.removeEventListener(`contextmenu`,a),o.removeEventListener(`mouseover`,n),o.removeEventListener(`mouseout`,r),o.removeEventListener(`click`,i,{capture:!0})})};return e.addEventListener(`load`,s),()=>{e.removeEventListener(`load`,s),t?.()}},[e]),(0,P.useEffect)(()=>{let e=s.current;if(e===null||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{l({width:e.clientWidth,height:e.clientHeight})});return t.observe(e),()=>{t.disconnect()}},[]),(0,P.useEffect)(()=>{let e=o.current?.contentDocument;if(e==null)return;let i=e.getElementById(uG);i===null&&(i=e.createElement(`style`),i.id=uG,e.head?.append(i)),i.textContent=sG(t,n,r)});let d=c.width>0,f=d?Math.max(c.width,cG):0,p=d?c.width/f:1,m=d&&p<1?{width:`${String(f)}px`,height:`${String(c.height/p)}px`,transform:`scale(${String(p)})`,transformOrigin:`top left`}:{width:`100%`,height:`100%`};return(0,F.jsx)(`div`,{ref:s,style:{width:`100%`,height:`100%`,overflow:`hidden`},children:(0,F.jsx)(`iframe`,{ref:o,title:`Snapshot`,sandbox:`allow-same-origin`,srcDoc:e,style:{...m,border:`none`,background:`white`}})})}function fG(e){return(e?.nodeType===Node.ELEMENT_NODE?e.closest(`a[href], area[href]`):null)??void 0}function pG(e){return(e?.nodeType===Node.ELEMENT_NODE?e.closest(`[${CSS.escape(lG)}]`):null)?.getAttribute(lG)??void 0}var mG=[],hG={object:`purple.fg`,array:`purple.fg`,element:`purple.fg`,string:`green.fg`,number:`orange.fg`,boolean:`blue.fg`,null:`fg.muted`},gG=(0,P.memo)(SG),_G=6;function vG(e){let t=new Set,n=(e,r)=>{if(e.children.length===0)return;let i=/^\[?(\d+)\]?$/.exec(e.label)?.[1];if(i!==void 0&&Number(i)>0||r>=_G){t.add(e.id);return}for(let t of e.children)n(t,r+1)};return n(e,0),t}function yG(e,t){let n=[],r=[{node:e,depth:0}];for(let e=r.pop();e!==void 0;e=r.pop())if(n.push(e),!(e.node.children.length===0||t.has(e.node.id)))for(let t=e.node.children.length-1;t>=0;--t)r.push({node:e.node.children[t],depth:e.depth+1});return n}var bG=20,xG=20;function SG({tree:e,onPick:t,steps:n=mG,hoveredStepId:r,onHoverStepId:i}){let[a,o]=(0,P.useState)(()=>vG(e.root)),s=(0,P.useRef)(null),c=yG(e.root,a),l=BO({count:c.length,getScrollElement:()=>s.current,estimateSize:()=>bG,overscan:xG});function u(e){o(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}return(0,F.jsxs)(I,{ref:s,h:`full`,overflow:`auto`,fontFamily:`mono`,fontSize:`xs`,py:2,children:[e.namespaces!==void 0&&Object.keys(e.namespaces).length>0&&(0,F.jsxs)(W,{px:2,pb:2,gap:2,flexWrap:`wrap`,children:[(0,F.jsx)(V,{color:`fg.muted`,children:`Namespaces:`}),Object.entries(e.namespaces).map(([e,t])=>(0,F.jsx)(LC,{size:`xs`,colorPalette:`gray`,children:`${e}: ${t}`},e))]}),(0,F.jsx)(I,{position:`relative`,style:{height:`${String(l.getTotalSize())}px`},children:l.getVirtualItems().map(e=>{let o=c[e.index];return(0,F.jsx)(I,{position:`absolute`,top:0,left:0,w:`full`,style:{transform:`translateY(${String(e.start)}px)`,height:`${String(bG)}px`},children:(0,F.jsx)(CG,{node:o.node,depth:o.depth,collapsed:a,onToggle:u,onPick:t,steps:n,hoveredStepId:r,onHoverStepId:i})},o.node.id)})})]})}function CG({node:e,depth:t,collapsed:n,onToggle:r,onPick:i,steps:a,hoveredStepId:o,onHoverStepId:s}){let c=e.children.length>0,l=n.has(e.id),u=e.valueType!==`object`&&e.valueType!==`array`&&e.valueType!==`element`,d=LH(e,a),f=o!==void 0&&d.includes(o);return(0,F.jsx)(F.Fragment,{children:(0,F.jsxs)(W,{"data-testid":`tree-node`,"data-highlighted":f,"data-step-ids":d.length===0?void 0:d.join(` `),gap:1,pl:`${t*14+4}px`,pr:2,minH:`20px`,cursor:`pointer`,bg:f?`orange.subtle`:void 0,_hover:{bg:f?`orange.subtle`:`bg.emphasized`},onClick:()=>{i(e,`value`)},onMouseEnter:s===void 0?void 0:()=>{s(d[0])},onMouseLeave:s===void 0?void 0:()=>{s(void 0)},children:[c?(0,F.jsx)(V,{as:`button`,w:`12px`,flexShrink:0,color:`fg.muted`,onClick:t=>{t.stopPropagation(),r(e.id)},children:l?`▸`:`▾`}):(0,F.jsx)(I,{w:`12px`,flexShrink:0}),(0,F.jsx)(V,{as:`span`,color:hG[e.valueType],fontWeight:`medium`,children:e.label}),u&&e.preview!==void 0&&(0,F.jsx)(V,{as:`span`,color:`fg.muted`,truncate:!0,children:e.preview}),d.map(e=>(0,F.jsx)(LC,{size:`xs`,colorPalette:`orange`,variant:f?`solid`:`subtle`,title:`Already in the recipe: the step reading this`,flexShrink:0,children:e},e)),e.listPath!==void 0&&(0,F.jsx)(LC,{as:`button`,size:`xs`,colorPalette:`brand`,onClick:t=>{t.stopPropagation(),i(e,`list`)},title:`Collect this for every one of the ${String(e.listCount??0)} items of the list`,children:`[*] ×${String(e.listCount??0)}`}),u&&e.jsonpath!==void 0&&(0,F.jsx)(V,{as:`button`,fontSize:`2xs`,color:`fg.muted`,_hover:{color:`fg`,textDecoration:`underline`},onClick:t=>{t.stopPropagation(),i(e,`next`)},title:`Use this value to reach the next page of results (for data that comes in pages)`,children:`next →`})]})})}function wG(e){return(e.textContent??``).replace(/\s+/g,` `).trim()}function TG(e){let t=e?.closest(`[data-oc-node]`),n=t instanceof HTMLElement?t.dataset.ocNode:void 0;return t==null||n===void 0?{reason:`that element is not part of the page snapshot`}:{nodeId:n,text:wG(t).slice(0,160)}}function EG(e,t){let n=t.replace(/\s+/g,` `).trim().toLowerCase(),r,i;for(let t of e.body.querySelectorAll(`[data-oc-node]`)){let e=wG(t),a=e.toLowerCase();a===n&&(r===void 0||e.length<r.length)?r={element:t,length:e.length}:a.includes(n)&&(i===void 0||e.length<i.length)&&(i={element:t,length:e.length})}return r?.element??i?.element??null}function DG(e,t){let n=new DOMParser().parseFromString(e,`text/html`);if(t.selector!==void 0)try{let e=n.querySelector(t.selector);return e===null?{reason:`nothing on the page matches ${t.selector}`}:TG(e)}catch{return{reason:`${t.selector} is not a valid CSS selector`}}if(t.text===void 0)return{reason:`say what to pick: a CSS selector or the text it shows`};let r=EG(n,t.text);return r===null?{reason:`no element on the page shows "${t.text}"`}:TG(r)}function OG(e,t){return{pick:e,fieldSelector:e.field.selector,...e.kind===`list`&&{itemSelector:e.item.selector},...t!==void 0&&{text:t}}}function kG(e,t,n){return t?.find(t=>t.selector===e)?.matches??n}function AG(e,t){return{...e,selector:t,matches:kG(t,e.alternatives,e.matches)}}function jG(e){let{pick:t}=e,n=AG(t.field,e.fieldSelector);if(t.kind!==`list`)return{...t,field:n};let r=e.itemSelector??t.item.selector;return{...t,field:n,item:{...t.item,selector:r,matches:kG(r,t.item.alternatives,t.item.matches)}}}function MG(e){if(e.pick.kind===`list`)return;let t=AG(e.pick.field,e.fieldSelector).matches;return t>1?t:void 0}function NG(e){return e.many===!0&&MG(e)!==void 0}function PG(e,t){return e!==void 0&&e.length>0?e:[{selector:t.selector,tier:t.tier,matches:t.matches}]}function FG(e){let{pick:t}=e,n={title:t.kind===`list`?`Value in each item`:`How to find it`,options:PG(t.field.alternatives,t.field),selected:e.fieldSelector,target:`field`,...t.field.generatedId!==void 0&&{generatedId:t.field.generatedId}};return t.kind===`list`?[{title:`Each item of the list`,options:PG(t.item.alternatives,t.item),selected:e.itemSelector??t.item.selector,target:`item`},n]:[n]}function IG(e){return e.pick.kind===`list`?`Collect this for every one of the ${String(e.pick.item.matches)} items`:e.pick.kind===`item-field`?`Collect this from each item of the list`:`Collect this value`}function LG(e){if(e.pick.kind===`field`)return`Click a similar item as well to collect the whole list. Pick the way to find it that will keep working.`;if(e.pick.kind===`list`)return`Pick the ways to find the items and the value that will keep working.`}var RG=100,zG=`img, picture, video, canvas, svg, iframe, object, embed, input, select, textarea, table`,BG=`h1, h2, h3, h4, h5, h6, li, a[href]`;function VG(e){let t=new DOMParser().parseFromString(e,`text/html`).body;for(let e of t.querySelectorAll(`script, style, noscript, template`))e.remove();return(t.textContent??``).trim().length>=RG||t.querySelector(`${zG}, ${BG}`)!==null}function HG({zoom:e,zoomIn:t,zoomOut:n,reset:r}){return(0,F.jsxs)(W,{gap:0,role:`group`,"aria-label":`Zoom`,flexShrink:0,children:[(0,F.jsx)(UC,{size:`2xs`,variant:`outline`,"aria-label":`Zoom out`,title:`Zoom out (ctrl + wheel)`,onClick:n,children:`−`}),(0,F.jsx)(UC,{size:`2xs`,variant:`outline`,"aria-label":`Reset zoom`,title:`Back to 100%`,minW:`3.5em`,onClick:r,children:`${String(Math.round(e*100))}%`}),(0,F.jsx)(UC,{size:`2xs`,variant:`outline`,"aria-label":`Zoom in`,title:`Zoom in (ctrl + wheel)`,onClick:t,children:`+`})]})}var UG=[.5,.67,.8,1,1.25,1.5,2,3];function WG(e,t){let n=UG.findIndex(t=>t>=e),r=n===-1?UG.length-1:n;return UG[Math.min(Math.max(r+t,0),UG.length-1)]??1}function GG(e){let[t,n]=(0,P.useState)(1),r=(0,P.useCallback)(()=>{n(e=>WG(e,1))},[]),i=(0,P.useCallback)(()=>{n(e=>WG(e,-1))},[]),a=(0,P.useCallback)(()=>{n(1)},[]);return(0,P.useEffect)(()=>{let t=e.current;if(t===null)return;let n=e=>{e.ctrlKey&&(e.preventDefault(),e.deltaY<0?r():i())};return t.addEventListener(`wheel`,n,{passive:!1}),()=>{t.removeEventListener(`wheel`,n)}},[e,r,i]),{zoom:t,zoomIn:r,zoomOut:i,reset:a}}function KG(e,t){let n=OD(e,t)?.step.selector;return typeof n==`string`?n:void 0}function qG(e,t,n){if(e!==void 0&&t!==void 0)for(let r of AD(e)){let e=r.step.selector,i=r.step.id;if(typeof e==`string`&&typeof i==`string`&&$O(t,e).has(n))return i}}var JG=`start`,YG=new Set([`json`,`yaml`,`jsonl`,`xml`]),XG=new Set([`csv`,`xlsx`]),ZG=new Set([`pptx`]);function QG({recipe:e,onSaveOutline:t,onSaveRecipe:n}){let r=e?.id,i=Kte(r,r===void 0?void 0:JG),a=oO(),[o,s]=(0,P.useState)(!1),[c,l]=(0,P.useState)(`tree`),u=BD(),d=i.data?.format,f=d!==void 0&&YG.has(d),p=d===`pdf`,m=d!==void 0&&XG.has(d),h=d!==void 0&&ZG.has(d),g=!f&&!p&&!m&&!h,_=i.data?.html,v=(0,P.useMemo)(()=>_===void 0||VG(_),[_]),y=Zte(r,r===void 0?void 0:JG,f),b=Qte(r,r===void 0?void 0:JG,p),[x,S]=(0,P.useState)(void 0),C=lO(r,r===void 0?void 0:JG,m,x),w=dO(r,r===void 0?void 0:JG,h),T=G(e=>e.pickTarget),E=G(e=>e.showHidden),D=G(e=>e.hoveredStepId),O=G(e=>e.startPicking),k=G(e=>e.stopPicking),A=G(e=>e.registerPick),ee=G(e=>e.setShowHidden),te=G(e=>e.setHoveredNodeId),ne=G(e=>e.setHoveredStepId),re=(0,P.useMemo)(()=>KG(e?.outline,D),[e?.outline,D]),ie=(0,P.useMemo)(()=>IH(e?.outline),[e?.outline]),ae=(0,P.useRef)(Ne);ae.current=Ne;let oe=(0,P.useCallback)((e,t)=>{ae.current(e,t)},[]),se=t=>{te(t),ne(t===void 0?void 0:qG(e?.outline,i.data?.html,t))},ce=GD(e=>e.recipeId),j=GD(e=>e.active),le=GD(e=>e.cards.length),ue=GD(e=>e.stoppedSteps),de=GD(e=>e.error),fe=GD(e=>e.dismissStopped),pe=pO(),me=mO(),he=ce===r&&j,ge=ce===r?ue:void 0,[_e,ve]=(0,P.useState)(void 0),M=e=>{ve(e===void 0?void 0:{text:e,ok:!0})},N=e=>{ve(e===void 0?void 0:{text:e,ok:!1})},ye=(0,P.useRef)(void 0),[be,xe]=(0,P.useState)(void 0),Se=(0,P.useRef)(null),Ce=GG(Se),we=(0,P.useRef)(void 0),Te=T!==void 0&&T.recipeId===r,Ee=ZD(e=>e.pick),De=ZD(e=>e.finishPick),Oe=(0,P.useRef)(void 0);(0,P.useEffect)(()=>{we.current=void 0,S(void 0),xe(void 0)},[r]);async function ke(t){if(r===void 0)return;Te||(ye.current=void 0,O(r,JG));let n=A(t);if(n.kind===`first`){let n=e?.outline===void 0?void 0:hD(e.outline.steps),i=await a.mutateAsync({recipeId:r,path:JG,nodeIds:[t],...n!==void 0&&{within:n}});if(i.kind!==`field`&&i.kind!==`item-field`){N(i.kind===`unsupported`?i.reason:void 0);return}let o=OG(i,Ae(t));return xe(o),o}let i=await a.mutateAsync({recipeId:r,path:JG,nodeIds:[n.firstNodeId,t]});if(i.kind!==`list`){N(i.kind===`unsupported`?i.reason:void 0);return}xe(e=>OG(i,e?.text))}function Ae(e){let t=i.data?.html;if(t===void 0)return;let n=new DOMParser().parseFromString(t,`text/html`).querySelector(`[data-oc-node="${CSS.escape(e)}"]`)?.textContent?.replace(/\s+/g,` `).trim();return n===void 0||n===``?void 0:n.slice(0,160)}async function je(e=be){if(r===void 0||e===void 0)return;let t=jG(e),n=NG(e);if(xe(void 0),k(),t.kind===`item-field`){await Re(e=>{let r=Ite(e,t.field,n);return r===void 0?e:(M(`Added to the list: ${t.field.selector}`),r)});return}if(t.kind===`field`){await Re(e=>(M(`Read card: ${t.field.selector} (${t.field.matches} match${t.field.matches===1?``:`es`})`),vD(e,void 0,[dD(t.field,`steps.${e.length}`,void 0,n)])));return}await Re(e=>{let n=_D(e);return M(`List: ${t.item.selector} (${t.item.matches} items) → ${t.field.selector}`),vD(e,void 0,Nte(t,`steps.${n}`))})}function Me(){xe(void 0),k()}(0,P.useEffect)(()=>{let e=Ee,t=i.data?.html;if(!g||t===void 0||e===void 0||e.recipeId!==r||Oe.current===e.requestId)return;if(Te||be!==void 0){Me();return}Oe.current=e.requestId;let n=async(t,n,r)=>{De(e.requestId);try{await u.reportUiOutcome(e.requestId,t,n,r)}catch{}};(async()=>{let r=DG(t,e);if(`reason`in r){await n(!1,`Could not pick: ${r.reason}.`);return}let i=await ke(r.nodeId);if(i===void 0){await n(!1,`Studio could not turn that element into a selector.`,{text:r.text});return}let{field:a}=jG(i),o={text:r.text,selector:a.selector,matches:a.matches,alternatives:(a.alternatives??[]).map(e=>({selector:e.selector,matches:e.matches}))};if(e.add===!0){await je(i),await n(!0,`Added to the recipe: ${a.selector}`,o);return}await n(!0,`Staged: the person can choose a selector and press Add to recipe.`,o)})()});async function Ne(e,t){if(r!==void 0)try{if(t===`next`){await Re(t=>{let n=Mte(e,`steps.${t.length}`);return M(`Paginate: next from ${e.jsonpath}`),vD(t,void 0,[n])});return}await Re(n=>{if(t===`list`){let t=Fte(n,e);if(t!==void 0)return M(`Added to the list: ${String(e.listPath)}`),t;let r=Pte(e,`steps.${_D(n)}`);if(r!==void 0)return M(`List: ${String(e.listPath)} (${String(e.listCount??0)} items)`),vD(n,void 0,r)}let r=jte(e,`steps.${n.length}`,{generalize:t===`list`,namespaces:y.data?.namespaces});return M(`Read card: ${r.step.selector}${t===`list`?` (${String(e.listCount??0)} items)`:``}`),vD(n,void 0,[r])})}catch(e){N(e instanceof Error?e.message:String(e))}}async function Pe(e){await Re(t=>{let n=we.current,r=n??_D(t);return we.current=r,M(`table: ${String(e.step.selector)}`),vD(t,n,[{...e,path:`steps.${r}`}])})}async function Fe(e){await Re(t=>(M(`${String(e.step.kind)}: ${String(e.step.id)} ← ${String(e.step.selector)}`),vD(t,void 0,[{...e,path:`steps.${t.length}`}])))}async function Ie(e){await Re(t=>(M(`jsonpath: ${String(e.step.selector)}`),vD(t,void 0,[{...e,path:`steps.${t.length}`}])))}let Le=(0,P.useRef)(void 0);async function Re(n){if(t===void 0||e?.outline===void 0)return;let r=Le.current,i=n(r!==void 0&&r.file===e.file&&r.basedOn===e.outline?r.steps:e.outline.steps);Le.current={basedOn:e.outline,file:e.file,steps:i},await t(e.file,{...e.outline,steps:i})}function ze(){if(r===void 0||e?.outline===void 0)return;let t=$W(e.outline.recipe);if(t===void 0){N(`this recipe has no start point to record from`);return}pe.mutate({recipeId:r,startUrl:t})}async function Be(){if(ge===void 0||e?.outline===void 0)return;let n=GD.getState().startUrl;if(n===void 0)return;let i=e.outline.recipe.session,a=$G(i)?i:{},o=a.bootstrap,s=$G(o)?o:void 0,c=eG(e.file,r??`recipe`),l={...a,bootstrap:QW(n,ge,s,c)};await t?.(e.file,{...e.outline,recipe:{...e.outline.recipe,session:l}}),M(`Made the login: session.bootstrap, ${ge.length} step${ge.length===1?``:`s`}`),fe()}async function Ve(){if(ge===void 0||e?.outline===void 0)return;let t=GD.getState().startUrl;if(t===void 0)return;let n=GD.getState().cards;await Re(e=>vD(e,void 0,[XW(t,`steps.${e.length}`),...n.map(e=>e.node)])),M(`Kept as steps: ${ge.length} step${ge.length===1?``:`s`}`),fe()}if(r===void 0)return(0,F.jsx)(I,{p:4,color:`fg.muted`,children:(0,F.jsx)(V,{children:`Pick a recipe to see its snapshot here.`})});function He(){if(Te){k();return}ye.current=void 0,O(r,JG)}return(0,F.jsxs)(I,{h:`full`,display:`flex`,flexDirection:`column`,children:[(0,F.jsxs)(W,{px:3,py:2,borderBottomWidth:`1px`,gap:3,flexShrink:0,minH:`38px`,children:[!f&&!p&&!m&&!h&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(V,{as:`button`,fontSize:`sm`,fontWeight:Te?`semibold`:`normal`,whiteSpace:`nowrap`,color:Te?`colorPalette.fg`:`fg`,colorPalette:`brand`,cursor:`pointer`,title:`Pick data from the page: click here, then click the text you want to collect (click two similar things to collect a whole list)`,onClick:He,children:Te?`Cancel pick`:`Read`}),(0,F.jsxs)(oT,{checked:E,onCheckedChange:e=>{ee(e.checked)},size:`sm`,title:`Also show the parts of the page that are normally out of sight (menus, pop-ups, tabs that are not open)`,children:[(0,F.jsx)(uT,{}),(0,F.jsx)(lT,{}),(0,F.jsx)(sT,{fontSize:`sm`,whiteSpace:`nowrap`,children:`Show hidden`})]}),(0,F.jsx)(V,{as:`button`,fontSize:`sm`,fontWeight:o?`semibold`:`normal`,color:o?`colorPalette.fg`:`fg`,colorPalette:`purple`,cursor:`pointer`,title:`See how the page is built, and the data it loads: for things that are hard to click`,onClick:()=>{s(e=>!e)},children:o?`Hide inspector`:`Inspect`}),(0,F.jsx)(V,{as:`button`,fontSize:`sm`,fontWeight:he?`semibold`:`normal`,color:he?`red.fg`:`fg`,colorPalette:`red`,cursor:`pointer`,title:`Open a real browser window and record what you click and type (to log in, open a menu or fill a form), as steps`,onClick:()=>{he?me.mutate():ze()},children:he?`Stop recording`:`Record`})]}),f&&(d===`json`||d===`yaml`)&&(0,F.jsx)(KV,{value:c,onChange:l}),f&&(0,F.jsx)(V,{fontSize:`sm`,color:`fg.muted`,children:`Click a value to collect it. Click [*] beside a field to collect it for every item of a list.`}),(i.isFetching||f&&y.isFetching||p&&b.isFetching||m&&C.isFetching||h&&w.isFetching)&&(0,F.jsx)(zC,{size:`xs`}),_e!==void 0&&(0,F.jsx)(LC,{size:`sm`,colorPalette:_e.ok?`green`:`orange`,children:_e.text}),(0,F.jsx)(I,{ml:`auto`,children:(0,F.jsx)(HG,{...Ce})})]}),he&&(0,F.jsxs)(W,{px:3,py:2,bg:`red.subtle`,color:`red.fg`,fontSize:`sm`,gap:3,flexShrink:0,"data-testid":`recording-banner`,children:[(0,F.jsx)(I,{w:`8px`,h:`8px`,borderRadius:`full`,bg:`red.solid`,flexShrink:0}),(0,F.jsx)(V,{children:`Recording — a browser window opened for you to drive; interact with it, not with the snapshot below.`}),(0,F.jsxs)(LC,{size:`sm`,colorPalette:`red`,children:[le,` step`,le===1?``:`s`]})]}),de!==void 0&&ce===r&&(0,F.jsx)(I,{px:3,py:1,bg:`red.subtle`,color:`red.fg`,fontSize:`sm`,flexShrink:0,children:de}),ge!==void 0&&(0,F.jsxs)(W,{px:3,py:2,borderBottomWidth:`1px`,gap:3,flexShrink:0,"data-testid":`recording-stopped-bar`,children:[(0,F.jsxs)(V,{fontSize:`sm`,children:[`Recording stopped: `,ge.length,` step`,ge.length===1?``:`s`,` recorded.`]}),(0,F.jsx)(UC,{size:`xs`,colorPalette:`brand`,onClick:()=>{Be()},disabled:ge.length===0,children:`Make this the login`}),(0,F.jsx)(UC,{size:`xs`,variant:`outline`,onClick:()=>{Ve()},disabled:ge.length===0,children:`Keep as steps`}),(0,F.jsx)(UC,{size:`xs`,variant:`ghost`,onClick:fe,children:`Discard`})]}),i.data?.notice!==void 0&&(0,F.jsx)(GV,{text:i.data.notice}),be!==void 0&&r!==void 0&&!f&&!p&&!m&&!h&&(0,F.jsx)(rG,{recipeId:r,stepPath:JG,heading:IG(be),hint:LG(be),preview:be.text,groups:FG(be).map(e=>({title:e.title,options:e.options,selected:e.selected,onSelect:t=>{xe(n=>n===void 0?n:e.target===`item`?{...n,itemSelector:t}:{...n,fieldSelector:t})},...e.generatedId!==void 0&&{generatedId:e.generatedId}})),collect:MG(be)===void 0?void 0:{matches:MG(be),many:NG(be),onChange:e=>{xe(t=>t===void 0?t:{...t,many:e})}},onAdd:()=>{je()},onCancel:Me}),g&&i.data!==void 0&&i.data.notice===void 0&&!v&&(0,F.jsx)(WV,{}),(0,F.jsxs)(I,{ref:Se,flex:`1`,minH:`0`,overflow:`auto`,style:p?void 0:{zoom:Ce.zoom},onContextMenu:e=>{e.preventDefault()},children:[f&&c===`text`&&i.data!==void 0&&(0,F.jsx)(dG,{html:i.data.html,pickMode:!1,showHidden:!1,onHoverNode:()=>{},onPickNode:()=>{}}),f&&c===`tree`&&y.data!==void 0&&(0,F.jsx)(gG,{tree:y.data,onPick:oe,steps:ie,hoveredStepId:D,onHoverStepId:ne}),f&&y.isError&&(0,F.jsx)(I,{p:4,color:`fg.error`,children:(0,F.jsx)(V,{children:y.error.message})}),p&&b.data!==void 0&&(0,F.jsx)(NW,{recipeId:r,stepPath:JG,view:b.data,zoom:Ce.zoom,bytesUrl:u.pdfBytesUrl(r,JG,i.data?.baseUrl),onTablePick:e=>{Pe(e)},onRegionPick:e=>{Fe(e)},steps:ie,hoveredStepId:D,onHoverStepId:ne},u.pdfBytesUrl(r,JG,i.data?.baseUrl)),p&&b.isError&&(0,F.jsx)(I,{p:4,color:`fg.error`,children:(0,F.jsx)(V,{children:b.error.message})}),m&&C.data!==void 0&&(0,F.jsx)(AU,{recipeId:r,stepPath:JG,view:C.data,onTablePick:e=>{Pe(e)},onCellPick:e=>{Fe(e)},steps:ie,hoveredStepId:D,onHoverStepId:ne,csvOverride:x,onCsvOverrideChange:S}),m&&C.isError&&(0,F.jsx)(I,{p:4,color:`fg.error`,children:(0,F.jsx)(V,{children:C.error.message})}),h&&w.data!==void 0&&(0,F.jsx)($H,{recipeId:r,stepPath:JG,view:w.data,onTablePick:e=>{Pe(e)},onChartPick:e=>{Ie(e)},onRegionPick:e=>{Fe(e)},steps:ie,hoveredStepId:D,onHoverStepId:ne}),h&&w.isError&&(0,F.jsx)(I,{p:4,color:`fg.error`,children:(0,F.jsx)(V,{children:w.error.message})}),!f&&!p&&!m&&!h&&i.data!==void 0&&!o&&(0,F.jsx)(dG,{html:i.data.html,pickMode:Te,showHidden:E,hoveredSelector:re,onHoverNode:se,onPickNode:e=>{ke(e)}}),!f&&!p&&!m&&!h&&i.data!==void 0&&o&&(0,F.jsxs)(Qw,{panels:[{id:`snapshot`,minSize:15},{id:`inspect`,minSize:20}],h:`full`,children:[(0,F.jsx)($w,{id:`snapshot`,overflow:`hidden`,children:(0,F.jsx)(dG,{html:i.data.html,pickMode:Te,showHidden:E,hoveredSelector:re,onHoverNode:se,onPickNode:e=>{ke(e)}})}),(0,F.jsx)(nT,{id:`snapshot:inspect`}),(0,F.jsx)($w,{id:`inspect`,overflow:`hidden`,children:(0,F.jsx)(uk,{recipeId:r,recipe:e,snapshot:i.data,onSaveOutline:t,onSaveRecipe:n})})]}),i.isError&&(0,F.jsxs)(I,{p:4,color:`fg.error`,role:`alert`,children:[(0,F.jsx)(V,{fontWeight:`semibold`,children:`Could not take a snapshot of this recipe's page.`}),(0,F.jsx)(V,{children:FD(i.error.message)})]}),!i.isFetching&&!i.isError&&i.data===void 0&&(0,F.jsx)(I,{p:4,color:`fg.muted`,children:(0,F.jsx)(V,{children:`Run a sample, or open a recipe, to see its snapshot here.`})})]})]})}function $G(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var eK=1024,tK=0,nK=class{constructor(e,t){this.from=e,this.to=t}},rK=class{constructor(e={}){this.id=tK++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw Error(`This node type doesn't define a deserialize function`)}),this.combine=e.combine||null}add(e){if(this.perNode)throw RangeError(`Can't add per-node props to node types`);return typeof e!=`function`&&(e=oK.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}};rK.closedBy=new rK({deserialize:e=>e.split(` `)}),rK.openedBy=new rK({deserialize:e=>e.split(` `)}),rK.group=new rK({deserialize:e=>e.split(` `)}),rK.isolate=new rK({deserialize:e=>{if(e&&e!=`rtl`&&e!=`ltr`&&e!=`auto`)throw RangeError(`Invalid value for isolate: `+e);return e||`auto`}}),rK.contextHash=new rK({perNode:!0}),rK.lookAhead=new rK({perNode:!0}),rK.mounted=new rK({perNode:!0});var iK=class{constructor(e,t,n,r=!1){this.tree=e,this.overlay=t,this.parser=n,this.bracketed=r}static get(e){return e&&e.props&&e.props[rK.mounted.id]}},aK=Object.create(null),oK=class e{constructor(e,t,n,r=0){this.name=e,this.props=t,this.id=n,this.flags=r}static define(t){let n=t.props&&t.props.length?Object.create(null):aK,r=+!!t.top|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),i=new e(t.name||``,n,t.id,r);if(t.props){for(let e of t.props)if(Array.isArray(e)||(e=e(i)),e){if(e[0].perNode)throw RangeError(`Can't store a per-node prop on a node type`);n[e[0].id]=e[1]}}return i}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e==`string`){if(this.name==e)return!0;let t=this.prop(rK.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let r of n.split(` `))t[r]=e[n];return e=>{for(let n=e.prop(rK.group),r=-1;r<(n?n.length:0);r++){let i=t[r<0?e.name:n[r]];if(i)return i}}}};oK.none=new oK(``,Object.create(null),0,8);var sK=class e{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw RangeError(`Node type ids should correspond to array positions when creating a node set`)}extend(...t){let n=[];for(let e of this.types){let r=null;for(let n of t){let t=n(e);if(t){r||=Object.assign({},e.props);let n=t[1],i=t[0];i.combine&&i.id in r&&(n=i.combine(r[i.id],n)),r[i.id]=n}}n.push(r?new oK(e.name,r,e.id,e.flags):e)}return new e(n)}},cK=new WeakMap,lK=new WeakMap,uK;(function(e){e[e.ExcludeBuffers=1]=`ExcludeBuffers`,e[e.IncludeAnonymous=2]=`IncludeAnonymous`,e[e.IgnoreMounts=4]=`IgnoreMounts`,e[e.IgnoreOverlays=8]=`IgnoreOverlays`,e[e.EnterBracketed=16]=`EnterBracketed`})(uK||={});var dK=class e{constructor(e,t,n,r,i){if(this.type=e,this.children=t,this.positions=n,this.length=r,this.props=null,i&&i.length){this.props=Object.create(null);for(let[e,t]of i)this.props[typeof e==`number`?e:e.id]=t}}toString(){let e=iK.get(this);if(e&&!e.overlay)return e.tree.toString();let t=``;for(let e of this.children){let n=e.toString();n&&(t&&(t+=`,`),t+=n)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?`(`+t+`)`:``):t}cursor(e=0){return new TK(this.topNode,e)}cursorAt(e,t=0,n=0){let r=new TK(cK.get(this)||this.topNode);return r.moveTo(e,t),cK.set(this,r._tree),r}get topNode(){return new _K(this,0,0,null)}resolve(e,t=0){let n=hK(cK.get(this)||this.topNode,e,t,!1);return cK.set(this,n),n}resolveInner(e,t=0){let n=hK(lK.get(this)||this.topNode,e,t,!0);return lK.set(this,n),n}resolveStack(e,t=0){return wK(this,e,t)}iterate(e){let{enter:t,leave:n,from:r=0,to:i=this.length}=e,a=e.mode||0,o=(a&uK.IncludeAnonymous)>0;for(let e=this.cursor(a|uK.IncludeAnonymous);;){let a=!1;if(e.from<=i&&e.to>=r&&(!o&&e.type.isAnonymous||t(e)!==!1)){if(e.firstChild())continue;a=!0}for(;a&&n&&(o||!e.type.isAnonymous)&&n(e),!e.nextSibling();){if(!e.parent())return;a=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(t={}){return this.children.length<=8?this:AK(oK.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,r)=>new e(this.type,t,n,r,this.propValues),t.makeTree||((t,n,r)=>new e(oK.none,t,n,r)))}static build(e){return DK(e)}};dK.empty=new dK(oK.none,[],[],0);var fK=class e{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new e(this.buffer,this.index)}},pK=class e{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return oK.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(`,`)}childString(e){let t=this.buffer[e],n=this.buffer[e+3],r=this.set.types[t],i=r.name;if(/\W/.test(i)&&!r.isError&&(i=JSON.stringify(i)),e+=4,n==e)return i;let a=[];for(;e<n;)a.push(this.childString(e)),e=this.buffer[e+3];return i+`(`+a.join(`,`)+`)`}findChild(e,t,n,r,i){let{buffer:a}=this,o=-1;for(let s=e;s!=t&&!(mK(i,r,a[s+1],a[s+2])&&(o=s,n>0));s=a[s+3]);return o}slice(t,n,r){let i=this.buffer,a=new Uint16Array(n-t),o=0;for(let e=t,s=0;e<n;){a[s++]=i[e++],a[s++]=i[e++]-r;let n=a[s++]=i[e++]-r;a[s++]=i[e++]-t,o=Math.max(o,n)}return new e(a,o,this.set)}};function mK(e,t,n,r){switch(e){case-2:return n<t;case-1:return r>=t&&n<t;case 0:return n<t&&r>t;case 1:return n<=t&&r>t;case 2:return r>t;case 4:return!0}}function hK(e,t,n,r){for(;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let t=!r&&e instanceof _K&&e.index<0?null:e.parent;if(!t)return e;e=t}let i=r?0:uK.IgnoreOverlays;if(r)for(let r=e,a=r.parent;a;r=a,a=r.parent)r instanceof _K&&r.index<0&&a.enter(t,n,i)?.from!=r.from&&(e=a);for(;;){let r=e.enter(t,n,i);if(!r)return e;e=r}}var gK=class{cursor(e=0){return new TK(this,e)}getChild(e,t=null,n=null){let r=vK(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return vK(this,e,t,n)}resolve(e,t=0){return hK(this,e,t,!1)}resolveInner(e,t=0){return hK(this,e,t,!0)}matchContext(e){return yK(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let e=t.lastChild;if(!e||e.to!=t.to)break;e.type.isError&&e.from==e.to?(n=t,t=e.prevSibling):t=e}return n}get node(){return this}get next(){return this.parent}},_K=class e extends gK{constructor(e,t,n,r){super(),this._tree=e,this.from=t,this.index=n,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,n,r,i,a=0){for(let o=this;;){for(let{children:s,positions:c}=o._tree,l=n>0?s.length:-1;t!=l;t+=n){let l=s[t],u=c[t]+o.from,d;if(a&uK.EnterBracketed&&l instanceof dK&&(d=iK.get(l))&&!d.overlay&&d.bracketed&&r>=u&&r<=u+l.length||mK(i,r,u,u+l.length)){if(l instanceof pK){if(a&uK.ExcludeBuffers)continue;let e=l.findChild(0,l.buffer.length,n,r-u,i);if(e>-1)return new xK(new bK(o,l,t,u),null,e)}else if(a&uK.IncludeAnonymous||!l.type.isAnonymous||EK(l)){let s;if(!(a&uK.IgnoreMounts)&&(s=iK.get(l))&&!s.overlay)return new e(s.tree,u,t,o);let c=new e(l,u,t,o);return a&uK.IncludeAnonymous||!c.type.isAnonymous?c:c.nextChild(n<0?l.children.length-1:0,n,r,i,a)}}}if(a&uK.IncludeAnonymous||!o.type.isAnonymous||(t=o.index>=0?o.index+n:n<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(t,n,r=0){let i;if(!(r&uK.IgnoreOverlays)&&(i=iK.get(this._tree))&&i.overlay){let a=t-this.from,o=r&uK.EnterBracketed&&i.bracketed;for(let{from:t,to:r}of i.overlay)if((n>0||o?t<=a:t<a)&&(n<0||o?r>=a:r>a))return new e(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,n,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}};function vK(e,t,n,r){let i=e.cursor(),a=[];if(!i.firstChild())return a;if(n!=null){for(let e=!1;!e;)if(e=i.type.is(n),!i.nextSibling())return a}for(;;){if(r!=null&&i.type.is(r))return a;if(i.type.is(t)&&a.push(i.node),!i.nextSibling())return r==null?a:[]}}function yK(e,t,n=t.length-1){for(let r=e;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}var bK=class{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}},xK=class e extends gK{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(t,n,r){let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],t,n-this.context.start,r);return a<0?null:new e(this.context,this,a)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(t,n,r=0){if(r&uK.ExcludeBuffers)return null;let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,t-this.context.start,n);return a<0?null:new e(this.context,this,a)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:t}=this.context,n=t.buffer[this.index+3];return n<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new e(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new e(this.context,this._parent,t.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,r=this.index+4,i=n.buffer[this.index+3];if(i>r){let a=n.buffer[this.index+1];e.push(n.slice(r,i,a)),t.push(0)}return new dK(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function SK(e){if(!e.length)return null;let t=0,n=e[0];for(let r=1;r<e.length;r++){let i=e[r];(i.from>n.from||i.to<n.to)&&(n=i,t=r)}let r=n instanceof _K&&n.index<0?null:n.parent,i=e.slice();return r?i[t]=r:i.splice(t,1),new CK(i,n)}var CK=class{constructor(e,t){this.heads=e,this.node=t}get next(){return SK(this.heads)}};function wK(e,t,n){let r=e.resolveInner(t,n),i=null;for(let e=r instanceof _K?r:r.context.parent;e;e=e.parent)if(e.index<0){let a=e.parent;(i||=[r]).push(a.resolve(t,n)),e=a}else{let a=iK.get(e.tree);if(a&&a.overlay&&a.overlay[0].from<=t&&a.overlay[a.overlay.length-1].to>=t){let o=new _K(a.tree,a.overlay[0].from+e.from,-1,e);(i||=[r]).push(hK(o,t,n,!1))}}return i?SK(i):r}var TK=class{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~uK.EnterBracketed,e instanceof _K)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:n,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=n+r.buffer[e+1],this.to=n+r.buffer[e+2],!0}yield(e){return e?e instanceof _K?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:r}=this.buffer,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return i<0?!1:(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?n&uK.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&uK.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&uK.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let e=n<0?0:this.stack[n]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(e)}return n<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(r.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:n}=r)}else({index:t,_parent:n}=this._tree);for(;n;{index:t,_parent:n}=n)if(t>-1)for(let r=t+e,i=e<0?-1:n._tree.children.length;r!=i;r+=e){let e=n._tree.children[r];if(this.mode&uK.IncludeAnonymous||e instanceof pK||!e.type.isAnonymous||EK(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)scan:for(let r=this.index,i=this.stack.length;i>=0;){for(let a=e;a;a=a._parent)if(a.index==r){if(r==this.index)return a;t=a,n=i+1;break scan}r=this.stack[--i]}for(let e=n;e<this.stack.length;e++)t=new xK(this.buffer,t,this.stack[e]);return this.bufferNode=new xK(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){n++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&t&&t(this),r=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,r=!0}}}matchContext(e){if(!this.buffer)return yK(this.node.parent,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let r=e.length-1,i=this.stack.length-1;r>=0;i--){if(i<0)return yK(this._tree,e,r);let a=n[t.buffer[this.stack[i]]];if(!a.isAnonymous){if(e[r]&&e[r]!=a.name)return!1;r--}}return!0}};function EK(e){return e.children.some(e=>e instanceof pK||!e.type.isAnonymous||EK(e))}function DK(e){let{buffer:t,nodeSet:n,maxBufferLength:r=eK,reused:i=[],minRepeatType:a=n.types.length}=e,o=Array.isArray(t)?new fK(t,t.length):t,s=n.types,c=0,l=0;function u(e,t,_,v,y,b){let{id:x,start:S,end:C,size:w}=o,T=l,E=c;if(w<0){if(o.next(),w==-1){let t=i[x];_.push(t),v.push(S-e);return}if(w==-3){c=x;return}if(w==-4){l=x;return}throw RangeError(`Unrecognized record size: ${w}`)}let D=s[x],O,k,A=S-e;if(C-S<=r&&(k=h(o.pos-t,y))){let t=new Uint16Array(k.size-k.skip),r=o.pos-k.size,i=t.length;for(;o.pos>r;)i=g(k.start,t,i);O=new pK(t,C-k.start,n),A=k.start-e}else{let e=o.pos-w;o.next();let t=[],n=[],i=x>=a?x:-1,s=0,c=C;for(;o.pos>e;)i>=0&&o.id==i&&o.size>=0?(o.end<=c-r&&(p(t,n,S,s,o.end,c,i,T,E),s=t.length,c=o.end),o.next()):b>2500?d(S,e,t,n):u(S,e,t,n,i,b+1);if(i>=0&&s>0&&s<t.length&&p(t,n,S,s,S,c,i,T,E),t.reverse(),n.reverse(),i>-1&&s>0){let e=f(D,E);O=AK(D,t,n,0,t.length,0,C-S,e,e)}else O=m(D,t,n,C-S,T-C,E)}_.push(O),v.push(A)}function d(e,t,i,a){let s=[],c=0,l=-1;for(;o.pos>t;){let{id:e,start:t,end:n,size:i}=o;if(i>4)o.next();else if(l>-1&&t<l)break;else l<0&&(l=n-r),s.push(e,t,n),c++,o.next()}if(c){let t=new Uint16Array(c*4),r=s[s.length-2];for(let e=s.length-3,n=0;e>=0;e-=3)t[n++]=s[e],t[n++]=s[e+1]-r,t[n++]=s[e+2]-r,t[n++]=n;i.push(new pK(t,s[2]-r,n)),a.push(r-e)}}function f(e,t){return(n,r,i)=>{let a=0,o=n.length-1,s,c;if(o>=0&&(s=n[o])instanceof dK){if(!o&&s.type==e&&s.length==i)return s;(c=s.prop(rK.lookAhead))&&(a=r[o]+s.length+c)}return m(e,n,r,i,a,t)}}function p(e,t,r,i,a,o,s,c,l){let u=[],d=[];for(;e.length>i;)u.push(e.pop()),d.push(t.pop()+r-a);e.push(m(n.types[s],u,d,o-a,c-o,l)),t.push(a-r)}function m(e,t,n,r,i,a,o){if(a){let e=[rK.contextHash,a];o=o?[e].concat(o):[e]}if(i>25){let e=[rK.lookAhead,i];o=o?[e].concat(o):[e]}return new dK(e,t,n,r,o)}function h(e,t){let n=o.fork(),i=0,s=0,c=0,l=n.end-r,u={size:0,start:0,skip:0};scan:for(let r=n.pos-e;n.pos>r;){let e=n.size;if(n.id==t&&e>=0){u.size=i,u.start=s,u.skip=c,c+=4,i+=4,n.next();continue}let o=n.pos-e;if(e<0||o<r||n.start<l)break;let d=n.id>=a?4:0,f=n.start;for(n.next();n.pos>o;){if(n.size<0){if(n.size==-3||n.size==-4)d+=4;else break scan}else n.id>=a&&(d+=4);n.next()}s=f,i+=e,c+=d}return(t<0||i==e)&&(u.size=i,u.start=s,u.skip=c),u.size>4?u:void 0}function g(e,t,n){let{id:r,start:i,end:s,size:u}=o;if(o.next(),u>=0&&r<a){let a=n;if(u>4){let r=o.pos-(u-4);for(;o.pos>r;)n=g(e,t,n)}t[--n]=a,t[--n]=s-e,t[--n]=i-e,t[--n]=r}else u==-3?c=r:u==-4&&(l=r);return n}let _=[],v=[];for(;o.pos>0;)u(e.start||0,e.bufferStart||0,_,v,-1,0);let y=e.length??(_.length?v[0]+_[0].length:0);return new dK(s[e.topID],_.reverse(),v.reverse(),y)}var OK=new WeakMap;function kK(e,t){if(!e.isAnonymous||t instanceof pK||t.type!=e)return 1;let n=OK.get(t);if(n==null){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof dK)){n=1;break}n+=kK(e,r)}OK.set(t,n)}return n}function AK(e,t,n,r,i,a,o,s,c){let l=0;for(let n=r;n<i;n++)l+=kK(e,t[n]);let u=Math.ceil(l*1.5/8),d=[],f=[];function p(t,n,r,i,o){for(let s=r;s<i;){let r=s,l=n[s],m=kK(e,t[s]);for(s++;s<i;s++){let n=kK(e,t[s]);if(m+n>=u)break;m+=n}if(s==r+1){if(m>u){let e=t[r];p(e.children,e.positions,0,e.children.length,n[r]+o);continue}d.push(t[r])}else{let i=n[s-1]+t[s-1].length-l;d.push(AK(e,t,n,r,s,l,i,null,c))}f.push(l+o-a)}}return p(t,n,r,i,0),(s||c)(d,f,o)}var jK=class e{constructor(e,t,n,r,i=!1,a=!1){this.from=e,this.to=t,this.tree=n,this.offset=r,this.open=!!i|(a?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,n=[],r=!1){let i=[new e(0,t.length,t,0,!1,r)];for(let e of n)e.to>t.length&&i.push(e);return i}static applyChanges(t,n,r=128){if(!n.length)return t;let i=[],a=1,o=t.length?t[0]:null;for(let s=0,c=0,l=0;;s++){let u=s<n.length?n[s]:null,d=u?u.fromA:1e9;if(d-c>=r)for(;o&&o.from<d;){let n=o;if(c>=n.from||d<=n.to||l){let t=Math.max(n.from,c)-l,r=Math.min(n.to,d)-l;n=t>=r?null:new e(t,r,n.tree,n.offset+l,s>0,!!u)}if(n&&i.push(n),o.to>d)break;o=a<t.length?t[a++]:null}if(!u)break;c=u.toA,l=u.toA-u.toB}return i}},MK=class{startParse(e,t,n){return typeof e==`string`&&(e=new NK(e)),n=n?n.length?n.map(e=>new nK(e.from,e.to)):[new nK(0,0)]:[new nK(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let e=r.advance();if(e)return e}}},NK=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}};new rK({perNode:!0});var PK=class e{constructor(e,t,n,r,i,a,o,s,c,l=0,u){this.p=e,this.stack=t,this.state=n,this.reducePos=r,this.pos=i,this.score=a,this.buffer=o,this.bufferBase=s,this.curContext=c,this.lookAhead=l,this.parent=u}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?`!`+this.score:``}`}static start(t,n,r=0){let i=t.parser.context;return new e(t,[],n,r,r,0,[],0,i?new FK(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){let t=e>>19,n=e&65535,{parser:r}=this.p,i=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),a=r.dynamicPrecedence(n);if(a&&(this.score+=a),t==0){n<r.minRepeatTerm&&this.reducePos<this.pos&&(this.reducePos=this.pos),this.pushState(r.getGoto(this.state,n,!0),this.reducePos),n<r.minRepeatTerm&&this.storeNode(n,this.reducePos,this.reducePos,i?8:4,!0),this.reduceContext(n,this.reducePos);return}let o=this.stack.length-(t-1)*3-(e&262144?6:0),s=o?this.stack[o-2]:this.p.ranges[0].from;n<r.minRepeatTerm&&s==this.reducePos&&this.reducePos<this.pos&&(this.reducePos=this.pos);let c=this.reducePos-s;c>=2e3&&!this.p.parser.nodeSet.types[n]?.isAnonymous&&(s==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSize<c&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=s,this.p.lastBigReductionSize=c));let l=o?this.stack[o-1]:0,u=this.bufferBase+this.buffer.length-l;if(n<r.minRepeatTerm||e&131072){let e=r.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(n,s,e,u+4,!0)}if(e&262144)this.state=this.stack[o];else{let e=this.stack[o-3];this.state=r.getGoto(e,n,!0)}for(;this.stack.length>o;)this.stack.pop();this.reduceContext(n,s)}storeNode(e,t,n,r=4,i=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let e=this.buffer.length;if(e>0&&this.buffer[e-4]==0&&this.buffer[e-1]>-1){if(t==n)return;if(this.buffer[e-2]>=t){this.buffer[e-2]=n;return}}}if(!i||this.pos==n)this.buffer.push(e,t,n,r);else{let i=this.buffer.length;if(i>0&&(this.buffer[i-4]!=0||this.buffer[i-1]<0)){let e=!1;for(let t=i;t>0&&this.buffer[t-2]>n;t-=4)if(this.buffer[t-1]>=0){e=!0;break}if(e)for(;i>0&&this.buffer[i-2]>n;)this.buffer[i]=this.buffer[i-4],this.buffer[i+1]=this.buffer[i-3],this.buffer[i+2]=this.buffer[i-2],this.buffer[i+3]=this.buffer[i-1],i-=4,r>4&&(r-=4)}this.buffer[i]=e,this.buffer[i+1]=t,this.buffer[i+2]=n,this.buffer[i+3]=r}}shift(e,t,n,r){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=r,this.shiftContext(t,n),t<=this.p.parser.maxNode&&this.buffer.push(t,n,r,4);else{let i=e,{parser:a}=this.p;this.pos=r;let o=a.stateFlag(i,1);!o&&(r>n||t<=a.maxNode)&&(this.reducePos=r),this.pushState(i,o?n:Math.min(n,this.reducePos)),this.shiftContext(t,n),t<=a.maxNode&&this.buffer.push(t,n,r,4)}}apply(e,t,n,r){e&65536?this.reduce(e):this.shift(e,t,n,r)}useNode(e,t){let n=this.p.reused.length-1;(n<0||this.p.reused[n]!=e)&&(this.p.reused.push(e),n++);let r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(t,r),this.buffer.push(n,r,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let t=this,n=t.buffer.length;for(n&&t.buffer[n-4]==0&&(n-=4);n>0&&t.buffer[n-2]>t.reducePos;)n-=4;let r=t.buffer.slice(n),i=t.bufferBase+n;for(;t&&i==t.bufferBase;)t=t.parent;return new e(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,r,i,this.curContext,this.lookAhead,t)}recoverByDelete(e,t){let n=e<=this.p.parser.maxNode;n&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,n?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new IK(this);;){let n=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(n==0)return!1;if(!(n&65536))return!0;t.reduce(n)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let n=[];for(let r=0,i;r<t.length;r+=2)(i=t[r+1])!=this.state&&this.p.parser.hasAction(i,e)&&n.push(t[r],i);if(this.stack.length<120)for(let e=0;n.length<8&&e<t.length;e+=2){let r=t[e+1];n.some((e,t)=>t&1&&e==r)||n.push(t[e],r)}t=n}let n=[];for(let e=0;e<t.length&&n.length<4;e+=2){let r=t[e+1];if(r==this.state)continue;let i=this.split();i.pushState(r,this.pos),i.storeNode(0,i.pos,i.pos,4,!0),i.shiftContext(t[e],this.pos),i.reducePos=this.pos,i.score-=200,n.push(i)}return n}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if(!(t&65536))return!1;if(!e.validAction(this.state,t)){let n=t>>19,r=t&65535,i=this.stack.length-n*3;if(i<0||e.getGoto(this.stack[i],r,!1)<0){let e=this.findForcedReduction();if(e==null)return!1;t=e}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],n=(r,i)=>{if(!t.includes(r))return t.push(r),e.allActions(r,t=>{if(!(t&393216)){if(t&65536){let n=(t>>19)-i;if(n>1){let r=t&65535,i=this.stack.length-n*3;if(i>=0&&e.getGoto(this.stack[i],r,!1)>=0)return n<<19|65536|r}}else{let e=n(t,i+1);if(e!=null)return e}}})};return n(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new FK(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){return e<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=e,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}},FK=class{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}},IK=class{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,n=e>>19;n==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(n-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=r}},LK=class e{constructor(e,t,n){this.stack=e,this.pos=t,this.index=n,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(t,n=t.bufferBase+t.buffer.length){return new e(t,n,n-t.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new e(this.stack,this.pos,this.index)}};function RK(e,t=Uint16Array){if(typeof e!=`string`)return e;let n=null;for(let r=0,i=0;r<e.length;){let a=0;for(;;){let t=e.charCodeAt(r++),n=!1;if(t==126){a=65535;break}t>=92&&t--,t>=34&&t--;let i=t-32;if(i>=46&&(i-=46,n=!0),a+=i,n)break;a*=46}n?n[i++]=a:n=new t(a)}return n}var zK=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},BK=new zK,VK=class{constructor(e,t){this.input=e,this.ranges=t,this.chunk=``,this.chunkOff=0,this.chunk2=``,this.chunk2Pos=0,this.next=-1,this.token=BK,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let n=this.range,r=this.rangeIndex,i=this.pos+e;for(;i<n.from;){if(!r)return null;let e=this.ranges[--r];i-=n.from-e.to,n=e}for(;t<0?i>n.to:i>=n.to;){if(r==this.ranges.length-1)return null;let e=this.ranges[++r];i+=e.from-n.to,n=e}return i}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,n,r;if(t>=0&&t<this.chunk.length)n=this.pos+e,r=this.chunk.charCodeAt(t);else{let t=this.resolveOffset(e,1);if(t==null)return-1;if(n=t,n>=this.chunk2Pos&&n<this.chunk2Pos+this.chunk2.length)r=this.chunk2.charCodeAt(n-this.chunk2Pos);else{let e=this.rangeIndex,t=this.range;for(;t.to<=n;)t=this.ranges[++e];this.chunk2=this.input.chunk(this.chunk2Pos=n),n+this.chunk2.length>t.to&&(this.chunk2=this.chunk2.slice(0,t.to-n)),r=this.chunk2.charCodeAt(0)}}return n>=this.token.lookAhead&&(this.token.lookAhead=n+1),r}acceptToken(e,t=0){let n=t?this.resolveOffset(t,-1):this.pos;if(n==null||n<this.token.start)throw RangeError(`Token end out of bounds`);this.token.value=e,this.token.end=n}acceptTokenTo(e,t){this.token.value=e,this.token.end=t}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.next=this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?-1:this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk=``,this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=BK,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk=``,this.chunkOff=0),this.readNext()}return this}read(e,t){if(e>=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let n=``;for(let r of this.ranges){if(r.from>=t)break;r.to>e&&(n+=this.input.read(Math.max(r.from,e),Math.min(r.to,t)))}return n}},HK=class{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;WK(this.data,e,t,this.id,n.data,n.tokenPrecTable)}};HK.prototype.contextual=HK.prototype.fallback=HK.prototype.extend=!1;var UK=class{constructor(e,t,n){this.precTable=t,this.elseToken=n,this.data=typeof e==`string`?RK(e):e}token(e,t){let n=e.pos,r=0;for(;;){let n=e.next<0,i=e.resolveOffset(1,1);if(WK(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(n||r++,i==null)break;e.reset(i,e.token)}r&&(e.reset(n,e.token),e.acceptToken(this.elseToken,r))}};UK.prototype.contextual=HK.prototype.fallback=HK.prototype.extend=!1;function WK(e,t,n,r,i,a){let o=0,s=1<<r,{dialect:c}=n.p.parser;scan:for(;(s&e[o])!=0;){let n=e[o+1];for(let r=o+3;r<n;r+=2)if((e[r+1]&s)>0){let n=e[r];if(c.allows(n)&&(t.token.value==-1||t.token.value==n||KK(n,t.token.value,i,a))){t.acceptToken(n);break}}let r=t.next,l=0,u=e[o+2];if(t.next<0&&u>l&&e[n+u*3-3]==65535){o=e[n+u*3-1];continue scan}for(;l<u;){let i=l+u>>1,a=n+i+(i<<1),s=e[a],c=e[a+1]||65536;if(r<s)u=i;else if(r>=c)l=i+1;else{o=e[a+2],t.advance();continue scan}}break}}function GK(e,t,n){for(let r=t,i;(i=e[r])!=65535;r++)if(i==n)return r-t;return-1}function KK(e,t,n,r){let i=GK(n,r,t);return i<0||GK(n,r,e)<i}var qK=typeof process<`u`&&/\bparse\b/.test({}.LOG),JK=null;function YK(e,t,n){let r=e.cursor(uK.IncludeAnonymous);for(r.moveTo(t);;)if(!(n<0?r.childBefore(t):r.childAfter(t)))for(;;){if((n<0?r.to<t:r.from>t)&&!r.type.isError)return n<0?Math.max(0,Math.min(r.to-1,t-25)):Math.min(e.length,Math.max(r.from+1,t+25));if(n<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return n<0?0:e.length}}var XK=class{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?YK(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?YK(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let t=this.trees.length-1;if(t<0)return this.nextFragment(),null;let n=this.trees[t],r=this.index[t];if(r==n.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let i=n.children[r],a=this.start[t]+n.positions[r];if(a>e)return this.nextStart=a,null;if(i instanceof dK){if(a==e){if(a<this.safeFrom)return null;let e=a+i.length;if(e<=this.safeTo){let t=i.prop(rK.lookAhead);if(!t||e+t<this.fragment.to)return i}}this.index[t]++,a+i.length>=Math.max(this.safeFrom,e)&&(this.trees.push(i),this.start.push(a),this.index.push(0))}else this.index[t]++,this.nextStart=a+i.length}}},ZK=class{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(e=>new zK)}getActions(e){let t=0,n=null,{parser:r}=e.p,{tokenizers:i}=r,a=r.stateSlot(e.state,3),o=e.curContext?e.curContext.hash:0,s=0;for(let r=0;r<i.length;r++){if(!(1<<r&a))continue;let c=i[r],l=this.tokens[r];if((!n||c.fallback)&&((c.contextual||l.start!=e.pos||l.mask!=a||l.context!=o)&&(this.updateCachedToken(l,c,e),l.mask=a,l.context=o),l.lookAhead>l.end+25&&(s=Math.max(l.lookAhead,s)),l.value!=0)){let r=t;if(l.extended>-1&&(t=this.addActions(e,l.extended,l.end,t)),t=this.addActions(e,l.value,l.end,t),!c.extend&&(n=l,t>r))break}}for(;this.actions.length>t;)this.actions.pop();return s&&e.setLookAhead(s),!n&&e.pos==this.stream.end&&(n=new zK,n.value=e.p.parser.eofTerm,n.start=n.end=e.pos,t=this.addActions(e,n.value,n.end,t)),this.mainToken=n,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new zK,{pos:n,p:r}=e;return t.start=n,t.end=Math.min(n+1,r.stream.end),t.value=n==r.stream.end?r.parser.eofTerm:0,t}updateCachedToken(e,t,n){let r=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(r,e),n),e.value>-1){let{parser:t}=n.p;for(let r=0;r<t.specialized.length;r++)if(t.specialized[r]==e.value){let i=t.specializers[r](this.stream.read(e.start,e.end),n);if(i>=0&&n.p.parser.dialect.allows(i>>1)){i&1?e.extended=i>>1:e.value=i>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,t,n,r){for(let t=0;t<r;t+=3)if(this.actions[t]==e)return r;return this.actions[r++]=e,this.actions[r++]=t,this.actions[r++]=n,r}addActions(e,t,n,r){let{state:i}=e,{parser:a}=e.p,{data:o}=a;for(let e=0;e<2;e++)for(let s=a.stateSlot(i,e?2:1);;s+=3){if(o[s]==65535){if(o[s+1]==1)s=nq(o,s+2);else{r==0&&o[s+1]==2&&(r=this.putAction(nq(o,s+2),t,n,r));break}}o[s]==t&&(r=this.putAction(nq(o,s+1),t,n,r))}return r}},QK=class{constructor(e,t,n,r){this.parser=e,this.input=t,this.ranges=r,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new VK(t,r),this.tokens=new ZK(e,this.stream),this.topTerm=e.top[1];let{from:i}=r[0];this.stacks=[PK.start(this,e.top[0],i)],this.fragments=n.length&&this.stream.end-i>e.bufferLength*4?new XK(n,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,n=this.stacks=[],r,i;if(this.bigReductionCount>300&&e.length==1){let[t]=e;for(;t.forceReduce()&&t.stack.length&&t.stack[t.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let a=0;a<e.length;a++){let o=e[a];for(;;){if(this.tokens.mainToken=null,o.pos>t)n.push(o);else if(this.advanceStack(o,n,e))continue;else{r||(r=[],i=[]),r.push(o);let e=this.tokens.getMainToken(o);i.push(e.value,e.end)}break}}if(!n.length){let e=r&&rq(r);if(e)return qK&&console.log(`Finish with `+this.stackID(e)),this.stackToTree(e);if(this.parser.strict)throw qK&&r&&console.log(`Stuck with token `+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):`none`)),SyntaxError(`No parse at `+t);this.recovering||=5}if(this.recovering&&r){let e=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,i,n);if(e)return qK&&console.log(`Force-finish `+this.stackID(e)),this.stackToTree(e.forceAll())}if(this.recovering){let e=this.recovering==1?1:this.recovering*3;if(n.length>e)for(n.sort((e,t)=>t.score-e.score);n.length>e;)n.pop();n.some(e=>e.reducePos>t)&&this.recovering--}else if(n.length>1){outer:for(let e=0;e<n.length-1;e++){let t=n[e];for(let r=e+1;r<n.length;r++){let i=n[r];if(t.sameState(i)||t.buffer.length>500&&i.buffer.length>500){if((t.score-i.score||t.buffer.length-i.buffer.length)>0)n.splice(r--,1);else{n.splice(e--,1);continue outer}}}}n.length>12&&(n.sort((e,t)=>t.score-e.score),n.splice(12,n.length-12))}this.minStackPos=n[0].pos;for(let e=1;e<n.length;e++)n[e].pos<this.minStackPos&&(this.minStackPos=n[e].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw RangeError(`Can't move stoppedAt forward`);this.stoppedAt=e}advanceStack(e,t,n){let r=e.pos,{parser:i}=this,a=qK?this.stackID(e)+` -> `:``;if(this.stoppedAt!=null&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let t=e.curContext&&e.curContext.tracker.strict,n=t?e.curContext.hash:0;for(let o=this.fragments.nodeAt(r);o;){let r=this.parser.nodeSet.types[o.type.id]==o.type?i.getGoto(e.state,o.type.id):-1;if(r>-1&&o.length&&(!t||(o.prop(rK.contextHash)||0)==n))return e.useNode(o,r),qK&&console.log(a+this.stackID(e)+` (via reuse of ${i.getName(o.type.id)})`),!0;if(!(o instanceof dK)||o.children.length==0||o.positions[0]>0)break;let s=o.children[0];if(s instanceof dK&&o.positions[0]==0)o=s;else break}}let o=i.stateSlot(e.state,4);if(o>0)return e.reduce(o),qK&&console.log(a+this.stackID(e)+` (via always-reduce ${i.getName(o&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let s=this.tokens.getActions(e);for(let o=0;o<s.length;){let c=s[o++],l=s[o++],u=s[o++],d=o==s.length||!n,f=d?e:e.split(),p=this.tokens.mainToken;if(f.apply(c,l,p?p.start:f.pos,u),qK&&console.log(a+this.stackID(f)+` (via ${c&65536?`reduce of ${i.getName(c&65535)}`:`shift`} for ${i.getName(l)} @ ${r}${f==e?``:`, split`})`),d)return!0;f.pos>r?t.push(f):n.push(f)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return $K(e,t),!0}}runRecovery(e,t,n){let r=null,i=!1;for(let a=0;a<e.length;a++){let o=e[a],s=t[a<<1],c=t[(a<<1)+1],l=qK?this.stackID(o)+` -> `:``;if(o.deadEnd&&(i||(i=!0,o.restart(),qK&&console.log(l+this.stackID(o)+` (restarted)`),this.advanceFully(o,n))))continue;let u=o.split(),d=l;for(let e=0;e<10&&u.forceReduce()&&(qK&&console.log(d+this.stackID(u)+` (via force-reduce)`),!this.advanceFully(u,n));e++)qK&&(d=this.stackID(u)+` -> `);for(let e of o.recoverByInsert(s))qK&&console.log(l+this.stackID(e)+` (via recover-insert)`),this.advanceFully(e,n);this.stream.end>o.pos?(c==o.pos&&(c++,s=0),o.recoverByDelete(s,c),qK&&console.log(l+this.stackID(o)+` (via recover-delete ${this.parser.getName(s)})`),$K(o,n)):(!r||r.score<u.score)&&(r=u)}return r}stackToTree(e){return e.close(),dK.build({buffer:LK.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(JK||=new WeakMap).get(e);return t||JK.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}};function $K(e,t){for(let n=0;n<t.length;n++){let r=t[n];if(r.pos==e.pos&&r.sameState(e)){t[n].score<e.score&&(t[n]=e);return}}t.push(e)}var eq=class{constructor(e,t,n){this.source=e,this.flags=t,this.disabled=n}allows(e){return!this.disabled||this.disabled[e]==0}},tq=class e extends MK{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(` `);this.minRepeatTerm=t.length;for(let n=0;n<e.repeatNodeCount;n++)t.push(``);let n=Object.keys(e.topRules).map(t=>e.topRules[t][1]),r=[];for(let e=0;e<t.length;e++)r.push([]);function i(e,t,n){r[e].push([t,t.deserialize(String(n))])}if(e.nodeProps)for(let t of e.nodeProps){let e=t[0];typeof e==`string`&&(e=rK[e]);for(let n=1;n<t.length;){let r=t[n++];if(r>=0)i(r,e,t[n++]);else{let a=t[n+-r];for(let o=-r;o>0;o--)i(t[n++],e,a);n++}}}this.nodeSet=new sK(t.map((t,i)=>oK.define({name:i>=this.minRepeatTerm?void 0:t,id:i,props:r[i],top:n.indexOf(i)>-1,error:i==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(i)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=eK;let a=RK(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let e=0;e<this.specializerSpecs.length;e++)this.specialized[e]=this.specializerSpecs[e].term;this.specializers=this.specializerSpecs.map(iq),this.states=RK(e.states,Uint32Array),this.data=RK(e.stateData),this.goto=RK(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(e=>typeof e==`number`?new HK(a,e):e),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,n){let r=new QK(this,e,t,n);for(let i of this.wrappers)r=i(r,e,t,n);return r}getGoto(e,t,n=!1){let r=this.goto;if(t>=r[0])return-1;for(let i=r[t+1];;){let t=r[i++],a=t&1,o=r[i++];if(a&&n)return o;for(let n=i+(t>>1);i<n;i++)if(r[i]==e)return o;if(a)return-1}}hasAction(e,t){let n=this.data;for(let r=0;r<2;r++)for(let i=this.stateSlot(e,r?2:1),a;;i+=3){if((a=n[i])==65535){if(n[i+1]==1)a=n[i=nq(n,i+2)];else if(n[i+1]==2)return nq(n,i+2);else break}if(a==t||a==0)return nq(n,i+1)}return 0}stateSlot(e,t){return this.states[e*6+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){return!!this.allActions(e,e=>e==t||null)}allActions(e,t){let n=this.stateSlot(e,4),r=n?t(n):void 0;for(let n=this.stateSlot(e,1);r==null;n+=3){if(this.data[n]==65535){if(this.data[n+1]==1)n=nq(this.data,n+2);else break}r=t(nq(this.data,n+1))}return r}nextStates(e){let t=[];for(let n=this.stateSlot(e,1);;n+=3){if(this.data[n]==65535){if(this.data[n+1]==1)n=nq(this.data,n+2);else break}if(!(this.data[n+2]&1)){let e=this.data[n+1];t.some((t,n)=>n&1&&t==e)||t.push(this.data[n],e)}}return t}configure(t){let n=Object.assign(Object.create(e.prototype),this);if(t.props&&(n.nodeSet=this.nodeSet.extend(...t.props)),t.top){let e=this.topRules[t.top];if(!e)throw RangeError(`Invalid top rule name ${t.top}`);n.top=e}return t.tokenizers&&(n.tokenizers=this.tokenizers.map(e=>{let n=t.tokenizers.find(t=>t.from==e);return n?n.to:e})),t.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((e,r)=>{let i=t.specializers.find(t=>t.from==e.external);if(!i)return e;let a=Object.assign(Object.assign({},e),{external:i.to});return n.specializers[r]=iq(a),a})),t.contextTracker&&(n.context=t.contextTracker),t.dialect&&(n.dialect=this.parseDialect(t.dialect)),t.strict!=null&&(n.strict=t.strict),t.wrap&&(n.wrappers=n.wrappers.concat(t.wrap)),t.bufferLength!=null&&(n.bufferLength=t.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),n=t.map(()=>!1);if(e)for(let r of e.split(` `)){let e=t.indexOf(r);e>=0&&(n[e]=!0)}let r=null;for(let e=0;e<t.length;e++)if(!n[e])for(let n=this.dialects[t[e]],i;(i=this.data[n++])!=65535;)(r||=new Uint8Array(this.maxTerm+1))[i]=1;return new eq(e,n,r)}static deserialize(t){return new e(t)}};function nq(e,t){return e[t]|e[t+1]<<16}function rq(e){let t=null;for(let n of e){let e=n.p.stoppedAt;(n.pos==n.p.stream.end||e!=null&&n.pos>e)&&n.p.parser.stateFlag(n.state,2)&&(!t||t.score<n.score)&&(t=n)}return t}function iq(e){if(e.external){let t=+!!e.extend;return(n,r)=>e.external(n,r)<<1|t}return e.get}var aq=0,oq=class e{constructor(e,t,n,r){this.name=e,this.set=t,this.base=n,this.modified=r,this.id=aq++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(t,n){let r=typeof t==`string`?t:`?`;if(t instanceof e&&(n=t),n?.base)throw Error(`Can not derive from a modified tag`);let i=new e(r,[],null,[]);if(i.set.push(i),n)for(let e of n.set)i.set.push(e);return i}static defineModifier(e){let t=new cq(e);return e=>e.modified.indexOf(t)>-1?e:cq.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}},sq=0,cq=class e{constructor(e){this.name=e,this.instances=[],this.id=sq++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(e=>e.base==t&&lq(n,e.modified));if(r)return r;let i=[],a=new oq(t.name,i,t,n);for(let e of n)e.instances.push(a);let o=uq(n);for(let n of t.set)if(!n.modified.length)for(let t of o)i.push(e.get(n,t));return a}};function lq(e,t){return e.length==t.length&&e.every((e,n)=>e==t[n])}function uq(e){let t=[[]];for(let n=0;n<e.length;n++)for(let r=0,i=t.length;r<i;r++)t.push(t[r].concat(e[n]));return t.sort((e,t)=>t.length-e.length)}function dq(e){let t=Object.create(null);for(let n in e){let r=e[n];Array.isArray(r)||(r=[r]);for(let e of n.split(` `))if(e){let n=[],i=2,a=e;for(let t=0;;){if(a==`...`&&t>0&&t+3==e.length){i=1;break}let r=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!r)throw RangeError(`Invalid path: `+e);if(n.push(r[0]==`*`?``:r[0][0]==`"`?JSON.parse(r[0]):r[0]),t+=r[0].length,t==e.length)break;let o=e[t++];if(t==e.length&&o==`!`){i=0;break}if(o!=`/`)throw RangeError(`Invalid path: `+e);a=e.slice(t)}let o=n.length-1,s=n[o];if(!s)throw RangeError(`Invalid path: `+e);t[s]=new pq(r,i,o>0?n.slice(0,o):null).sort(t[s])}}return fq.add(t)}var fq=new rK({combine(e,t){let n,r,i;for(;e||t;){if(!e||t&&e.depth<=t.depth?(i=t,t=t.next):(i=e,e=e.next),n&&n.mode==i.mode&&!i.context&&!n.context)continue;let a=new pq(i.tags,i.mode,i.context);n?n.next=a:r=a,n=a}return r}}),pq=class{constructor(e,t,n,r){this.tags=e,this.mode=t,this.context=n,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}};pq.empty=new pq([],2,null);function mq(e,t){let n=Object.create(null);for(let t of e)if(!Array.isArray(t.tag))n[t.tag.id]=t.class;else for(let e of t.tag)n[e.id]=t.class;let{scope:r,all:i=null}=t||{};return{style:e=>{let t=i;for(let r of e)for(let e of r.set){let r=n[e.id];if(r){t=t?t+` `+r:r;break}}return t},scope:r}}function hq(e,t){let n=null;for(let r of e){let e=r.style(t);e&&(n=n?n+` `+e:e)}return n}function gq(e,t,n,r=0,i=e.length){let a=new _q(r,Array.isArray(t)?t:[t],n);a.highlightRange(e.cursor(),r,i,``,a.highlighters),a.flush(i)}var _q=class{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=``}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,r,i){let{type:a,from:o,to:s}=e;if(o>=n||s<=t)return;a.isTop&&(i=this.highlighters.filter(e=>!e.scope||e.scope(a)));let c=r,l=vq(e)||pq.empty,u=hq(i,l.tags);if(u&&(c&&(c+=` `),c+=u,l.mode==1&&(r+=(r?` `:``)+u)),this.startSpan(Math.max(t,o),c),l.opaque)return;let d=e.tree&&e.tree.prop(rK.mounted);if(d&&d.overlay){let a=e.node.enter(d.overlay[0].from+o,1),l=this.highlighters.filter(e=>!e.scope||e.scope(d.tree.type)),u=e.firstChild();for(let f=0,p=o;;f++){let m=f<d.overlay.length?d.overlay[f]:null,h=m?m.from+o:s,g=Math.max(t,p),_=Math.min(n,h);if(g<_&&u)for(;e.from<_&&(this.highlightRange(e,g,_,r,i),this.startSpan(Math.min(_,e.to),c),!(e.to>=h||!e.nextSibling())););if(!m||h>n)break;p=m.to+o,p>t&&(this.highlightRange(a.cursor(),Math.max(t,m.from+o),Math.min(n,p),``,l),this.startSpan(Math.min(n,p),c))}u&&e.parent()}else if(e.firstChild()){d&&(r=``);do if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,r,i),this.startSpan(Math.min(n,e.to),c)}while(e.nextSibling());e.parent()}}};function vq(e){let t=e.type.prop(fq);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}var q=oq.define,yq=q(),bq=q(),xq=q(bq),Sq=q(bq),Cq=q(),wq=q(Cq),Tq=q(Cq),Eq=q(),Dq=q(Eq),Oq=q(),kq=q(),Aq=q(),jq=q(Aq),Mq=q(),J={comment:yq,lineComment:q(yq),blockComment:q(yq),docComment:q(yq),name:bq,variableName:q(bq),typeName:xq,tagName:q(xq),propertyName:Sq,attributeName:q(Sq),className:q(bq),labelName:q(bq),namespace:q(bq),macroName:q(bq),literal:Cq,string:wq,docString:q(wq),character:q(wq),attributeValue:q(wq),number:Tq,integer:q(Tq),float:q(Tq),bool:q(Cq),regexp:q(Cq),escape:q(Cq),color:q(Cq),url:q(Cq),keyword:Oq,self:q(Oq),null:q(Oq),atom:q(Oq),unit:q(Oq),modifier:q(Oq),operatorKeyword:q(Oq),controlKeyword:q(Oq),definitionKeyword:q(Oq),moduleKeyword:q(Oq),operator:kq,derefOperator:q(kq),arithmeticOperator:q(kq),logicOperator:q(kq),bitwiseOperator:q(kq),compareOperator:q(kq),updateOperator:q(kq),definitionOperator:q(kq),typeOperator:q(kq),controlOperator:q(kq),punctuation:Aq,separator:q(Aq),bracket:jq,angleBracket:q(jq),squareBracket:q(jq),paren:q(jq),brace:q(jq),content:Eq,heading:Dq,heading1:q(Dq),heading2:q(Dq),heading3:q(Dq),heading4:q(Dq),heading5:q(Dq),heading6:q(Dq),contentSeparator:q(Eq),list:q(Eq),quote:q(Eq),emphasis:q(Eq),strong:q(Eq),link:q(Eq),monospace:q(Eq),strikethrough:q(Eq),inserted:q(),deleted:q(),changed:q(),invalid:q(),meta:Mq,documentMeta:q(Mq),annotation:q(Mq),processingInstruction:q(Mq),definition:oq.defineModifier(`definition`),constant:oq.defineModifier(`constant`),function:oq.defineModifier(`function`),standard:oq.defineModifier(`standard`),local:oq.defineModifier(`local`),special:oq.defineModifier(`special`)};for(let e in J){let t=J[e];t instanceof oq&&(t.name=e)}mq([{tag:J.link,class:`tok-link`},{tag:J.heading,class:`tok-heading`},{tag:J.emphasis,class:`tok-emphasis`},{tag:J.strong,class:`tok-strong`},{tag:J.keyword,class:`tok-keyword`},{tag:J.atom,class:`tok-atom`},{tag:J.bool,class:`tok-bool`},{tag:J.url,class:`tok-url`},{tag:J.labelName,class:`tok-labelName`},{tag:J.inserted,class:`tok-inserted`},{tag:J.deleted,class:`tok-deleted`},{tag:J.literal,class:`tok-literal`},{tag:J.string,class:`tok-string`},{tag:J.number,class:`tok-number`},{tag:[J.regexp,J.escape,J.special(J.string)],class:`tok-string2`},{tag:J.variableName,class:`tok-variableName`},{tag:J.local(J.variableName),class:`tok-variableName tok-local`},{tag:J.definition(J.variableName),class:`tok-variableName tok-definition`},{tag:J.special(J.variableName),class:`tok-variableName2`},{tag:J.definition(J.propertyName),class:`tok-propertyName tok-definition`},{tag:J.typeName,class:`tok-typeName`},{tag:J.namespace,class:`tok-namespace`},{tag:J.className,class:`tok-className`},{tag:J.macroName,class:`tok-macroName`},{tag:J.propertyName,class:`tok-propertyName`},{tag:J.operator,class:`tok-operator`},{tag:J.comment,class:`tok-comment`},{tag:J.meta,class:`tok-meta`},{tag:J.invalid,class:`tok-invalid`},{tag:J.punctuation,class:`tok-punctuation`}]);var Nq=dq({String:J.string,Number:J.number,"True False":J.bool,PropertyName:J.propertyName,Null:J.null,", :":J.separator,"[ ]":J.squareBracket,"{ }":J.brace}),Pq=tq.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:`#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O`,goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:`⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array`,maxTerm:25,nodeProps:[[`isolate`,-2,6,11,``],[`openedBy`,7,`{`,14,`[`],[`closedBy`,8,`}`,15,`]`]],propSources:[Nq],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),Fq=[],Iq=[];(()=>{let e=`lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5`.split(`,`).map(e=>e?parseInt(e,36):1);for(let t=0,n=0;t<e.length;t++)(t%2?Iq:Fq).push(n+=e[t])})();function Lq(e){if(e<768)return!1;for(let t=0,n=Fq.length;;){let r=t+n>>1;if(e<Fq[r])n=r;else if(e>=Iq[r])t=r+1;else return!0;if(t==n)return!1}}function Rq(e){return e>=127462&&e<=127487}var zq=8205;function Bq(e,t,n=!0,r=!0){return(n?Vq:Hq)(e,t,r)}function Vq(e,t,n){if(t==e.length)return t;t&&Wq(e.charCodeAt(t))&&Gq(e.charCodeAt(t-1))&&t--;let r=Uq(e,t);for(t+=Kq(r);t<e.length;){let i=Uq(e,t);if(r==zq||i==zq||n&&Lq(i))t+=Kq(i),r=i;else if(Rq(i)){let n=0,r=t-2;for(;r>=0&&Rq(Uq(e,r));)n++,r-=2;if(n%2==0)break;t+=2}else break}return t}function Hq(e,t,n){for(;t>1;){let r=Vq(e,t-2,n);if(r<t)return r;t--}return 0}function Uq(e,t){let n=e.charCodeAt(t);if(!Gq(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return Wq(r)?(n-55296<<10)+(r-56320)+65536:n}function Wq(e){return e>=56320&&e<57344}function Gq(e){return e>=55296&&e<56320}function Kq(e){return e<65536?1:2}var qq=class e{lineAt(e){if(e<0||e>this.length)throw RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=rJ(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),Yq.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=rJ(this,e,t);let n=[];return this.decompose(e,t,n,0),Yq.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new $q(this),i=new $q(e);for(let e=t,a=t;;){if(r.next(e),i.next(e),e=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(a+=r.value.length,r.done||a>=n)return!0}}iter(e=1){return new $q(this,e)}iterRange(e,t=this.length){return new eJ(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t??=this.lines+1;let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new tJ(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(t){if(t.length==0)throw RangeError(`A document must have at least one line`);return t.length==1&&!t[0]?e.empty:t.length<=32?new Jq(t):Yq.from(Jq.split(t,[]))}},Jq=class e extends qq{constructor(e,t=Xq(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.text[i],o=r+a.length;if((t?n:o)>=e)return new nJ(r,o,n,a);r=o+1,n++}}decompose(t,n,r,i){let a=t<=0&&n>=this.length?this:new e(Qq(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let t=r.pop(),n=Zq(a.text,t.text.slice(),0,a.length);if(n.length<=32)r.push(new e(n,t.length+a.length));else{let t=n.length>>1;r.push(new e(n.slice(0,t)),new e(n.slice(t)))}}else r.push(a)}replace(t,n,r){if(!(r instanceof e))return super.replace(t,n,r);[t,n]=rJ(this,t,n);let i=Zq(this.text,Zq(r.text,Qq(this.text,0,t)),n),a=this.length+r.length-(n-t);return i.length<=32?new e(i,a):Yq.from(e.split(i,[]),a)}sliceString(e,t=this.length,n=`
|
|
20
20
|
`){[e,t]=rJ(this,e,t);let r=``;for(let i=0,a=0;i<=t&&a<this.text.length;a++){let o=this.text[a],s=i+o.length;i>e&&a&&(r+=n),e<s&&t>i&&(r+=o.slice(Math.max(0,e-i),t-i)),i=s+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(t,n){let r=[],i=-1;for(let a of t)r.push(a),i+=a.length+1,r.length==32&&(n.push(new e(r,i)),r=[],i=-1);return i>-1&&n.push(new e(r,i)),n}},Yq=class e extends qq{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let t of e)this.lines+=t.lines}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.children[i],o=r+a.length,s=n+a.lines-1;if((t?s:o)>=e)return a.lineInner(e,t,n,r);r=o+1,n=s+1}}decompose(e,t,n,r){for(let i=0,a=0;a<=t&&i<this.children.length;i++){let o=this.children[i],s=a+o.length;if(e<=s&&t>=a){let i=r&(a<=e|(s>=t?2:0));a>=e&&s<=t&&!i?n.push(o):o.decompose(e-a,t-a,n,i)}a=s+1}}replace(t,n,r){if([t,n]=rJ(this,t,n),r.lines<this.lines)for(let i=0,a=0;i<this.children.length;i++){let o=this.children[i],s=a+o.length;if(t>=a&&n<=s){let c=o.replace(t-a,n-a,r),l=this.lines-o.lines+c.lines;if(c.lines<l>>4&&c.lines>l>>6){let a=this.children.slice();return a[i]=c,new e(a,this.length-(n-t)+r.length)}return super.replace(a,s,c)}a=s+1}return super.replace(t,n,r)}sliceString(e,t=this.length,n=`
|
|
21
21
|
`){[e,t]=rJ(this,e,t);let r=``;for(let i=0,a=0;i<this.children.length&&a<=t;i++){let o=this.children[i],s=a+o.length;a>e&&i&&(r+=n),e<s&&t>a&&(r+=o.sliceString(e-a,t-a,n)),a=s+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(t,n){if(!(t instanceof e))return 0;let r=0,[i,a,o,s]=n>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;i+=n,a+=n){if(i==o||a==s)return r;let e=this.children[i],c=t.children[a];if(e!=c)return r+e.scanIdentical(c,n);r+=e.length+1}}static from(t,n=t.reduce((e,t)=>e+t.length+1,-1)){let r=0;for(let e of t)r+=e.lines;if(r<32){let e=[];for(let n of t)n.flatten(e);return new Jq(e,n)}let i=Math.max(32,r>>5),a=i<<1,o=i>>1,s=[],c=0,l=-1,u=[];function d(t){let n;if(t.lines>a&&t instanceof e)for(let e of t.children)d(e);else t.lines>o&&(c>o||!c)?(f(),s.push(t)):t instanceof Jq&&c&&(n=u[u.length-1])instanceof Jq&&t.lines+n.lines<=32?(c+=t.lines,l+=t.length+1,u[u.length-1]=new Jq(n.text.concat(t.text),n.length+1+t.length)):(c+t.lines>i&&f(),c+=t.lines,l+=t.length+1,u.push(t))}function f(){c!=0&&(s.push(u.length==1?u[0]:e.from(u,l)),l=-1,c=u.length=0)}for(let e of t)d(e);return f(),s.length==1?s[0]:new e(s,n)}};qq.empty=new Jq([``],0);function Xq(e){let t=-1;for(let n of e)t+=n.length+1;return t}function Zq(e,t,n=0,r=1e9){for(let i=0,a=0,o=!0;a<e.length&&i<=r;a++){let s=e[a],c=i+s.length;c>=n&&(c>r&&(s=s.slice(0,r-i)),i<n&&(s=s.slice(n-i)),o?(t[t.length-1]+=s,o=!1):t.push(s)),i=c+1}return t}function Qq(e,t,n){return Zq(e,[``],t,n)}var $q=class{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value=``,this.nodes=[e],this.offsets=[t>0?1:(e instanceof Jq?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,r=this.nodes[n],i=this.offsets[n],a=i>>1,o=r instanceof Jq?r.text.length:r.children.length;if(a==(t>0?o:0)){if(n==0)return this.done=!0,this.value=``,this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((i&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=`
|
|
@@ -39,4 +39,4 @@ ${String(e.value)}`:String(e.value),truncate:!0,children:String(e.value)})}funct
|
|
|
39
39
|
`)+(e.length===0?``:`\r
|
|
40
40
|
`)}function Qae(e){return e==null?``:typeof e==`object`?JSON.stringify(e):String(e)}function _9(e){return/["\r\n,]/.test(e)?`"${e.replace(/"/g,`""`)}"`:e}function $ae({records:e,onSelectRecord:t}){return e.length===0?(0,F.jsx)(I,{p:4,color:`fg.muted`,children:(0,F.jsx)(V,{children:`No records yet. Run a sample to see them here.`})}):(0,F.jsx)(I,{as:`pre`,p:2,h:`full`,overflow:`auto`,fontFamily:`mono`,fontSize:`xs`,whiteSpace:`pre-wrap`,children:g9(e).trimEnd().split(`
|
|
41
41
|
`).map((e,n)=>(0,F.jsx)(I,{as:`span`,display:`block`,cursor:t===void 0?void 0:`pointer`,_hover:t===void 0?void 0:{bg:`bg.muted`},onClick:t===void 0?void 0:()=>{t(n)},children:e},n))})}function eoe({record:e,index:t,onClose:n}){return(0,F.jsx)(ow,{open:e!==void 0,onOpenChange:e=>{e.open||n()},size:`lg`,placement:`center`,scrollBehavior:`inside`,children:(0,F.jsxs)(g_,{children:[(0,F.jsx)(dw,{}),(0,F.jsx)(sw,{children:(0,F.jsxs)(cw,{children:[(0,F.jsxs)(pw,{display:`flex`,flexDirection:`row`,alignItems:`center`,justifyContent:`space-between`,children:[(0,F.jsxs)(I,{minW:0,children:[(0,F.jsxs)(lw,{children:[`Record `,t===void 0?``:t+1]}),e?.key!=null&&(0,F.jsx)(V,{fontSize:`xs`,color:`fg.muted`,truncate:!0,title:e.key,children:e.key})]}),(0,F.jsx)(uw,{asChild:!0,children:(0,F.jsx)(ew,{size:`sm`,"aria-label":`Close record`})})]}),(0,F.jsx)(fw,{pb:4,children:(0,F.jsx)(I,{as:`pre`,fontFamily:`mono`,fontSize:`xs`,whiteSpace:`pre-wrap`,wordBreak:`break-word`,children:e===void 0?``:JSON.stringify(e.data,null,2)})})]})})]})})}function toe({records:e,onCellClick:t,highlightedField:n,onHoverField:r}){let[i,a]=(0,P.useState)(`table`),[o,s]=(0,P.useState)(!1),[c,l]=(0,P.useState)();function u(t){let n=Jae(e,t);noe(n.filename,n.mimeType,n.content)}return(0,F.jsxs)(I,{flex:`1`,minH:`0`,display:`flex`,flexDirection:`column`,children:[(0,F.jsx)(y9,{view:i,onViewChange:a,onExport:u,onEnlarge:()=>{s(!0)},exportDisabled:e.length===0}),(0,F.jsx)(I,{flex:`1`,minH:`0`,overflow:`auto`,children:(0,F.jsx)(v9,{view:i,records:e,onCellClick:t,highlightedField:n,onHoverField:r,onSelectRecord:l})}),(0,F.jsx)(ow,{open:o,onOpenChange:e=>{s(e.open)},size:`cover`,placement:`center`,children:(0,F.jsxs)(g_,{children:[(0,F.jsx)(dw,{}),(0,F.jsx)(sw,{children:(0,F.jsxs)(cw,{h:`85vh`,display:`flex`,flexDirection:`column`,children:[(0,F.jsxs)(pw,{display:`flex`,flexDirection:`row`,alignItems:`center`,justifyContent:`space-between`,children:[(0,F.jsxs)(lw,{children:[`Records (`,e.length,`)`]}),(0,F.jsx)(uw,{asChild:!0,children:(0,F.jsx)(ew,{size:`sm`,"aria-label":`Close`})})]}),(0,F.jsxs)(fw,{flex:`1`,minH:`0`,display:`flex`,flexDirection:`column`,gap:2,pb:4,children:[(0,F.jsx)(y9,{view:i,onViewChange:a,onExport:u,exportDisabled:e.length===0}),(0,F.jsx)(I,{flex:`1`,minH:`0`,overflow:`auto`,children:(0,F.jsx)(v9,{view:i,records:e,onCellClick:t,highlightedField:n,onHoverField:r,onSelectRecord:l})})]})]})})]})}),(0,F.jsx)(eoe,{record:c===void 0?void 0:e[c],index:c,onClose:()=>{l(void 0)}})]})}function v9({view:e,records:t,onCellClick:n,highlightedField:r,onHoverField:i,onSelectRecord:a}){return e===`table`?(0,F.jsx)(Gae,{records:t,onCellClick:n,highlightedField:r,onHoverField:i,onSelectRecord:a}):(0,F.jsx)($ae,{records:t,onSelectRecord:a})}function y9({view:e,onViewChange:t,onExport:n,onEnlarge:r,exportDisabled:i}){return(0,F.jsxs)(W,{px:2,py:1,gap:2,borderBottomWidth:`1px`,flexShrink:0,children:[(0,F.jsx)(UC,{size:`2xs`,colorPalette:`brand`,variant:e===`table`?`solid`:`outline`,onClick:()=>{t(`table`)},children:`Table`}),(0,F.jsx)(UC,{size:`2xs`,colorPalette:`brand`,variant:e===`jsonl`?`solid`:`outline`,onClick:()=>{t(`jsonl`)},children:`JSONL`}),(0,F.jsx)(Lw,{size:`xs`,width:`7em`,variant:`outline`,disabled:i,children:(0,F.jsxs)(zw,{"aria-label":`Export records`,value:``,onChange:e=>{let t=e.target.value;t!==``&&n(t),e.target.value=``},children:[(0,F.jsx)(`option`,{value:``,disabled:!0,children:`Export…`}),(0,F.jsx)(`option`,{value:`json`,children:`JSON`}),(0,F.jsx)(`option`,{value:`jsonl`,children:`JSONL`}),(0,F.jsx)(`option`,{value:`csv`,children:`CSV`})]})}),r!==void 0&&(0,F.jsx)(UC,{size:`2xs`,variant:`outline`,onClick:r,marginStart:`auto`,children:`Enlarge`})]})}function noe(e,t,n){let r=new Blob([n],{type:t}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=e,document.body.append(a),a.click(),a.remove(),URL.revokeObjectURL(i)}function roe({rejected:e,onClick:t}){return e.length===0?null:(0,F.jsxs)(rw,{borderTopWidth:`1px`,gap:0,flexShrink:0,maxH:`30%`,overflow:`auto`,children:[(0,F.jsxs)(I,{px:3,py:1,fontSize:`xs`,fontWeight:`semibold`,color:`fg.muted`,children:[`Rejected (`,e.length,`)`]}),(0,F.jsx)(hT,{size:`sm`,children:(0,F.jsx)(xT,{children:e.map((e,n)=>(0,F.jsxs)(gT,{cursor:t===void 0?void 0:`pointer`,onClick:t===void 0?void 0:()=>{t(n)},children:[(0,F.jsx)(bT,{fontFamily:`mono`,fontWeight:`medium`,children:e.field}),(0,F.jsx)(bT,{color:`fg.error`,children:(0,F.jsx)(V,{truncate:!0,children:e.reason})})]},`${e.field}-${n}`))})})]})}function ioe({lines:e}){return e.length===0?(0,F.jsx)(I,{p:4,color:`fg.muted`,children:(0,F.jsx)(V,{children:`No trace yet. Run a sample to see it here.`})}):(0,F.jsx)(I,{as:`pre`,p:2,h:`full`,overflow:`auto`,fontFamily:`mono`,fontSize:`xs`,whiteSpace:`pre-wrap`,children:e.join(`
|
|
42
|
-
`)})}function aoe({loading:e,view:t,error:n}){return e===!0?(0,F.jsxs)(rw,{p:4,direction:`row`,align:`center`,color:`fg.muted`,children:[(0,F.jsx)(zC,{size:`sm`}),(0,F.jsx)(V,{children:`Working it out…`})]}):n===void 0?t===void 0?(0,F.jsx)(I,{p:4,color:`fg.muted`,children:(0,F.jsx)(V,{children:`Click a missing or rejected value in the Records tab to see why here.`})}):(0,F.jsxs)(rw,{p:4,gap:2,children:[(0,F.jsxs)(rw,{direction:`row`,gap:2,align:`center`,children:[(0,F.jsx)(LC,{colorPalette:t.outcome===`rejected`?`red`:`orange`,children:t.outcome}),(0,F.jsx)(V,{fontFamily:`mono`,fontSize:`sm`,fontWeight:`medium`,children:t.field})]}),(0,F.jsx)(V,{children:t.sentence}),t.policy!==void 0&&(0,F.jsxs)(V,{fontSize:`xs`,color:`fg.muted`,children:[`policy: `,t.policy]}),t.stepPath!==void 0&&(0,F.jsxs)(V,{fontSize:`xs`,color:`fg.muted`,children:[`step: `,t.stepPath]})]}):(0,F.jsx)(I,{p:4,children:(0,F.jsx)(V,{color:`fg.error`,children:n})})}function ooe({records:e,traceLines:t,rejected:n=[],onExplainMissing:r,onExplainRejected:i,whyLoading:a,whyView:o,whyError:s,highlightedField:c,onHoverField:l}){return(0,F.jsxs)(Hc,{colorPalette:`brand`,defaultValue:`records`,h:`full`,display:`flex`,flexDirection:`column`,children:[(0,F.jsxs)(Gc,{children:[(0,F.jsxs)(Uc,{value:`records`,children:[`Records (`,e.length,`)`]}),(0,F.jsx)(Uc,{value:`trace`,children:`Trace`}),(0,F.jsx)(Uc,{value:`why`,children:`Why?`})]}),(0,F.jsxs)(Wc,{value:`records`,flex:`1`,minH:`0`,p:0,display:`flex`,flexDirection:`column`,children:[(0,F.jsx)(toe,{records:e,onCellClick:r,highlightedField:c,onHoverField:l}),(0,F.jsx)(roe,{rejected:n,onClick:i})]}),(0,F.jsx)(Wc,{value:`trace`,flex:`1`,minH:`0`,overflow:`auto`,p:0,children:(0,F.jsx)(ioe,{lines:t})}),(0,F.jsx)(Wc,{value:`why`,flex:`1`,minH:`0`,overflow:`auto`,p:0,children:(0,F.jsx)(aoe,{loading:a,view:o,error:s})})]})}function b9(e){if(Array.isArray(e))return e.some(e=>b9(e));if(typeof e!=`object`||!e)return!1;let t=e;return t.type===`emit`||Object.values(t).some(e=>b9(e))}function soe(e){return[...Array.isArray(e)?e:[],{type:`emit`}]}var coe={string:`gray`,number:`blue`,integer:`blue`,boolean:`green`,date:`purple`,datetime:`purple`,currency:`orange`,url:`cyan`,enum:`pink`,array:`teal`,object:`teal`,json:`yellow`};function x9(e){return coe[e]??`gray`}function S9(e){return e!==void 0&&`each`in e}function loe(e){let t={};for(let[n,r]of Object.entries(e))!S9(r)&&typeof r.from==`string`&&(t[n]=r.from);return t}var uoe=[`string`,`number`,`integer`,`boolean`,`date`,`datetime`,`currency`,`url`,`enum`,`array`,`object`,`json`],C9=[`fail`,`skip-record`,`null`,`default`],w9=/^[A-Z_][\w-]*$/i,doe=`trim.lowercase.uppercase.replace.regex.split.join.first.last.nth.slice.concat.coalesce.default.number.integer.boolean.toString.padStart.padEnd.currency.date.absoluteUrl.urlEncode.flatten.unique.sum.count.template.jsonpath.lookup.group`.split(`.`),foe={replace:[{name:`pattern`},{name:`replacement`},{name:`flags`}],regex:[{name:`pattern`},{name:`group`,numeric:!0},{name:`flags`}],split:[{name:`separator`}],join:[{name:`separator`}],nth:[{name:`index`,numeric:!0}],slice:[{name:`start`,numeric:!0},{name:`end`,numeric:!0}],concat:[{name:`separator`}],default:[{name:`value`}],number:[{name:`locale`}],boolean:[{name:`truthy`}],padStart:[{name:`length`,numeric:!0},{name:`char`}],padEnd:[{name:`length`,numeric:!0},{name:`char`}],currency:[{name:`locale`},{name:`currency`}],date:[{name:`format`},{name:`timezone`}],absoluteUrl:[{name:`base`}],template:[{name:`value`}],jsonpath:[{name:`path`}],lookup:[{name:`in`},{name:`key`},{name:`pick`}],group:[{name:`by`}]};function poe(e){return foe[e]??[]}function moe({transforms:e,trace:t,onChange:n}){let[r,i]=(0,P.useState)(!1),a=bk(),o=(t,r)=>{n(e.map((e,n)=>n===t?r:e))},s=t=>{n(e.filter((e,n)=>n!==t))},c=(t,r)=>{let i=t+r;if(i<0||i>=e.length)return;let a=[...e],o=a[t];a[t]=a[i],a[i]=o,n(a)},l=t=>{n([...e,t===`hook`?{op:t,name:a?.[0]??`myHook`}:{op:t}]),i(!1)};return(0,F.jsxs)(rw,{direction:`row`,gap:2,wrap:`wrap`,align:`flex-start`,children:[e.map((n,r)=>(0,F.jsx)(hoe,{transform:n,value:t?.steps[r]?.value,failed:t!==void 0&&t.steps.length<=r,onChange:e=>{o(r,e)},onRemove:()=>{s(r)},onMoveLeft:r===0?void 0:()=>{c(r,-1)},onMoveRight:r===e.length-1?void 0:()=>{c(r,1)}},r)),r?(0,F.jsx)(Lw,{size:`xs`,width:`140px`,children:(0,F.jsxs)(zw,{defaultValue:``,onChange:e=>{e.target.value!==``&&l(e.target.value)},children:[(0,F.jsx)(`option`,{value:``,disabled:!0,children:`op…`}),doe.map(e=>(0,F.jsx)(`option`,{value:e,children:e},e)),(0,F.jsx)(`option`,{value:`hook`,children:`hook (your code)`})]})}):(0,F.jsx)(UC,{size:`xs`,variant:`outline`,onClick:()=>{i(!0)},children:`+ transform`})]})}function hoe({transform:e,value:t,failed:n,onChange:r,onRemove:i,onMoveLeft:a,onMoveRight:o}){let[s,c]=(0,P.useState)(!1),l=e.op===`hook`,u=l?[]:poe(e.op),d=l||u.length>0;return(0,F.jsxs)(I,{borderWidth:`1px`,borderRadius:`md`,borderColor:n?`red.subtle`:void 0,px:2,py:1,fontSize:`xs`,children:[(0,F.jsxs)(W,{gap:1,children:[a!==void 0&&(0,F.jsx)($C,{"aria-label":`Move left`,size:`2xs`,variant:`ghost`,onClick:a,children:`‹`}),(0,F.jsxs)(V,{as:d?`button`:`span`,fontWeight:`medium`,cursor:d?`pointer`:void 0,onClick:d?()=>{c(!s)}:void 0,children:[e.op,l&&typeof e.name==`string`?`: ${e.name}`:``]}),o!==void 0&&(0,F.jsx)($C,{"aria-label":`Move right`,size:`2xs`,variant:`ghost`,onClick:o,children:`›`}),(0,F.jsx)($C,{"aria-label":`Remove ${e.op}`,size:`2xs`,variant:`ghost`,colorPalette:`red`,onClick:i,children:`×`})]}),t!==void 0&&(0,F.jsxs)(LC,{mt:1,size:`sm`,colorPalette:n?`red`:`gray`,fontFamily:`mono`,maxW:`160px`,overflow:`hidden`,textOverflow:`ellipsis`,children:[`→ `,typeof t==`object`?JSON.stringify(t):String(t)]}),s&&l&&(0,F.jsx)(rw,{mt:1,gap:1,children:(0,F.jsx)(xk,{size:`xs`,ariaLabel:`Hook name`,value:typeof e.name==`string`?e.name:``,onChange:t=>{r({...e,name:t})}})}),s&&u.length>0&&(0,F.jsx)(rw,{mt:1,gap:1,children:u.map(t=>(0,F.jsxs)(W,{gap:1,children:[(0,F.jsx)(V,{color:`fg.muted`,minW:`70px`,children:t.name}),(0,F.jsx)(Dw,{size:`2xs`,value:e[t.name]===void 0?``:String(e[t.name]),onChange:n=>{let i=n.target.value;r({...e,[t.name]:t.numeric?Number(i):i})}})]},t.name))})]})}function T9({name:e,field:t,rule:n,scopeIds:r,trace:i,value:a,missing:o,rejected:s,depth:c=0,stepId:l,highlighted:u=!1,onHoverStepId:d,onFieldChange:f,onRuleChange:p,onRename:m,onRemove:h,onExplainMissing:g,onExplainRejected:_}){let[v,y]=(0,P.useState)(!1),[b,x]=(0,P.useState)(e),[S,C]=(0,P.useState)(),[w,T]=(0,P.useState)(!1),E=t.generated!==void 0;return(0,F.jsxs)(I,{"data-testid":`${e}-row`,"data-highlighted":u,borderWidth:`1px`,borderRadius:`md`,p:2,ml:c*5,borderColor:u?`orange.solid`:s===void 0?void 0:`red.subtle`,bg:u?`orange.subtle`:void 0,onMouseEnter:l===void 0||d===void 0?void 0:()=>{d(l)},onMouseLeave:l===void 0||d===void 0?void 0:()=>{d(void 0)},children:[(0,F.jsxs)(W,{"data-testid":`${e}-summary`,gap:2,mb:2,align:`center`,wrap:`wrap`,fontSize:`xs`,children:[(0,F.jsx)(LC,{size:`sm`,colorPalette:x9(t.type),children:t.type}),E?(0,F.jsx)(LC,{size:`sm`,colorPalette:`gray`,children:`generated`}):l===void 0?(0,F.jsx)(LC,{size:`sm`,colorPalette:`orange`,children:n===void 0?`not mapped`:`from a template`}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(V,{color:`fg.muted`,children:`←`}),(0,F.jsx)(oB,{name:l,draggable:!1})]}),a!==void 0&&(0,F.jsxs)(V,{color:`fg.muted`,truncate:!0,maxW:`260px`,title:E9(a),children:[`= `,E9(a)]})]}),(0,F.jsxs)(W,{gap:2,align:`center`,wrap:`wrap`,children:[(0,F.jsxs)(rw,{gap:0,children:[(0,F.jsx)(Dw,{size:`xs`,width:`140px`,value:b,onChange:e=>{x(e.target.value)},onBlur:()=>{if(b!==e){if(!w9.test(b)){C(`a field name has no dots`);return}C(void 0),m(b)}}}),S!==void 0&&(0,F.jsx)(V,{fontSize:`2xs`,color:`fg.error`,children:S})]}),(0,F.jsx)(Lw,{size:`xs`,width:`110px`,children:(0,F.jsx)(zw,{value:t.type,onChange:e=>{f({...t,type:e.target.value})},children:uoe.map(e=>(0,F.jsx)(`option`,{value:e,children:e},e))})}),(0,F.jsx)(I,{"data-testid":`${e}-source-drop`,minW:`140px`,borderWidth:`1px`,borderStyle:`dashed`,borderRadius:`sm`,px:2,py:`2px`,fontSize:`xs`,bg:w?`colorPalette.subtle`:void 0,colorPalette:`brand`,onDragOver:e=>{e.dataTransfer.types.includes(`application/x-opencraw-pill`)&&(e.preventDefault(),T(!0))},onDragLeave:()=>{T(!1)},onDrop:e=>{e.preventDefault(),T(!1);let t=e.dataTransfer.getData(`application/x-opencraw-pill`)||e.dataTransfer.getData(`text/plain`);t!==``&&p({...n,from:t})},children:E?(0,F.jsxs)(V,{color:`fg.muted`,children:[`generated: `,t.generated]}):(0,F.jsx)(Lw,{size:`xs`,children:(0,F.jsxs)(zw,{value:typeof n?.from==`string`?n.from:``,onChange:e=>{p(e.target.value===``?void 0:{...n,from:e.target.value})},children:[(0,F.jsx)(`option`,{value:``,children:`(drop a pill, or pick)`}),r.map(e=>(0,F.jsx)(`option`,{value:e,children:e},e))]})})}),(0,F.jsxs)(JC,{size:`xs`,checked:t.key===!0,onCheckedChange:e=>{f({...t,key:e.checked===!0})},children:[(0,F.jsx)(QC,{}),(0,F.jsx)(ZC,{}),(0,F.jsx)(YC,{children:`key`})]}),(0,F.jsxs)(JC,{size:`xs`,checked:t.required===!0,disabled:E,onCheckedChange:e=>{f({...t,required:e.checked===!0})},children:[(0,F.jsx)(QC,{}),(0,F.jsx)(ZC,{}),(0,F.jsx)(YC,{children:`required`})]}),o===!0&&(0,F.jsx)(UC,{size:`2xs`,variant:`outline`,colorPalette:`orange`,onClick:g,children:`Why null?`}),s!==void 0&&(0,F.jsxs)(UC,{size:`2xs`,variant:`outline`,colorPalette:`red`,onClick:_,title:s.reason,children:[s.count,` rejected`]}),(0,F.jsx)(UC,{size:`2xs`,variant:`ghost`,onClick:()=>{y(!v)},children:v?`less`:`more`}),(0,F.jsx)($C,{"aria-label":`Remove ${e}`,size:`2xs`,variant:`ghost`,colorPalette:`red`,onClick:h,ml:`auto`,children:`×`})]}),!E&&t.type!==`object`&&(0,F.jsx)(I,{mt:2,children:(0,F.jsx)(moe,{transforms:n?.transform??[],trace:i,onChange:e=>{p(n===void 0?void 0:{...n,transform:e.length===0?void 0:e})}})}),v&&(0,F.jsxs)(rw,{mt:2,direction:`row`,gap:3,wrap:`wrap`,fontSize:`xs`,children:[(0,F.jsxs)(JC,{size:`xs`,checked:t.nullable===!0,onCheckedChange:e=>{f({...t,nullable:e.checked===!0})},children:[(0,F.jsx)(QC,{}),(0,F.jsx)(ZC,{}),(0,F.jsx)(YC,{children:`nullable`})]}),(0,F.jsxs)(W,{gap:1,children:[(0,F.jsx)(V,{color:`fg.muted`,children:`onMissing`}),(0,F.jsx)(Lw,{size:`xs`,width:`110px`,children:(0,F.jsxs)(zw,{value:t.onMissing??``,onChange:e=>{f({...t,onMissing:e.target.value===``?void 0:e.target.value})},children:[(0,F.jsx)(`option`,{value:``,children:`(recipe default)`}),C9.map(e=>(0,F.jsx)(`option`,{value:e,children:e},e))]})})]}),(0,F.jsxs)(W,{gap:1,children:[(0,F.jsx)(V,{color:`fg.muted`,children:`default`}),(0,F.jsx)(Dw,{size:`xs`,width:`120px`,value:t.default===void 0?``:String(t.default),onChange:e=>{f({...t,default:e.target.value===``?void 0:e.target.value})}})]}),t.type===`currency`&&(0,F.jsxs)(W,{gap:1,children:[(0,F.jsx)(V,{color:`fg.muted`,children:`currency`}),(0,F.jsx)(Dw,{size:`xs`,width:`60px`,value:t.currency??``,onChange:e=>{f({...t,currency:e.target.value||void 0})}})]}),(t.type===`date`||t.type===`datetime`)&&(0,F.jsxs)(W,{gap:1,children:[(0,F.jsx)(V,{color:`fg.muted`,children:`format`}),(0,F.jsx)(Dw,{size:`xs`,width:`100px`,value:t.format??``,onChange:e=>{f({...t,format:e.target.value||void 0})}})]}),t.type===`enum`&&(0,F.jsxs)(W,{gap:1,children:[(0,F.jsx)(V,{color:`fg.muted`,children:`values`}),(0,F.jsx)(Dw,{size:`xs`,width:`160px`,placeholder:`a, b, c`,value:(t.values??[]).join(`, `),onChange:e=>{f({...t,values:e.target.value.split(`,`).map(e=>e.trim()).filter(e=>e!==``)})}})]}),(0,F.jsxs)(W,{gap:1,children:[(0,F.jsx)(V,{color:`fg.muted`,children:`pattern`}),(0,F.jsx)(Dw,{size:`xs`,width:`120px`,value:t.pattern??``,onChange:e=>{f({...t,pattern:e.target.value||void 0})}})]}),(0,F.jsxs)(W,{gap:1,children:[(0,F.jsx)(V,{color:`fg.muted`,children:`min`}),(0,F.jsx)(Dw,{size:`xs`,width:`60px`,value:t.min??``,onChange:e=>{f({...t,min:e.target.value===``?void 0:Number(e.target.value)})}})]}),(0,F.jsxs)(W,{gap:1,children:[(0,F.jsx)(V,{color:`fg.muted`,children:`max`}),(0,F.jsx)(Dw,{size:`xs`,width:`60px`,value:t.max??``,onChange:e=>{f({...t,max:e.target.value===``?void 0:Number(e.target.value)})}})]})]})]})}function E9(e){let t=typeof e==`string`?e:JSON.stringify(e);return t.length>80?`${t.slice(0,79)}…`:t}function goe({suggestions:e,onAdd:t,onAddAll:n}){return e.length===0?null:(0,F.jsxs)(I,{"data-testid":`field-suggestions`,borderWidth:`1px`,borderStyle:`dashed`,borderRadius:`md`,p:2,bg:`bg.subtle`,children:[(0,F.jsxs)(W,{justify:`space-between`,mb:1,children:[(0,F.jsx)(V,{fontSize:`xs`,fontWeight:`medium`,children:`Read by the steps, not in the output yet`}),(0,F.jsxs)(UC,{size:`2xs`,variant:`outline`,onClick:n,children:[`Add all (`,e.length,`)`]})]}),(0,F.jsx)(rw,{direction:`row`,wrap:`wrap`,gap:2,children:e.map(e=>(0,F.jsxs)(W,{"data-testid":`suggestion-${e.source}`,gap:1,borderWidth:`1px`,borderRadius:`full`,pl:1,pr:1,py:`1px`,bg:`bg`,title:`${e.name}: ${e.field.type}, because ${e.reason}`,children:[(0,F.jsx)(oB,{name:e.source,draggable:!1}),(0,F.jsx)(V,{fontSize:`xs`,color:`fg.muted`,children:`→`}),(0,F.jsx)(V,{fontSize:`xs`,fontWeight:`medium`,children:e.name}),(0,F.jsx)(LC,{size:`sm`,colorPalette:x9(e.field.type),children:e.field.type}),(0,F.jsx)(UC,{size:`2xs`,variant:`ghost`,"aria-label":`Add ${e.name}`,onClick:()=>{t(e)},children:`+`})]},e.source))})]})}function D9(e){let t=new Set(e.dataTransfer.types);return t.has(`application/x-opencraw-pill`)||t.has(`application/x-opencraw-card`)}function _oe({onPill:e,onCard:t,children:n}){let[r,i]=(0,P.useState)(!1);function a(e){!e.defaultPrevented&&D9(e)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`,i(!0))}function o(n){if(i(!1),n.defaultPrevented||!D9(n))return;n.preventDefault();let r=gk(n.dataTransfer);if(r!==void 0){t(r);return}let a=n.dataTransfer.getData(aB);a!==``&&e(a)}return(0,F.jsx)(I,{"data-testid":`output-drop-zone`,"data-drop-over":r,borderWidth:`2px`,borderStyle:`dashed`,borderColor:r?`brand.solid`:`transparent`,bg:r?`brand.subtle`:void 0,borderRadius:`md`,minH:`4em`,flexShrink:0,onDragOver:a,onDragLeave:()=>{i(!1)},onDrop:o,children:n})}function voe(e){let t=k9(e);if(t===void 0)return[];let n=[];return O9(t,n),n}function O9(e,t){for(let n of e){if(typeof n!=`object`||!n)continue;let e=n;for(let n of[`id`,`as`]){let r=e[n];typeof r==`string`&&r.length>0&&!t.includes(r)&&t.push(r)}let r=k9(e);r!==void 0&&O9(r,t),Array.isArray(e.else)&&O9(e.else,t)}}function k9(e){if(typeof e!=`object`||!e)return;let t=e.steps;return Array.isArray(t)?t:void 0}var yoe=new Set([`attr:href`,`attr:src`,`attr:data-src`]),boe=[[[`url`,`link`,`href`,`website`,`homepage`,`image`,`img`,`photo`,`thumbnail`,`src`],{type:`url`,reason:`its name says a link`}],[[`datetime`,`timestamp`],{type:`datetime`,reason:`its name says a moment in time`}],[[`date`,`day`,`published`,`created`,`updated`,`released`,`expires`,`expiry`,`until`,`since`],{type:`date`,reason:`its name says a date`}],[[`available`,`availability`,`active`,`enabled`,`instock`,`is`,`has`],{type:`boolean`,reason:`its name says yes or no`}],[[`qty`,`quantity`,`count`,`pages`,`year`,`age`,`rank`,`position`,`votes`,`reviews`],{type:`integer`,reason:`its name says a whole number`}],[[`price`,`cost`,`amount`,`total`,`fee`,`discount`,`salary`,`rate`,`rating`,`score`,`weight`,`height`,`width`,`length`,`percent`,`sconto`],{type:`number`,reason:`its name says an amount`}]];function A9(e,t,n){let r=N9(M9(e)),i=new Set(r.flatMap(e=>typeof e.over==`string`?[e.over]:[])),a=woe(n),o=new Set(Object.keys(t)),s=[],c=new Set;for(let e of r){let t=e.id;if(typeof t!=`string`||t===``||!Coe(e)||i.has(t)||a.has(t)||c.has(t))continue;c.add(t);let n=Soe(t,e),r=j9(t,o);o.add(r),s.push({source:t,name:r,field:{type:n.type,...n.items!==void 0&&{items:n.items}},rule:{from:n.from??t,...n.transform!==void 0&&{transform:n.transform}},reason:n.reason})}return s}function xoe(e,t,n,r){let i=A9(t,n,r).find(t=>t.source===e);return i===void 0?{source:e,name:j9(e,new Set(Object.keys(n))),field:{type:`string`},rule:{from:e},reason:`text, the safe default`}:i}function Soe(e,t){if(t.kind===`table`)return{type:`json`,from:`${e}.rows`,reason:`the rows of the table, as a list`};if(t.many===!0)return{type:`array`,items:{type:`string`},reason:`it reads every match, a list`};let n=typeof t.take==`string`?t.take:void 0;if(n!==void 0&&yoe.has(n))return{type:`url`,transform:[{op:`absoluteUrl`}],reason:`it takes ${n}, a link (made absolute)`};if(t.kind===`section`)return{type:`string`,reason:`it reads a block of text`};let r=Toe(e);for(let[e,t]of boe)if(r.some(t=>e.includes(t)))return t;return{type:`string`,reason:`text, the safe default`}}function Coe(e){return e.type===`set`||e.type===`extract`&&(e.kind!==`table`||e.many!==!0)}function woe(e){let t=new Set,n=e=>{let n=Array.isArray(e.from)?e.from:[e.from];for(let e of n)t.add(e.split(`.`,1)[0])};for(let r of Object.values(e))if(`each`in r){t.add(r.each);for(let e of Object.values(r.fields))n(e)}else n(r);return t}function Toe(e){return e.replace(/([a-z\d])([A-Z])/g,`$1 $2`).toLowerCase().split(/[^a-z\d]+/).filter(e=>e!==``)}function j9(e,t){let n=e.replace(/[^\w-]/g,`_`);w9.test(n)||(n=`field_${n}`);let r=n,i=2;for(;t.has(r);)r=`${n}${String(i)}`,i+=1;return r}function M9(e){if(typeof e!=`object`||!e)return[];let t=e.steps;return Array.isArray(t)?t:[]}function N9(e){return e.flatMap(e=>{if(typeof e!=`object`||!e)return[];let t=e,n=Array.isArray(t.else)?t.else:[];return[t,...N9(M9(t)),...N9(n)]})}function Eoe({inputRecipe:e,outputRecipe:t,records:n,rejected:r,onSaveInput:i,onSaveOutput:a,onSaveOutline:o,onExplainMissing:s,onExplainRejected:c}){let[l,u]=(0,P.useState)(),[d,f]=(0,P.useState)(),[p,m]=(0,P.useState)(),[h,g]=(0,P.useState)(),[_,v]=(0,P.useState)(0),[y,b]=(0,P.useState)(!1),[x,S]=(0,P.useState)(),C=G(e=>e.hoveredStepId),w=G(e=>e.setHoveredStepId),T=(0,P.useRef)(new Set);if((0,P.useEffect)(()=>{let n=t===void 0?void 0:JSON.parse(t.text),r=e===void 0?void 0:JSON.parse(e.text);m(n===void 0?void 0:JSON.stringify(n)),g(r===void 0?void 0:JSON.stringify(r));let i=T.current;if(n!==void 0&&r!==void 0&&i.size>0){T.current=new Set;let e=A9(r,n.fields,r.mapping).filter(e=>i.has(e.source)),t={...n.fields},a={...r.mapping};for(let n of e)t[n.name]=n.field,a[n.name]=n.rule;u({...n,fields:t}),f({...r,mapping:a})}else u(n),f(r);v(0)},[e?.file,e?.text,t?.file,t?.text]),e===void 0)return(0,F.jsx)(I,{p:4,color:`fg.muted`,children:(0,F.jsx)(V,{children:`Select a recipe to see its output fields.`})});if(t===void 0||l===void 0||d===void 0)return(0,F.jsx)(I,{p:4,color:`fg.muted`,children:(0,F.jsx)(V,{children:`This recipe names no output recipe found in this workspace.`})});let E=voe(d),D=A9(d,l.fields,d.mapping),O=n[_],k=JSON.stringify(l)!==p||JSON.stringify(d)!==h,A=(e,t)=>{let n={...l.fields};t===void 0?delete n[e]:n[e]=t,u({...l,fields:n})},ee=(e,t)=>{if(t===e||l.fields[t]!==void 0)return;let n={};for(let[r,i]of Object.entries(l.fields))n[r===e?t:r]=i;u({...l,fields:n});let r={...d.mapping};r[e]!==void 0&&(r[t]=r[e],delete r[e]),f({...d,mapping:r})},te=(e,t)=>{let n={...d.mapping};t===void 0?delete n[e]:n[e]=t,f({...d,mapping:n})},ne=e=>{let t={...l.fields},n={...d.mapping};for(let r of e)t[r.name]=r.field,n[r.name]=r.rule;u({...l,fields:t}),f({...d,mapping:n})},re=e=>{ne([xoe(e,d,l.fields,d.mapping)])},ie=()=>{let e=`field`,t=1;for(;l.fields[e]!==void 0;)e=`field${t}`,t+=1;A(e,{type:`string`})},ae=async()=>{b(!0),S(void 0);try{await a(t.file,l),await i(e.file,d)}catch(e){S(e instanceof Error?e.message:String(e))}finally{b(!1)}},oe=async t=>{let n=e.outline;if(o!==void 0&&n!==void 0){S(void 0);try{k&&await ae(),T.current=new Set(P9(t)),await o(e.file,{...n,steps:[...n.steps,{...t,path:`steps.${String(n.steps.length)}`}]})}catch(e){T.current=new Set,S(e instanceof Error?e.message:String(e))}}};return(0,F.jsxs)(rw,{h:`full`,p:2,gap:2,overflow:`auto`,children:[(0,F.jsxs)(W,{justify:`space-between`,wrap:`wrap`,children:[(0,F.jsxs)(W,{gap:3,fontSize:`xs`,color:`fg.muted`,children:[(0,F.jsxs)(W,{gap:1,children:[(0,F.jsx)(V,{children:`onMissing`}),(0,F.jsx)(Lw,{size:`xs`,width:`110px`,children:(0,F.jsxs)(zw,{value:l.onMissing??``,onChange:e=>{u({...l,onMissing:e.target.value===``?void 0:e.target.value})},children:[(0,F.jsx)(`option`,{value:``,children:`(fail/null)`}),C9.filter(e=>e!=="default").map(e=>(0,F.jsx)(`option`,{value:e,children:e},e))]})})]}),n.length>0&&(0,F.jsxs)(W,{gap:1,children:[(0,F.jsx)(V,{children:`record`}),(0,F.jsx)(Lw,{size:`xs`,width:`70px`,children:(0,F.jsx)(zw,{value:_,onChange:e=>{v(Number(e.target.value))},children:n.map((e,t)=>(0,F.jsxs)(`option`,{value:t,children:[`#`,t+1]},e.key??t))})})]})]}),(0,F.jsxs)(W,{children:[x!==void 0&&(0,F.jsx)(V,{color:`fg.error`,fontSize:`xs`,children:x}),(0,F.jsx)(UC,{size:`xs`,onClick:()=>{ae()},disabled:!k||y,loading:y,children:`Save`})]})]}),!b9(d.steps)&&(Object.keys(l.fields).length>0||D.length>0)&&(0,F.jsxs)(W,{role:`alert`,"data-testid":`missing-emit`,gap:2,p:2,borderWidth:`1px`,borderColor:`orange.300`,rounded:`md`,fontSize:`xs`,justify:`space-between`,children:[(0,F.jsx)(V,{children:`This recipe has no Emit step, so a run reads these values but returns no records.`}),(0,F.jsx)(UC,{size:`xs`,variant:`outline`,onClick:()=>{f({...d,steps:soe(d.steps)})},children:`Add Emit step`})]}),(0,F.jsx)(goe,{suggestions:D,onAdd:e=>{ne([e])},onAddAll:()=>{ne(D)}}),(0,F.jsxs)(_oe,{onPill:re,onCard:e=>{oe(e)},children:[Object.keys(l.fields).length===0&&D.length===0&&(0,F.jsx)(V,{fontSize:`xs`,color:`fg.muted`,p:2,children:`No output fields yet. Drag a pill from a Steps card, or a selection from the content pane, onto this list; or pick values and they show up above as proposals; or add a field by hand.`}),(0,F.jsx)(rw,{gap:2,children:Object.entries(l.fields).map(([e,t])=>(0,F.jsx)(F9,{name:e,field:t,target:e,input:d,record:O,rejected:r,scopeIds:E,hoveredStepId:C,onHoverStepId:w,setRule:te,onFieldChange:t=>{A(e,t)},onRename:t=>{ee(e,t)},onRemove:()=>{A(e,void 0)},onExplainMissing:s===void 0?void 0:()=>{s(_,e)},onExplainRejected:c===void 0?void 0:()=>{let t=r.findIndex(t=>t.field===e);t!==-1&&c(t)}},e))})]}),(0,F.jsx)(I,{flexShrink:0,children:(0,F.jsx)(UC,{size:`xs`,variant:`outline`,onClick:ie,children:`+ field`})})]})}function P9(e){let t=typeof e.step.id==`string`?[e.step.id]:[];return e.kind===`bracket`?[...t,...e.children.flatMap(e=>P9(e)),...(e.elseChildren??[]).flatMap(e=>P9(e))]:t}function F9({name:e,field:t,target:n,input:r,record:i,rejected:a,scopeIds:o,depth:s=0,hoveredStepId:c,onHoverStepId:l,setRule:u,onFieldChange:d,onRename:f,onRemove:p,onExplainMissing:m,onExplainRejected:h}){if(t.type===`object`&&t.fields!==void 0)return(0,F.jsxs)(rw,{gap:1,children:[(0,F.jsx)(T9,{name:e,field:t,scopeIds:o,depth:s,onFieldChange:d,onRename:f,onRemove:p,onRuleChange:()=>{}}),Object.entries(t.fields).map(([e,f])=>(0,F.jsx)(F9,{name:e,field:f,target:`${n}.${e}`,input:r,record:i,rejected:a,scopeIds:o,depth:s+1,hoveredStepId:c,onHoverStepId:l,setRule:u,onFieldChange:n=>{d({...t,fields:{...t.fields,[e]:n}})},onRename:n=>{let r={},i=Object.entries(t.fields??{});for(let[t,a]of i)r[t===e?n:t]=a;d({...t,fields:r})},onRemove:()=>{let n={...t.fields};delete n[e],d({...t,fields:n})}},e))]});if(t.type===`array`&&t.items?.type===`object`&&t.items.fields!==void 0){let i=r.mapping[n],a=S9(i)?i:void 0,f=t.items,p=f.fields;return(0,F.jsxs)(rw,{gap:1,borderWidth:`1px`,borderRadius:`md`,p:2,ml:s*5,children:[(0,F.jsxs)(W,{gap:2,children:[(0,F.jsx)(V,{fontWeight:`medium`,fontSize:`sm`,children:e}),(0,F.jsx)(V,{fontSize:`xs`,color:`fg.muted`,children:`each`}),(0,F.jsx)(Dw,{size:`xs`,width:`140px`,placeholder:`list id (e.g. items)`,value:a?.each??``,onChange:e=>{u(n,e.target.value===``?void 0:{each:e.target.value,fields:a?.fields??{}})}})]}),Object.entries(p).map(([e,r])=>{let i=a?.fields[e],m=typeof i?.from==`string`?i.from:void 0;return(0,F.jsx)(T9,{name:e,field:r,rule:i,scopeIds:o,depth:s+1,stepId:m,highlighted:m!==void 0&&m===c,onHoverStepId:l,onFieldChange:n=>{d({...t,items:{...f,fields:{...p,[e]:n}}})},onRename:n=>{let r={};for(let[t,i]of Object.entries(p))r[t===e?n:t]=i;d({...t,items:{...f,fields:r}})},onRemove:()=>{let n={...p};delete n[e],d({...t,items:{...f,fields:n}})},onRuleChange:t=>{let r={...a?.fields};t===void 0?delete r[e]:r[e]=t,u(n,{each:a?.each??``,fields:r})}},e)})]})}let g=r.mapping[n],_=g===void 0||S9(g)?void 0:g,v=i?.data[e],y=i?.mapping?.[n],b=a.filter(e=>e.field===n),x=typeof _?.from==`string`?_.from:void 0;return(0,F.jsx)(T9,{name:e,field:t,rule:_,scopeIds:o,trace:y,value:v,missing:v===null,rejected:b.length===0?void 0:{count:b.length,reason:b[b.length-1].reason},depth:s,stepId:x,highlighted:x!==void 0&&x===c,onHoverStepId:l,onFieldChange:d,onRename:f,onRemove:p,onRuleChange:e=>{u(n,e)},onExplainMissing:m,onExplainRejected:h})}function I9(e){if(e.trim()===``)return{ok:!1};try{return{ok:!0,value:JSON.parse(e)}}catch{return{ok:!1}}}function Doe(e){let t={};for(let[n,r]of Object.entries(e)){if(!r.enabled)continue;let e=I9(r.text);e.ok&&(t[n]=e.value)}return Object.keys(t).length===0?void 0:t}var L9=ZE(e=>({entries:{},setEnabled:(t,n)=>{e(e=>({entries:{...e.entries,[t]:{text:e.entries[t]?.text??`null`,enabled:n}}}))},setText:(t,n)=>{e(e=>({entries:{...e.entries,[t]:{enabled:e.entries[t]?.enabled??!1,text:n}}}))}})),Ooe={hook:`hook`,captcha:`captcha solver`,access:`access plugin`};function koe({remote:e}){let t=L9(e=>e.entries),n=L9(e=>e.setEnabled),r=L9(e=>e.setText);return e.length===0?null:(0,F.jsxs)(rw,{gap:1,mt:1,"data-testid":`hook-stubs`,children:[(0,F.jsx)(V,{fontSize:`xs`,children:`These call outside this machine: a sample run waits for them, and they may cost.`}),e.map(e=>{let i=t[e.name],a=e.kind===`hook`,o=i?.text??`null`,s=i?.enabled??!1,c=I9(o).ok;return(0,F.jsxs)(W,{gap:2,wrap:`wrap`,"data-testid":`remote-${e.name}`,children:[(0,F.jsx)(V,{fontSize:`xs`,children:`${Ooe[e.kind]} ${e.name} → ${e.label}`}),a&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(JC,{size:`xs`,checked:s,onCheckedChange:t=>{n(e.name,t.checked===!0)},children:[(0,F.jsx)(QC,{}),(0,F.jsx)(ZC,{}),(0,F.jsx)(YC,{children:`stub ${e.name}`})]}),(0,F.jsx)(Dw,{size:`xs`,width:`220px`,fontFamily:`mono`,"aria-label":`stub value of ${e.name}`,"aria-invalid":!c,value:o,onChange:t=>{r(e.name,t.target.value)}}),!c&&(0,F.jsx)(V,{fontSize:`xs`,color:`red.fg`,children:`not JSON: the hook is called`})]})]},`${e.kind}:${e.name}`)})]})}var Aoe=/^[a-z0-9][a-z0-9-]*$/,joe=`https://example.com`;function R9(e){if(e.trim()!==``)try{let{protocol:t}=new URL(e.trim());return t===`http:`||t===`https:`?void 0:`use an http:// or https:// address`}catch{return`use a full address, like https://example.com/books`}}function z9(e,t,n=joe){return B9(e,t,{mode:`web`,start:[{url:n}],steps:[{type:`goto`,url:`{{start.url}}`},{type:`emit`}]})}function Moe(e,t,n,r){return B9(e,t,{mode:`api`,start:[{url:n}],steps:[{type:`request`,id:`doc`,url:`{{start.url}}`,as:r}]})}function Noe(e,t,n){return B9(e,t,{mode:`api`,start:[{url:n}],steps:[{type:`request`,id:`doc`,url:`{{start.url}}`}]})}function B9(e,t,n){let r=e.endsWith(`/`)?e.slice(0,-1):e;return{outputPath:`${r}/${t}.ocw-out.json`,output:{kind:`output`,id:t,version:1,fields:{}},inputPath:`${r}/${t}.ocw-in.json`,input:{kind:`input`,id:t,output:t,...n,mapping:{}}}}function V9(e){let t=e.replace(/\.[^.]+$/,``).toLowerCase().split(/[^a-z0-9]+/).filter(e=>e!==``).join(`-`);return t===``?`document`:t}var Poe=new Set([`www`,`en`,`uk`,`com`,`co`,`org`,`net`,`gov`,`edu`,`io`,`eu`,`us`,`de`,`fr`,`es`,`it`,`nl`,`info`,`app`,`dev`]);function Foe(e){let t;try{t=new URL(e)}catch{return`document`}let n=t.hostname.split(`.`).filter(e=>!Poe.has(e)).slice(0,2),r=t.pathname.split(`/`).filter(e=>e!==``).map(e=>e.replace(/\.[^.]+$/,``)),i=r.length===0?void 0:r[r.length-1],a=r.length<2?void 0:r[r.length-2],o=i===void 0?[]:a!==void 0&&/^\d+$/.test(i)?[a,i]:[i];return V9([...n,...o].join(` `)).slice(0,48).replace(/-$/,``)}function H9(e,t){let n=new Set(t);if(!n.has(e))return e;for(let t=2;;t+=1)if(!n.has(`${e}-${t}`))return`${e}-${t}`}function Ioe({folder:e,open:t,onClose:n,onCreated:r}){let[i,a]=(0,P.useState)(``),[o,s]=(0,P.useState)(``),[c,l]=(0,P.useState)(),u=tO(),d=i.length===0?void 0:U9(i),f=R9(o);function p(){n(),a(``),s(``),l(void 0)}async function m(){if(e===void 0||U9(i)!==void 0||R9(o)!==void 0)return;l(void 0);let t=z9(e,i,o.trim()===``?void 0:o.trim());try{await u.mutateAsync({path:t.outputPath,recipe:t.output}),await u.mutateAsync({path:t.inputPath,recipe:t.input}),r(i),p()}catch(e){l(e instanceof Error?e.message:String(e))}}return(0,F.jsx)(ow,{open:t,onOpenChange:e=>{e.open||p()},children:(0,F.jsxs)(g_,{children:[(0,F.jsx)(dw,{}),(0,F.jsx)(sw,{children:(0,F.jsxs)(cw,{children:[(0,F.jsxs)(pw,{display:`flex`,flexDirection:`row`,alignItems:`center`,justifyContent:`space-between`,children:[(0,F.jsx)(lw,{children:`New recipe`}),(0,F.jsx)(uw,{asChild:!0,children:(0,F.jsx)(ew,{size:`sm`,"aria-label":`Close`})})]}),(0,F.jsxs)(fw,{display:`flex`,flexDirection:`column`,gap:3,pb:4,children:[(0,F.jsxs)(xw,{invalid:d!==void 0,children:[(0,F.jsx)(Sw,{children:`Recipe id`}),(0,F.jsx)(Dw,{size:`sm`,placeholder:`books`,value:i,onChange:e=>{a(e.target.value)},onKeyDown:e=>{e.key===`Enter`&&m()}}),d!==void 0&&(0,F.jsx)(ww,{children:d})]}),(0,F.jsxs)(xw,{invalid:f!==void 0,children:[(0,F.jsx)(Sw,{children:`Start URL (optional)`}),(0,F.jsx)(Dw,{size:`sm`,placeholder:`https://example.com/books`,value:o,onChange:e=>{s(e.target.value)},onKeyDown:e=>{e.key===`Enter`&&m()}}),f!==void 0&&(0,F.jsx)(ww,{children:f})]}),(0,F.jsxs)(V,{fontSize:`xs`,color:`fg.muted`,children:[`Writes `,(0,F.jsxs)(V,{as:`span`,fontFamily:`mono`,children:[i||`<id>`,`.ocw-in.json`]}),` and`,` `,(0,F.jsxs)(V,{as:`span`,fontFamily:`mono`,children:[i||`<id>`,`.ocw-out.json`]})," into the open folder: a `web` recipe with one page and no fields mapped yet, ready to build out in the Steps tab."]}),c!==void 0&&(0,F.jsx)(V,{color:`fg.error`,fontSize:`sm`,children:c}),(0,F.jsx)(UC,{size:`sm`,colorPalette:`brand`,alignSelf:`flex-end`,onClick:()=>{m()},disabled:e===void 0||i.length===0||d!==void 0||f!==void 0||u.isPending,loading:u.isPending,children:`Create`})]})]})})]})})}function U9(e){return Aoe.test(e)?void 0:`lowercase letters, digits and hyphens, starting with a letter or digit`}function W9(e){return[...e.dataTransfer.types].includes(`Files`)}function Loe(e){W9(e)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)}function Roe({onFile:e,children:t,...n}){let[r,i]=(0,P.useState)(0),a=r>0;function o(e){W9(e)&&(e.preventDefault(),i(e=>e+1))}function s(e){W9(e)&&i(e=>Math.max(0,e-1))}function c(t){if(!W9(t))return;t.preventDefault(),i(0);let n=t.dataTransfer.files[0];n!==void 0&&e(n)}return(0,F.jsxs)(I,{position:`relative`,"data-testid":`document-drop-zone`,onDragEnter:o,onDragOver:Loe,onDragLeave:s,onDrop:c,...n,children:[t,a&&(0,F.jsx)(I,{role:`status`,position:`absolute`,inset:0,zIndex:`overlay`,display:`flex`,alignItems:`center`,justifyContent:`center`,bg:`brand.subtle/80`,borderWidth:`3px`,borderStyle:`dashed`,borderColor:`brand.solid`,pointerEvents:`none`,children:(0,F.jsx)(V,{fontSize:`lg`,fontWeight:`semibold`,color:`brand.fg`,children:`Drop to load this file`})})]})}function G9(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function zoe(e){let t=Array.isArray(e.steps)?e.steps[0]:void 0;return e.mode===`api`&&G9(t)&&t.type===`request`&&t.url===`{{start.url}}`}function Boe(e,t){if(!G9(e)||e.kind!==`input`||!Array.isArray(e.start))return{kind:`new`};let[n,...r]=e.start;if(!G9(n)||!(t.kind===`document`?zoe(e):e.mode===`web`))return{kind:`new`};let i=typeof n.url==`string`?n.url:void 0;return{kind:`replace`,recipe:{...e,start:[{...n,url:t.url},...r]},previous:i}}function Voe(e){if(e!==void 0)try{return JSON.parse(e)}catch{return}}function K9(e,t){return e.kind===`document`?t:e.url}function q9(){let e=ET(),t=tO();return async(n,r,i)=>{let{openFolder:a,selectedRecipeId:o}=G.getState(),s=a===void 0?void 0:e.getQueryData(VD(a))?.recipes.find(e=>e.id===o),c=Boe(Voe(s?.text),n);if(XD(),s!==void 0&&c.kind===`replace`)return await t.mutateAsync({path:s.file,recipe:c.recipe}),`Loaded ${K9(n,r)} into “${s.id??s.file}”${c.previous===void 0?``:`, replacing ${c.previous}`}.`;if(await i(),s!==void 0)return`“${s.id??s.file}” reads ${n.kind===`document`?`a web page`:`a document`}, so ${K9(n,r)} started a new recipe instead. “${s.id??s.file}” is unchanged.`}}var Hoe={ods:{what:`an OpenDocument spreadsheet`,instead:`Open it in Excel or LibreOffice, save it as .xlsx or .csv, and load that file.`},odt:{what:`an OpenDocument text document`,instead:`Open it in Word or LibreOffice, save it as .docx or .pdf, and load that file.`},odp:{what:`an OpenDocument presentation`,instead:`Open it in PowerPoint or LibreOffice, save it as .pptx or .pdf, and load that file.`},rtf:{what:`a Rich Text document`,instead:`Open it in Word, save it as .docx or .pdf, and load that file.`},pages:{what:`an Apple Pages document`,instead:`Export it from Pages as .pdf or .docx, and load that file.`},numbers:{what:`an Apple Numbers spreadsheet`,instead:`Export it from Numbers as .xlsx or .csv, and load that file.`},key:{what:`an Apple Keynote presentation`,instead:`Export it from Keynote as .pptx or .pdf, and load that file.`},zip:{what:`a compressed archive`,instead:`Unpack it and load the file you want from inside.`},rar:{what:`a compressed archive`,instead:`Unpack it and load the file you want from inside.`},"7z":{what:`a compressed archive`,instead:`Unpack it and load the file you want from inside.`},png:{what:`a picture`,instead:`The Studio reads text, tables and data, not pictures. If it is a scan, use the text version of the document.`},jpg:{what:`a picture`,instead:`The Studio reads text, tables and data, not pictures. If it is a scan, use the text version of the document.`},jpeg:{what:`a picture`,instead:`The Studio reads text, tables and data, not pictures. If it is a scan, use the text version of the document.`},gif:{what:`a picture`,instead:`The Studio reads text, tables and data, not pictures.`}};function J9(e){let t=/\.([a-z0-9]+)$/i.exec(e.split(/[?#]/,1)[0])?.[1]?.toLowerCase(),n=t===void 0?void 0:Hoe[t];if(n!==void 0)return`“${e.split(/[\\/]/).pop()??e}” is ${n.what}, which the Studio cannot read yet. ${n.instead}`}function Y9(){let e=BD(),t=tO(),n=G(e=>e.commitFolder),r=G(e=>e.selectRecipe);return async(i,a,o)=>{let s=(await e.openWorkspace(i)).recipes.map(e=>e.id).filter(e=>e!==void 0),c=H9(V9(a),s),l=Noe(i,c,o);await t.mutateAsync({path:l.outputPath,recipe:l.output}),await t.mutateAsync({path:l.inputPath,recipe:l.input}),G.getState().openFolder!==i&&n(i),r(c)}}function Uoe(){let e=rO(),t=Y9(),n=q9(),r=G(e=>e.folder),i=G(e=>e.openFolder),[a,o]=(0,P.useState)(),[s,c]=(0,P.useState)(!1),[l,u]=(0,P.useState)();async function d(a){let s=(i??r).trim();if(s===``){o(`Type a workspace folder in the toolbar first, then drop the file again: that is where the copy and the recipe go.`);return}let l=J9(a.name);if(l!==void 0){o(l);return}o(void 0),u(void 0),c(!0);try{let{url:r}=await e.mutateAsync({folder:s,name:a.name,bytes:await Woe(a)});u(await n({kind:`document`,url:r},a.name,async()=>{await t(s,a.name,r)}))}catch(e){o(e instanceof Error?e.message:String(e))}finally{c(!1)}}return{importFile:d,pending:s,error:a,notice:l}}function Woe(e){return new Promise((t,n)=>{let r=new FileReader;r.addEventListener(`error`,()=>{n(r.error??Error(`could not read ${e.name}`))}),r.addEventListener(`load`,()=>{let e=String(r.result);t(e.slice(e.indexOf(`,`)+1))}),r.readAsDataURL(e)})}function Goe(e){return e.slice(Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`))+1)}function X9(){let e=BD(),t=G(e=>e.commitFolder),n=G(e=>e.selectRecipe),r=Y9();return(0,P.useCallback)(async(i,a)=>{let o=await e.openPath(i,a);o.kind===`document`?await r(o.folder,Goe(o.path),o.url):(t(o.folder),o.kind===`recipe`&&o.recipeId!==void 0&&n(o.recipeId))},[e,t,n,r])}function Koe(){let e=BD(),t=X9(),[n,r]=(0,P.useState)();return(0,P.useEffect)(()=>{let n=e.initialOpen;if(n===void 0)return;let i=()=>{let e=new URLSearchParams(globalThis.location.search);e.delete(`open`),globalThis.history.replaceState({},``,`${globalThis.location.pathname}?${e.toString()}`)};(async()=>{try{await t(n,e.initialFolder)}catch(e){r(e instanceof Error?e.message:String(e))}finally{i()}})()},[]),n}function qoe(e){return e instanceof Error?e.message:String(e)}function Joe(){let e=BD(),t=X9(),n=G(e=>e.selectRecipe),r=ZD(e=>e.askPick),[i,a]=(0,P.useState)();return(0,P.useEffect)(()=>e.subscribe(i=>{if(i.type!==`ui-request`)return;let{requestId:o,request:s}=i;if(a(void 0),s.kind===`pick`){n(s.recipeId),r({requestId:o,recipeId:s.recipeId,selector:s.selector,text:s.text,add:s.add});return}(async()=>{let n=!0,r=`Opened ${s.path}.`;try{await t(s.path,s.workspace)}catch(e){n=!1,r=qoe(e),a(r)}try{await e.reportUiOutcome(o,n,r)}catch{}})()}),[e,t,n,r]),i}function Yoe({open:e,onClose:t,onLoad:n}){let[r,i]=(0,P.useState)(``),a=r.trim()===``?void 0:R9(r),o=r.trim()!==``&&a===void 0;function s(){i(``),t()}function c(){o&&(n(r.trim()),s())}return(0,F.jsx)(ow,{open:e,onOpenChange:e=>{e.open||s()},children:(0,F.jsxs)(g_,{children:[(0,F.jsx)(dw,{}),(0,F.jsx)(sw,{children:(0,F.jsxs)(cw,{children:[(0,F.jsxs)(pw,{display:`flex`,flexDirection:`row`,alignItems:`center`,justifyContent:`space-between`,children:[(0,F.jsx)(lw,{children:`Load a web page`}),(0,F.jsx)(uw,{asChild:!0,children:(0,F.jsx)(ew,{size:`sm`,"aria-label":`Close`})})]}),(0,F.jsxs)(fw,{display:`flex`,flexDirection:`column`,gap:3,pb:4,children:[(0,F.jsxs)(xw,{invalid:a!==void 0,children:[(0,F.jsx)(Sw,{children:`Page address`}),(0,F.jsx)(Dw,{size:`sm`,placeholder:`https://example.com/books`,value:r,onChange:e=>{i(e.target.value)},onKeyDown:e=>{e.key===`Enter`&&c()}}),a!==void 0&&(0,F.jsx)(ww,{children:a}),(0,F.jsx)(Cw,{children:`Becomes the open recipe's start page, or a new recipe when none reads a web page.`})]}),(0,F.jsx)(UC,{size:`sm`,colorPalette:`brand`,alignSelf:`flex-end`,disabled:!o,onClick:c,children:`Load`})]})]})})]})})}function Xoe(){let e=BD(),t=tO(),n=q9(),r=G(e=>e.folder),i=G(e=>e.openFolder),a=G(e=>e.commitFolder),o=G(e=>e.selectRecipe),[s,c]=(0,P.useState)(!1),[l,u]=(0,P.useState)(),[d,f]=(0,P.useState)();async function p(n,r){let i=(await e.openWorkspace(n)).recipes.map(e=>e.id).filter(e=>e!==void 0),{kind:s}=await e.detectUrl(r),c=H9(Foe(r),i),l=s===`html`||s===`unknown`?z9(n,c,r):Moe(n,c,r,s);await t.mutateAsync({path:l.outputPath,recipe:l.output}),await t.mutateAsync({path:l.inputPath,recipe:l.input}),G.getState().openFolder!==n&&a(n),o(c)}async function m(e){let t=(i??r).trim();if(t===``){u(`Open a workspace folder first (Recipe ▾ → Open folder…): that is where the recipe is written.`);return}let a=J9(e.trim());if(a!==void 0){u(a);return}u(void 0),f(void 0),c(!0);try{let r=e.trim();f(await n({kind:`url`,url:r},r,async()=>{await p(t,r)}))}catch(e){u(e instanceof Error?e.message:String(e))}finally{c(!1)}}return{loadUrl:m,pending:s,error:l,notice:d}}function Zoe(){let e=globalThis.opencrawDesktop;return typeof e?.chooseFolder==`function`?{chooseFolder:e.chooseFolder}:void 0}function Qoe({hooks:e}){return e===void 0?null:(0,F.jsxs)(I,{px:4,py:1,bg:`orange.subtle`,color:`orange.fg`,fontSize:`sm`,"data-testid":`hooks-bar`,children:[`Hooks loaded from ${e.source} (runs as your code): ${e.names.length===0?`none exported`:e.names.join(`, `)}`,e.remote!==void 0&&(0,F.jsx)(koe,{remote:e.remote})]})}function $oe(){let e=BD(),t=G(e=>e.commitFolder),[n,r]=(0,P.useState)(!1),[i,a]=(0,P.useState)();async function o(){a(void 0),r(!0);try{let n=await e.chooseFolder();return n===void 0?`cancelled`:(t(n),`picked`)}catch(e){return a(e instanceof Error?e.message:String(e)),`unavailable`}finally{r(!1)}}return{browse:o,pending:n,error:i}}function Z9({label:e,title:t,disabled:n,loading:r,items:i}){let[a,o]=(0,P.useState)(!1),s=(0,P.useRef)(null);return(0,P.useEffect)(()=>{if(!a)return;let e=e=>{if(e instanceof KeyboardEvent){e.key===`Escape`&&o(!1);return}s.current!==null&&!s.current.contains(e.target)&&o(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,e)}},[a]),(0,F.jsxs)(I,{ref:s,position:`relative`,flexShrink:0,children:[(0,F.jsx)(UC,{size:`sm`,variant:`outline`,maxW:`16em`,title:t,disabled:n,loading:r,"aria-haspopup":`menu`,"aria-expanded":a,onClick:()=>{o(e=>!e)},children:(0,F.jsx)(I,{as:`span`,display:`block`,truncate:!0,maxW:`15em`,title:e,children:e})}),a&&(0,F.jsx)(I,{role:`menu`,position:`absolute`,top:`100%`,left:0,mt:1,zIndex:`dropdown`,minW:`14em`,py:1,bg:`bg`,borderWidth:`1px`,borderRadius:`md`,boxShadow:`md`,children:i.map(e=>(0,F.jsxs)(I,{children:[e.divider===!0&&(0,F.jsx)(I,{borderTopWidth:`1px`,my:1}),e.heading!==void 0&&(0,F.jsx)(I,{px:3,py:1,fontSize:`xs`,color:`fg.muted`,children:e.heading}),(0,F.jsx)(I,{as:`button`,role:`menuitem`,display:`block`,w:`full`,textAlign:`left`,px:3,py:1,fontSize:`sm`,cursor:e.disabled===!0?`not-allowed`:`pointer`,opacity:e.disabled===!0?.5:1,_hover:e.disabled===!0?void 0:{bg:`bg.muted`},"aria-disabled":e.disabled===!0,onClick:()=>{e.disabled!==!0&&(o(!1),e.onSelect())},children:e.label})]},e.label))})]})}function ese({loading:e,onLoadDocument:t,onLoadUrl:n}){return(0,F.jsx)(Z9,{label:`Load ▾`,title:`Bring in the document or page the recipe reads (a file can also be dropped anywhere)`,disabled:e,loading:e,items:[{label:`Document…`,onSelect:t},{label:`Web page (URL)…`,onSelect:n}]})}function tse({open:e,onClose:t,folder:n,onFolderChange:r,onOpen:i,onBrowse:a,browsing:o}){function s(){n.trim()!==``&&(i(),t())}return(0,F.jsx)(ow,{open:e,onOpenChange:e=>{e.open||t()},children:(0,F.jsxs)(g_,{children:[(0,F.jsx)(dw,{}),(0,F.jsx)(sw,{children:(0,F.jsxs)(cw,{children:[(0,F.jsxs)(pw,{display:`flex`,flexDirection:`row`,alignItems:`center`,justifyContent:`space-between`,children:[(0,F.jsx)(lw,{children:`Open folder`}),(0,F.jsx)(uw,{asChild:!0,children:(0,F.jsx)(ew,{size:`sm`,"aria-label":`Close`})})]}),(0,F.jsxs)(fw,{display:`flex`,flexDirection:`column`,gap:3,pb:4,children:[(0,F.jsx)(Dw,{size:`sm`,placeholder:`recipe folder`,value:n,onChange:e=>{r(e.target.value)},onKeyDown:e=>{e.key===`Enter`&&s()}}),(0,F.jsxs)(V,{fontSize:`xs`,color:`fg.muted`,children:[`A folder of `,(0,F.jsx)(V,{as:`span`,fontFamily:`mono`,children:`.ocw-in.json`}),` and `,(0,F.jsx)(V,{as:`span`,fontFamily:`mono`,children:`.ocw-out.json`}),` recipes, or an empty one to start in.`]}),(0,F.jsxs)(W,{justifyContent:`flex-end`,children:[a!==void 0&&(0,F.jsx)(UC,{size:`sm`,variant:`outline`,onClick:a,disabled:o,loading:o,title:`Pick the folder in the operating system dialog`,children:`Browse…`}),(0,F.jsx)(UC,{size:`sm`,colorPalette:`brand`,onClick:s,disabled:n.trim()===``,children:`Open`})]})]})]})})]})})}function nse({inputs:e,selectedRecipeId:t,hasFolder:n,onSelectRecipe:r,onNewRecipe:i,onOpenFolder:a}){let o=e.length===0?[{label:n?`No recipes in this folder`:`Open a folder first`,onSelect:()=>{},disabled:!0,heading:`Open recipe`}]:e.map((e,n)=>{let i=e.id??e.file;return{label:i===t?`✓ ${i}`:i,onSelect:()=>{r(i)},...n===0&&{heading:`Open recipe`}}});return(0,F.jsx)(Z9,{label:t===void 0?`Recipe ▾`:`Recipe: ${t} ▾`,title:`Open, create or switch the recipe being edited`,items:[...o,{label:`New recipe…`,onSelect:i,disabled:!n,divider:!0},{label:`Open folder…`,onSelect:a}]})}function rse(){let e=mte()>0;return(0,F.jsx)(V,{role:`status`,fontSize:`sm`,color:`fg.muted`,flexShrink:0,children:e?`Saving…`:`All changes saved`})}var ise=`.pdf,.xlsx,.xlsm,.xls,.csv,.tsv,.pptx,.docx,.md,.markdown,.html,.htm,.json,.jsonl,.yaml,.yml,.xml`;function ase(e){return/[^/\\]+(?=[/\\]*$)/u.exec(e)?.[0]??``}function ose({folder:e,onFolderChange:t,onOpen:n,onChooseFolder:r,onBrowse:i,browsing:a,openFolder:o,inputs:s,selectedRecipeId:c,onSelectRecipe:l,onRecipeCreated:u,onImportFile:d,onLoadUrl:f,importing:p,running:m,onRunSample:h,onStop:g,onClear:_}){let v=(0,P.useRef)(null),[y,b]=(0,P.useState)(!1),[x,S]=(0,P.useState)(!1),[C,w]=(0,P.useState)(!1);return(0,F.jsxs)(W,{gap:2,p:2,borderBottomWidth:`1px`,wrap:`wrap`,children:[(0,F.jsx)(_te,{}),(0,F.jsx)(nse,{inputs:s,selectedRecipeId:c,hasFolder:o!==void 0,onSelectRecipe:l,onNewRecipe:()=>{b(!0)},onOpenFolder:()=>{r===void 0?i===void 0?w(!0):i().then(e=>{e===`unavailable`&&w(!0)}):r()}}),(0,F.jsx)(ese,{loading:p,onLoadDocument:()=>{v.current?.click()},onLoadUrl:()=>{S(!0)}}),(0,F.jsx)(`input`,{ref:v,type:`file`,accept:ise,"aria-label":`Load document`,hidden:!0,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t!==void 0&&d(t)}}),o!==void 0&&(0,F.jsx)(V,{fontSize:`sm`,color:`fg.muted`,truncate:!0,maxW:`14em`,title:o,children:ase(o)}),(0,F.jsx)(rse,{}),(0,F.jsxs)(W,{gap:2,flexShrink:0,ml:`auto`,children:[(0,F.jsx)(Tte,{}),(0,F.jsx)(UC,{size:`sm`,colorPalette:`brand`,onClick:h,disabled:c===void 0||m,loading:m,children:`Run sample`}),(0,F.jsx)(UC,{size:`sm`,variant:`outline`,onClick:g,disabled:!m,children:`Stop`}),(0,F.jsx)(UC,{size:`sm`,variant:`ghost`,onClick:_,disabled:m,title:`Clear the records, trace and selection left from the last source`,children:`Clear`})]}),(0,F.jsx)(Ioe,{folder:o,open:y,onClose:()=>{b(!1)},onCreated:u}),(0,F.jsx)(Yoe,{open:x,onClose:()=>{S(!1)},onLoad:f}),(0,F.jsx)(tse,{open:C,onClose:()=>{w(!1)},folder:e,onFolderChange:t,onOpen:n,onBrowse:i===void 0?void 0:()=>{i()},browsing:a})]})}var sse=8e3;function cse(){let[e]=(0,P.useState)(()=>Vte());return(0,F.jsx)(DT,{client:e,children:(0,F.jsx)(nn,{value:gte,children:(0,F.jsx)(lse,{})})})}function lse(){let e=BD();Wte(),Cte();let t=G(e=>e.folder),n=G(e=>e.openFolder),r=G(e=>e.selectedRecipeId),i=G(e=>e.editorTab),a=G(e=>e.setFolder),o=G(e=>e.commitFolder),s=G(e=>e.selectRecipe),c=G(e=>e.setEditorTab),l=G(e=>e.hoveredStepId),u=G(e=>e.setHoveredStepId),[d,f]=(0,P.useState)([70,30]),[p,m]=(0,P.useState)([50,50]),h=HD(n),g=$D(),_=QD(),v=YD(e=>e.running),y=YD(e=>e.error),b=Hte(),x=L9(e=>e.entries),S=Ute(),C=tO(),w=iO(),T=Jte(),E=Uoe(),D=Xoe(),O=$oe(),k=Koe(),A=Joe();(0,P.useEffect)(()=>{e.initialFolder!==void 0&&o(e.initialFolder)},[]),(0,P.useEffect)(()=>{if(r!==void 0||h.data===void 0)return;let e=h.data.recipes.find(e=>e.kind===`input`);e?.id!==void 0&&s(e.id)},[h.data,r,s]);let ee=(0,P.useMemo)(()=>{if(_!==void 0&&_.kind===`input`)try{let e=JSON.parse(_.text).output;return h.data?.recipes.find(t=>t.kind===`output`&&t.id===e)}catch{return}},[_,h.data]),te=(0,P.useMemo)(()=>{if(_===void 0||_.kind!==`input`)return{};try{let e=JSON.parse(_.text).mapping;return e===void 0?{}:loe(e)}catch{return{}}},[_]),ne=Object.keys(te).find(e=>te[e]===l&&l!==void 0),re=(0,P.useMemo)(()=>Zoe(),[]),ie=re===void 0?void 0:()=>{re.chooseFolder()},ae=e=>{T.mutate(e)},oe=k??A??E.error??D.error??O.error??Q9(h.error)??(y===void 0?void 0:FD(y)),se=E.notice??D.notice,[ce,j]=(0,P.useState)();(0,P.useEffect)(()=>{if(se===void 0)return;let e=setTimeout(()=>{j(se)},sse);return()=>{clearTimeout(e)}},[se]);let le=se===ce?void 0:se;return(0,F.jsx)(vk.Provider,{value:h.data?.hooks?.names,children:(0,F.jsxs)(Roe,{onFile:e=>{E.importFile(e)},h:`100vh`,display:`flex`,flexDirection:`column`,children:[(0,F.jsx)(ose,{folder:t,onFolderChange:a,onOpen:()=>{o(t)},onChooseFolder:ie,onBrowse:O.browse,browsing:O.pending,openFolder:n,inputs:g,selectedRecipeId:r,onSelectRecipe:s,onRecipeCreated:s,onImportFile:e=>{E.importFile(e)},onLoadUrl:e=>{D.loadUrl(e)},importing:E.pending||D.pending,running:v,onRunSample:()=>{r!==void 0&&b.mutate({recipeId:r,stubs:Doe(x)})},onStop:()=>{S.mutate()},onClear:()=>{XD(),T.reset()}}),(0,F.jsx)(Qoe,{hooks:h.data?.hooks}),le!==void 0&&oe===void 0&&(0,F.jsx)(I,{role:`status`,px:4,py:1,bg:`brand.subtle`,color:`brand.fg`,fontSize:`sm`,children:le}),oe!==void 0&&(0,F.jsx)(I,{px:4,py:1,bg:`red.subtle`,color:`red.fg`,fontSize:`sm`,children:oe}),(0,F.jsxs)(Qw,{orientation:`vertical`,panels:[{id:`workspace`,minSize:20},{id:`preview`,minSize:10}],size:d,onResize:e=>{f(e.size)},flex:`1`,minH:`0`,children:[(0,F.jsx)($w,{id:`workspace`,overflow:`hidden`,children:(0,F.jsxs)(Qw,{panels:[{id:`content`,minSize:20},{id:`editor`,minSize:20}],size:p,onResize:e=>{m(e.size)},h:`full`,children:[(0,F.jsx)($w,{id:`content`,overflow:`auto`,children:(0,F.jsx)(QG,{recipe:_,onSaveOutline:async(e,t)=>{await w.mutateAsync({path:e,outline:t})},onSaveRecipe:async(e,t)=>{await C.mutateAsync({path:e,recipe:t})}})}),(0,F.jsx)(nT,{id:`content:editor`}),(0,F.jsxs)($w,{id:`editor`,overflow:`hidden`,display:`flex`,flexDirection:`column`,children:[(0,F.jsxs)(W,{gap:1,px:2,pt:2,borderBottomWidth:`1px`,flexShrink:0,children:[(0,F.jsx)($9,{label:`Steps`,active:i===`steps`,onClick:()=>{c(`steps`)}}),(0,F.jsx)($9,{label:`Record`,active:i===`record`,onClick:()=>{c(`record`)},switchOnDrag:!0}),(0,F.jsx)($9,{label:`JSON`,active:i===`json`,onClick:()=>{c(`json`)}}),i===`steps`&&(0,F.jsx)(I,{ml:`auto`,pb:1,children:(0,F.jsx)(kte,{})})]}),(0,F.jsxs)(I,{flex:`1`,minH:`0`,overflow:`auto`,children:[i===`steps`&&(0,F.jsx)(UV,{recipe:_,onSaveOutline:async(e,t)=>{await w.mutateAsync({path:e,outline:t})}}),i===`record`&&(0,F.jsx)(use,{inputRecipe:_,outputRecipe:ee,onSaveInput:async(e,t)=>{await C.mutateAsync({path:e,recipe:t})},onSaveOutput:async(e,t)=>{await C.mutateAsync({path:e,recipe:t})},onSaveOutline:async(e,t)=>{await w.mutateAsync({path:e,outline:t})},onExplainMissing:r===void 0?void 0:(e,t)=>{ae({kind:`missing`,recipeId:r,recordIndex:e,field:t})},onExplainRejected:r===void 0?void 0:e=>{ae({kind:`rejected`,recipeId:r,rejectedIndex:e})}}),i===`json`&&(0,F.jsx)(Hae,{recipe:_,onSave:async(e,t)=>{await C.mutateAsync({path:e,recipe:t})}})]})]})]})}),(0,F.jsx)(nT,{id:`workspace:preview`}),(0,F.jsx)($w,{id:`preview`,overflow:`hidden`,borderTopWidth:`1px`,children:(0,F.jsx)(dse,{onExplainMissing:r===void 0?void 0:(e,t)=>{ae({kind:`missing`,recipeId:r,recordIndex:e,field:t})},onExplainRejected:r===void 0?void 0:e=>{ae({kind:`rejected`,recipeId:r,rejectedIndex:e})},whyLoading:T.isPending,whyView:T.data,whyError:Q9(T.error),highlightedField:ne,onHoverField:e=>{u(e===void 0?void 0:te[e])}})})]})]})})}function use(e){let t=YD(e=>e.records),n=YD(e=>e.rejected);return(0,F.jsx)(Eoe,{...e,records:t,rejected:n})}function dse(e){let t=YD(e=>e.records),n=YD(e=>e.rejected),r=YD(e=>e.traceLines);return(0,F.jsx)(ooe,{...e,records:t,traceLines:r,rejected:n})}function Q9(e){if(e!=null)return FD(e instanceof Error?e.message:String(e))}function fse(e){let t=new Set(e.dataTransfer.types);return t.has(`application/x-opencraw-pill`)||t.has(`application/x-opencraw-card`)}var pse=450;function $9({label:e,active:t,onClick:n,switchOnDrag:r=!1}){let i=(0,P.useRef)(void 0),a=()=>{i.current!==void 0&&clearTimeout(i.current),i.current=void 0},o=e=>{r&&!t&&fse(e)&&(e.preventDefault(),i.current??=setTimeout(()=>{i.current=void 0,n()},pse))};return(0,F.jsx)(V,{as:`button`,px:3,py:1,fontSize:`sm`,fontWeight:t?`semibold`:`normal`,color:t?`fg`:`fg.muted`,borderBottomWidth:`2px`,borderColor:t?`colorPalette.solid`:`transparent`,colorPalette:`brand`,cursor:`pointer`,onClick:n,onDragEnter:o,onDragOver:o,onDragLeave:a,onDrop:a,children:e})}nt.createRoot(document.getElementById(`root`)).render((0,F.jsx)(P.StrictMode,{children:(0,F.jsx)(cse,{})}));export{bW as t};
|
|
42
|
+
`)})}function aoe({loading:e,view:t,error:n}){return e===!0?(0,F.jsxs)(rw,{p:4,direction:`row`,align:`center`,color:`fg.muted`,children:[(0,F.jsx)(zC,{size:`sm`}),(0,F.jsx)(V,{children:`Working it out…`})]}):n===void 0?t===void 0?(0,F.jsx)(I,{p:4,color:`fg.muted`,children:(0,F.jsx)(V,{children:`Click a missing or rejected value in the Records tab to see why here.`})}):(0,F.jsxs)(rw,{p:4,gap:2,children:[(0,F.jsxs)(rw,{direction:`row`,gap:2,align:`center`,children:[(0,F.jsx)(LC,{colorPalette:t.outcome===`rejected`?`red`:`orange`,children:t.outcome}),(0,F.jsx)(V,{fontFamily:`mono`,fontSize:`sm`,fontWeight:`medium`,children:t.field})]}),(0,F.jsx)(V,{children:t.sentence}),t.policy!==void 0&&(0,F.jsxs)(V,{fontSize:`xs`,color:`fg.muted`,children:[`policy: `,t.policy]}),t.stepPath!==void 0&&(0,F.jsxs)(V,{fontSize:`xs`,color:`fg.muted`,children:[`step: `,t.stepPath]})]}):(0,F.jsx)(I,{p:4,children:(0,F.jsx)(V,{color:`fg.error`,children:n})})}function ooe({records:e,traceLines:t,rejected:n=[],onExplainMissing:r,onExplainRejected:i,whyLoading:a,whyView:o,whyError:s,highlightedField:c,onHoverField:l}){return(0,F.jsxs)(Hc,{colorPalette:`brand`,defaultValue:`records`,h:`full`,display:`flex`,flexDirection:`column`,children:[(0,F.jsxs)(Gc,{children:[(0,F.jsxs)(Uc,{value:`records`,children:[`Records (`,e.length,`)`]}),(0,F.jsx)(Uc,{value:`trace`,children:`Trace`}),(0,F.jsx)(Uc,{value:`why`,children:`Why?`})]}),(0,F.jsxs)(Wc,{value:`records`,flex:`1`,minH:`0`,p:0,display:`flex`,flexDirection:`column`,children:[(0,F.jsx)(toe,{records:e,onCellClick:r,highlightedField:c,onHoverField:l}),(0,F.jsx)(roe,{rejected:n,onClick:i})]}),(0,F.jsx)(Wc,{value:`trace`,flex:`1`,minH:`0`,overflow:`auto`,p:0,children:(0,F.jsx)(ioe,{lines:t})}),(0,F.jsx)(Wc,{value:`why`,flex:`1`,minH:`0`,overflow:`auto`,p:0,children:(0,F.jsx)(aoe,{loading:a,view:o,error:s})})]})}function b9(e){if(Array.isArray(e))return e.some(e=>b9(e));if(typeof e!=`object`||!e)return!1;let t=e;return t.type===`emit`||Object.values(t).some(e=>b9(e))}function soe(e){return[...Array.isArray(e)?e:[],{type:`emit`}]}var coe={string:`gray`,number:`blue`,integer:`blue`,boolean:`green`,date:`purple`,datetime:`purple`,currency:`orange`,url:`cyan`,enum:`pink`,array:`teal`,object:`teal`,json:`yellow`};function x9(e){return coe[e]??`gray`}function S9(e){return e!==void 0&&`each`in e}function loe(e){let t={};for(let[n,r]of Object.entries(e))!S9(r)&&typeof r.from==`string`&&(t[n]=r.from);return t}var uoe=[`string`,`number`,`integer`,`boolean`,`date`,`datetime`,`currency`,`url`,`enum`,`array`,`object`,`json`],C9=[`fail`,`skip-record`,`null`,`default`],w9=/^[A-Z_][\w-]*$/i,doe=`trim.lowercase.uppercase.replace.regex.split.join.first.last.nth.slice.concat.coalesce.default.number.integer.boolean.toString.padStart.padEnd.currency.date.absoluteUrl.urlEncode.flatten.unique.sum.count.template.jsonpath.lookup.group`.split(`.`),foe={replace:[{name:`pattern`},{name:`replacement`},{name:`flags`}],regex:[{name:`pattern`},{name:`group`,numeric:!0},{name:`flags`}],split:[{name:`separator`}],join:[{name:`separator`}],nth:[{name:`index`,numeric:!0}],slice:[{name:`start`,numeric:!0},{name:`end`,numeric:!0}],concat:[{name:`separator`}],default:[{name:`value`}],number:[{name:`locale`}],boolean:[{name:`truthy`}],padStart:[{name:`length`,numeric:!0},{name:`char`}],padEnd:[{name:`length`,numeric:!0},{name:`char`}],currency:[{name:`locale`},{name:`currency`}],date:[{name:`format`},{name:`timezone`}],absoluteUrl:[{name:`base`}],template:[{name:`value`}],jsonpath:[{name:`path`}],lookup:[{name:`in`},{name:`key`},{name:`pick`}],group:[{name:`by`}]};function poe(e){return foe[e]??[]}function moe({transforms:e,trace:t,onChange:n}){let[r,i]=(0,P.useState)(!1),a=bk(),o=(t,r)=>{n(e.map((e,n)=>n===t?r:e))},s=t=>{n(e.filter((e,n)=>n!==t))},c=(t,r)=>{let i=t+r;if(i<0||i>=e.length)return;let a=[...e],o=a[t];a[t]=a[i],a[i]=o,n(a)},l=t=>{n([...e,t===`hook`?{op:t,name:a?.[0]??`myHook`}:{op:t}]),i(!1)};return(0,F.jsxs)(rw,{direction:`row`,gap:2,wrap:`wrap`,align:`flex-start`,children:[e.map((n,r)=>(0,F.jsx)(hoe,{transform:n,value:t?.steps[r]?.value,failed:t!==void 0&&t.steps.length<=r,onChange:e=>{o(r,e)},onRemove:()=>{s(r)},onMoveLeft:r===0?void 0:()=>{c(r,-1)},onMoveRight:r===e.length-1?void 0:()=>{c(r,1)}},r)),r?(0,F.jsx)(Lw,{size:`xs`,width:`140px`,children:(0,F.jsxs)(zw,{defaultValue:``,onChange:e=>{e.target.value!==``&&l(e.target.value)},children:[(0,F.jsx)(`option`,{value:``,disabled:!0,children:`op…`}),doe.map(e=>(0,F.jsx)(`option`,{value:e,children:e},e)),(0,F.jsx)(`option`,{value:`hook`,children:`hook (your code)`})]})}):(0,F.jsx)(UC,{size:`xs`,variant:`outline`,onClick:()=>{i(!0)},children:`+ transform`})]})}function hoe({transform:e,value:t,failed:n,onChange:r,onRemove:i,onMoveLeft:a,onMoveRight:o}){let[s,c]=(0,P.useState)(!1),l=e.op===`hook`,u=l?[]:poe(e.op),d=l||u.length>0;return(0,F.jsxs)(I,{borderWidth:`1px`,borderRadius:`md`,borderColor:n?`red.subtle`:void 0,px:2,py:1,fontSize:`xs`,children:[(0,F.jsxs)(W,{gap:1,children:[a!==void 0&&(0,F.jsx)($C,{"aria-label":`Move left`,size:`2xs`,variant:`ghost`,onClick:a,children:`‹`}),(0,F.jsxs)(V,{as:d?`button`:`span`,fontWeight:`medium`,cursor:d?`pointer`:void 0,onClick:d?()=>{c(!s)}:void 0,children:[e.op,l&&typeof e.name==`string`?`: ${e.name}`:``]}),o!==void 0&&(0,F.jsx)($C,{"aria-label":`Move right`,size:`2xs`,variant:`ghost`,onClick:o,children:`›`}),(0,F.jsx)($C,{"aria-label":`Remove ${e.op}`,size:`2xs`,variant:`ghost`,colorPalette:`red`,onClick:i,children:`×`})]}),t!==void 0&&(0,F.jsxs)(LC,{mt:1,size:`sm`,colorPalette:n?`red`:`gray`,fontFamily:`mono`,maxW:`160px`,overflow:`hidden`,textOverflow:`ellipsis`,children:[`→ `,typeof t==`object`?JSON.stringify(t):String(t)]}),s&&l&&(0,F.jsx)(rw,{mt:1,gap:1,children:(0,F.jsx)(xk,{size:`xs`,ariaLabel:`Hook name`,value:typeof e.name==`string`?e.name:``,onChange:t=>{r({...e,name:t})}})}),s&&u.length>0&&(0,F.jsx)(rw,{mt:1,gap:1,children:u.map(t=>(0,F.jsxs)(W,{gap:1,children:[(0,F.jsx)(V,{color:`fg.muted`,minW:`70px`,children:t.name}),(0,F.jsx)(Dw,{size:`2xs`,value:e[t.name]===void 0?``:String(e[t.name]),onChange:n=>{let i=n.target.value;r({...e,[t.name]:t.numeric?Number(i):i})}})]},t.name))})]})}function T9({name:e,field:t,rule:n,scopeIds:r,trace:i,value:a,missing:o,rejected:s,depth:c=0,stepId:l,highlighted:u=!1,onHoverStepId:d,onFieldChange:f,onRuleChange:p,onRename:m,onRemove:h,onExplainMissing:g,onExplainRejected:_}){let[v,y]=(0,P.useState)(!1),[b,x]=(0,P.useState)(e),[S,C]=(0,P.useState)(),[w,T]=(0,P.useState)(!1),E=t.generated!==void 0;return(0,F.jsxs)(I,{"data-testid":`${e}-row`,"data-highlighted":u,borderWidth:`1px`,borderRadius:`md`,p:2,ml:c*5,borderColor:u?`orange.solid`:s===void 0?void 0:`red.subtle`,bg:u?`orange.subtle`:void 0,onMouseEnter:l===void 0||d===void 0?void 0:()=>{d(l)},onMouseLeave:l===void 0||d===void 0?void 0:()=>{d(void 0)},children:[(0,F.jsxs)(W,{"data-testid":`${e}-summary`,gap:2,mb:2,align:`center`,wrap:`wrap`,fontSize:`xs`,children:[(0,F.jsx)(LC,{size:`sm`,colorPalette:x9(t.type),children:t.type}),E?(0,F.jsx)(LC,{size:`sm`,colorPalette:`gray`,children:`generated`}):l===void 0?(0,F.jsx)(LC,{size:`sm`,colorPalette:`orange`,children:n===void 0?`not mapped`:`from a template`}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(V,{color:`fg.muted`,children:`←`}),(0,F.jsx)(oB,{name:l,draggable:!1})]}),a!==void 0&&(0,F.jsxs)(V,{color:`fg.muted`,truncate:!0,maxW:`260px`,title:E9(a),children:[`= `,E9(a)]})]}),(0,F.jsxs)(W,{gap:2,align:`center`,wrap:`wrap`,children:[(0,F.jsxs)(rw,{gap:0,children:[(0,F.jsx)(Dw,{size:`xs`,width:`140px`,value:b,onChange:e=>{x(e.target.value)},onBlur:()=>{if(b!==e){if(!w9.test(b)){C(`a field name has no dots`);return}C(void 0),m(b)}}}),S!==void 0&&(0,F.jsx)(V,{fontSize:`2xs`,color:`fg.error`,children:S})]}),(0,F.jsx)(Lw,{size:`xs`,width:`110px`,children:(0,F.jsx)(zw,{value:t.type,onChange:e=>{f({...t,type:e.target.value})},children:uoe.map(e=>(0,F.jsx)(`option`,{value:e,children:e},e))})}),(0,F.jsx)(I,{"data-testid":`${e}-source-drop`,minW:`140px`,borderWidth:`1px`,borderStyle:`dashed`,borderRadius:`sm`,px:2,py:`2px`,fontSize:`xs`,bg:w?`colorPalette.subtle`:void 0,colorPalette:`brand`,onDragOver:e=>{e.dataTransfer.types.includes(`application/x-opencraw-pill`)&&(e.preventDefault(),T(!0))},onDragLeave:()=>{T(!1)},onDrop:e=>{e.preventDefault(),T(!1);let t=e.dataTransfer.getData(`application/x-opencraw-pill`)||e.dataTransfer.getData(`text/plain`);t!==``&&p({...n,from:t})},children:E?(0,F.jsxs)(V,{color:`fg.muted`,children:[`generated: `,t.generated]}):(0,F.jsx)(Lw,{size:`xs`,children:(0,F.jsxs)(zw,{value:typeof n?.from==`string`?n.from:``,onChange:e=>{p(e.target.value===``?void 0:{...n,from:e.target.value})},children:[(0,F.jsx)(`option`,{value:``,children:`(drop a pill, or pick)`}),r.map(e=>(0,F.jsx)(`option`,{value:e,children:e},e))]})})}),(0,F.jsxs)(JC,{size:`xs`,checked:t.key===!0,onCheckedChange:e=>{f({...t,key:e.checked===!0})},children:[(0,F.jsx)(QC,{}),(0,F.jsx)(ZC,{}),(0,F.jsx)(YC,{children:`key`})]}),(0,F.jsxs)(JC,{size:`xs`,checked:t.required===!0,disabled:E,onCheckedChange:e=>{f({...t,required:e.checked===!0})},children:[(0,F.jsx)(QC,{}),(0,F.jsx)(ZC,{}),(0,F.jsx)(YC,{children:`required`})]}),o===!0&&(0,F.jsx)(UC,{size:`2xs`,variant:`outline`,colorPalette:`orange`,onClick:g,children:`Why null?`}),s!==void 0&&(0,F.jsxs)(UC,{size:`2xs`,variant:`outline`,colorPalette:`red`,onClick:_,title:s.reason,children:[s.count,` rejected`]}),(0,F.jsx)(UC,{size:`2xs`,variant:`ghost`,onClick:()=>{y(!v)},children:v?`less`:`more`}),(0,F.jsx)($C,{"aria-label":`Remove ${e}`,size:`2xs`,variant:`ghost`,colorPalette:`red`,onClick:h,ml:`auto`,children:`×`})]}),!E&&t.type!==`object`&&(0,F.jsx)(I,{mt:2,children:(0,F.jsx)(moe,{transforms:n?.transform??[],trace:i,onChange:e=>{p(n===void 0?void 0:{...n,transform:e.length===0?void 0:e})}})}),v&&(0,F.jsxs)(rw,{mt:2,direction:`row`,gap:3,wrap:`wrap`,fontSize:`xs`,children:[(0,F.jsxs)(JC,{size:`xs`,checked:t.nullable===!0,onCheckedChange:e=>{f({...t,nullable:e.checked===!0})},children:[(0,F.jsx)(QC,{}),(0,F.jsx)(ZC,{}),(0,F.jsx)(YC,{children:`nullable`})]}),(0,F.jsxs)(W,{gap:1,children:[(0,F.jsx)(V,{color:`fg.muted`,children:`onMissing`}),(0,F.jsx)(Lw,{size:`xs`,width:`110px`,children:(0,F.jsxs)(zw,{value:t.onMissing??``,onChange:e=>{f({...t,onMissing:e.target.value===``?void 0:e.target.value})},children:[(0,F.jsx)(`option`,{value:``,children:`(recipe default)`}),C9.map(e=>(0,F.jsx)(`option`,{value:e,children:e},e))]})})]}),(0,F.jsxs)(W,{gap:1,children:[(0,F.jsx)(V,{color:`fg.muted`,children:`default`}),(0,F.jsx)(Dw,{size:`xs`,width:`120px`,value:t.default===void 0?``:String(t.default),onChange:e=>{f({...t,default:e.target.value===``?void 0:e.target.value})}})]}),t.type===`currency`&&(0,F.jsxs)(W,{gap:1,children:[(0,F.jsx)(V,{color:`fg.muted`,children:`currency`}),(0,F.jsx)(Dw,{size:`xs`,width:`60px`,value:t.currency??``,onChange:e=>{f({...t,currency:e.target.value||void 0})}})]}),(t.type===`date`||t.type===`datetime`)&&(0,F.jsxs)(W,{gap:1,children:[(0,F.jsx)(V,{color:`fg.muted`,children:`format`}),(0,F.jsx)(Dw,{size:`xs`,width:`100px`,value:t.format??``,onChange:e=>{f({...t,format:e.target.value||void 0})}})]}),t.type===`enum`&&(0,F.jsxs)(W,{gap:1,children:[(0,F.jsx)(V,{color:`fg.muted`,children:`values`}),(0,F.jsx)(Dw,{size:`xs`,width:`160px`,placeholder:`a, b, c`,value:(t.values??[]).join(`, `),onChange:e=>{f({...t,values:e.target.value.split(`,`).map(e=>e.trim()).filter(e=>e!==``)})}})]}),(0,F.jsxs)(W,{gap:1,children:[(0,F.jsx)(V,{color:`fg.muted`,children:`pattern`}),(0,F.jsx)(Dw,{size:`xs`,width:`120px`,value:t.pattern??``,onChange:e=>{f({...t,pattern:e.target.value||void 0})}})]}),(0,F.jsxs)(W,{gap:1,children:[(0,F.jsx)(V,{color:`fg.muted`,children:`min`}),(0,F.jsx)(Dw,{size:`xs`,width:`60px`,value:t.min??``,onChange:e=>{f({...t,min:e.target.value===``?void 0:Number(e.target.value)})}})]}),(0,F.jsxs)(W,{gap:1,children:[(0,F.jsx)(V,{color:`fg.muted`,children:`max`}),(0,F.jsx)(Dw,{size:`xs`,width:`60px`,value:t.max??``,onChange:e=>{f({...t,max:e.target.value===``?void 0:Number(e.target.value)})}})]})]})]})}function E9(e){let t=typeof e==`string`?e:JSON.stringify(e);return t.length>80?`${t.slice(0,79)}…`:t}function goe({suggestions:e,onAdd:t,onAddAll:n}){return e.length===0?null:(0,F.jsxs)(I,{"data-testid":`field-suggestions`,borderWidth:`1px`,borderStyle:`dashed`,borderRadius:`md`,p:2,bg:`bg.subtle`,children:[(0,F.jsxs)(W,{justify:`space-between`,mb:1,children:[(0,F.jsx)(V,{fontSize:`xs`,fontWeight:`medium`,children:`Read by the steps, not in the output yet`}),(0,F.jsxs)(UC,{size:`2xs`,variant:`outline`,onClick:n,children:[`Add all (`,e.length,`)`]})]}),(0,F.jsx)(rw,{direction:`row`,wrap:`wrap`,gap:2,children:e.map(e=>(0,F.jsxs)(W,{"data-testid":`suggestion-${e.source}`,gap:1,borderWidth:`1px`,borderRadius:`full`,pl:1,pr:1,py:`1px`,bg:`bg`,title:`${e.name}: ${e.field.type}, because ${e.reason}`,children:[(0,F.jsx)(oB,{name:e.source,draggable:!1}),(0,F.jsx)(V,{fontSize:`xs`,color:`fg.muted`,children:`→`}),(0,F.jsx)(V,{fontSize:`xs`,fontWeight:`medium`,children:e.name}),(0,F.jsx)(LC,{size:`sm`,colorPalette:x9(e.field.type),children:e.field.type}),(0,F.jsx)(UC,{size:`2xs`,variant:`ghost`,"aria-label":`Add ${e.name}`,onClick:()=>{t(e)},children:`+`})]},e.source))})]})}function D9(e){let t=new Set(e.dataTransfer.types);return t.has(`application/x-opencraw-pill`)||t.has(`application/x-opencraw-card`)}function _oe({onPill:e,onCard:t,children:n}){let[r,i]=(0,P.useState)(!1);function a(e){!e.defaultPrevented&&D9(e)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`,i(!0))}function o(n){if(i(!1),n.defaultPrevented||!D9(n))return;n.preventDefault();let r=gk(n.dataTransfer);if(r!==void 0){t(r);return}let a=n.dataTransfer.getData(aB);a!==``&&e(a)}return(0,F.jsx)(I,{"data-testid":`output-drop-zone`,"data-drop-over":r,borderWidth:`2px`,borderStyle:`dashed`,borderColor:r?`brand.solid`:`transparent`,bg:r?`brand.subtle`:void 0,borderRadius:`md`,minH:`4em`,flexShrink:0,onDragOver:a,onDragLeave:()=>{i(!1)},onDrop:o,children:n})}function voe(e){let t=k9(e);if(t===void 0)return[];let n=[];return O9(t,n),n}function O9(e,t){for(let n of e){if(typeof n!=`object`||!n)continue;let e=n;for(let n of[`id`,`as`]){let r=e[n];typeof r==`string`&&r.length>0&&!t.includes(r)&&t.push(r)}let r=k9(e);r!==void 0&&O9(r,t),Array.isArray(e.else)&&O9(e.else,t)}}function k9(e){if(typeof e!=`object`||!e)return;let t=e.steps;return Array.isArray(t)?t:void 0}var yoe=new Set([`attr:href`,`attr:src`,`attr:data-src`]),boe=[[[`url`,`link`,`href`,`website`,`homepage`,`image`,`img`,`photo`,`thumbnail`,`src`],{type:`url`,reason:`its name says a link`}],[[`datetime`,`timestamp`],{type:`datetime`,reason:`its name says a moment in time`}],[[`date`,`day`,`published`,`created`,`updated`,`released`,`expires`,`expiry`,`until`,`since`],{type:`date`,reason:`its name says a date`}],[[`available`,`availability`,`active`,`enabled`,`instock`,`is`,`has`],{type:`boolean`,reason:`its name says yes or no`}],[[`qty`,`quantity`,`count`,`pages`,`year`,`age`,`rank`,`position`,`votes`,`reviews`],{type:`integer`,reason:`its name says a whole number`}],[[`price`,`cost`,`amount`,`total`,`fee`,`discount`,`salary`,`rate`,`rating`,`score`,`weight`,`height`,`width`,`length`,`percent`,`sconto`],{type:`number`,reason:`its name says an amount`}]];function A9(e,t,n){let r=N9(M9(e)),i=new Set(r.flatMap(e=>typeof e.over==`string`?[e.over]:[])),a=woe(n),o=new Set(Object.keys(t)),s=[],c=new Set;for(let e of r){let t=e.id;if(typeof t!=`string`||t===``||!Coe(e)||i.has(t)||a.has(t)||c.has(t))continue;c.add(t);let n=Soe(t,e),r=j9(t,o);o.add(r),s.push({source:t,name:r,field:{type:n.type,...n.items!==void 0&&{items:n.items}},rule:{from:n.from??t,...n.transform!==void 0&&{transform:n.transform}},reason:n.reason})}return s}function xoe(e,t,n,r){let i=A9(t,n,r).find(t=>t.source===e);return i===void 0?{source:e,name:j9(e,new Set(Object.keys(n))),field:{type:`string`},rule:{from:e},reason:`text, the safe default`}:i}function Soe(e,t){if(t.kind===`table`)return{type:`json`,from:`${e}.rows`,reason:`the rows of the table, as a list`};if(t.many===!0)return{type:`array`,items:{type:`string`},reason:`it reads every match, a list`};let n=typeof t.take==`string`?t.take:void 0;if(n!==void 0&&yoe.has(n))return{type:`url`,transform:[{op:`absoluteUrl`}],reason:`it takes ${n}, a link (made absolute)`};if(t.kind===`section`)return{type:`string`,reason:`it reads a block of text`};let r=Toe(e);for(let[e,t]of boe)if(r.some(t=>e.includes(t)))return t;return{type:`string`,reason:`text, the safe default`}}function Coe(e){return e.type===`set`||e.type===`extract`&&(e.kind!==`table`||e.many!==!0)}function woe(e){let t=new Set,n=e=>{let n=Array.isArray(e.from)?e.from:[e.from];for(let e of n)t.add(e.split(`.`,1)[0])};for(let r of Object.values(e))if(`each`in r){t.add(r.each);for(let e of Object.values(r.fields))n(e)}else n(r);return t}function Toe(e){return e.replace(/([a-z\d])([A-Z])/g,`$1 $2`).toLowerCase().split(/[^a-z\d]+/).filter(e=>e!==``)}function j9(e,t){let n=e.replace(/[^\w-]/g,`_`);w9.test(n)||(n=`field_${n}`);let r=n,i=2;for(;t.has(r);)r=`${n}${String(i)}`,i+=1;return r}function M9(e){if(typeof e!=`object`||!e)return[];let t=e.steps;return Array.isArray(t)?t:[]}function N9(e){return e.flatMap(e=>{if(typeof e!=`object`||!e)return[];let t=e,n=Array.isArray(t.else)?t.else:[];return[t,...N9(M9(t)),...N9(n)]})}function Eoe({inputRecipe:e,outputRecipe:t,records:n,rejected:r,onSaveInput:i,onSaveOutput:a,onSaveOutline:o,onExplainMissing:s,onExplainRejected:c}){let[l,u]=(0,P.useState)(),[d,f]=(0,P.useState)(),[p,m]=(0,P.useState)(),[h,g]=(0,P.useState)(),[_,v]=(0,P.useState)(0),[y,b]=(0,P.useState)(!1),[x,S]=(0,P.useState)(),C=G(e=>e.hoveredStepId),w=G(e=>e.setHoveredStepId),T=(0,P.useRef)(new Set);if((0,P.useEffect)(()=>{let n=t===void 0?void 0:JSON.parse(t.text),r=e===void 0?void 0:JSON.parse(e.text);m(n===void 0?void 0:JSON.stringify(n)),g(r===void 0?void 0:JSON.stringify(r));let i=T.current;if(n!==void 0&&r!==void 0&&i.size>0){T.current=new Set;let e=A9(r,n.fields,r.mapping).filter(e=>i.has(e.source)),t={...n.fields},a={...r.mapping};for(let n of e)t[n.name]=n.field,a[n.name]=n.rule;u({...n,fields:t}),f({...r,mapping:a})}else u(n),f(r);v(0)},[e?.file,e?.text,t?.file,t?.text]),e===void 0)return(0,F.jsx)(I,{p:4,color:`fg.muted`,children:(0,F.jsx)(V,{children:`Select a recipe to see its output fields.`})});if(t===void 0||l===void 0||d===void 0)return(0,F.jsx)(I,{p:4,color:`fg.muted`,children:(0,F.jsx)(V,{children:`This recipe names no output recipe found in this workspace.`})});let E=voe(d),D=A9(d,l.fields,d.mapping),O=n[_],k=JSON.stringify(l)!==p||JSON.stringify(d)!==h,A=(e,t)=>{let n={...l.fields};t===void 0?delete n[e]:n[e]=t,u({...l,fields:n})},ee=(e,t)=>{if(t===e||l.fields[t]!==void 0)return;let n={};for(let[r,i]of Object.entries(l.fields))n[r===e?t:r]=i;u({...l,fields:n});let r={...d.mapping};r[e]!==void 0&&(r[t]=r[e],delete r[e]),f({...d,mapping:r})},te=(e,t)=>{let n={...d.mapping};t===void 0?delete n[e]:n[e]=t,f({...d,mapping:n})},ne=e=>{let t={...l.fields},n={...d.mapping};for(let r of e)t[r.name]=r.field,n[r.name]=r.rule;u({...l,fields:t}),f({...d,mapping:n})},re=e=>{ne([xoe(e,d,l.fields,d.mapping)])},ie=()=>{let e=`field`,t=1;for(;l.fields[e]!==void 0;)e=`field${t}`,t+=1;A(e,{type:`string`})},ae=async()=>{b(!0),S(void 0);try{await a(t.file,l),await i(e.file,d)}catch(e){S(e instanceof Error?e.message:String(e))}finally{b(!1)}},oe=async t=>{let n=e.outline;if(o!==void 0&&n!==void 0){S(void 0);try{k&&await ae(),T.current=new Set(P9(t)),await o(e.file,{...n,steps:[...n.steps,{...t,path:`steps.${String(n.steps.length)}`}]})}catch(e){T.current=new Set,S(e instanceof Error?e.message:String(e))}}};return(0,F.jsxs)(rw,{h:`full`,p:2,gap:2,overflow:`auto`,children:[(0,F.jsxs)(W,{justify:`space-between`,wrap:`wrap`,children:[(0,F.jsxs)(W,{gap:3,fontSize:`xs`,color:`fg.muted`,children:[(0,F.jsxs)(W,{gap:1,children:[(0,F.jsx)(V,{children:`onMissing`}),(0,F.jsx)(Lw,{size:`xs`,width:`110px`,children:(0,F.jsxs)(zw,{value:l.onMissing??``,onChange:e=>{u({...l,onMissing:e.target.value===``?void 0:e.target.value})},children:[(0,F.jsx)(`option`,{value:``,children:`(fail/null)`}),C9.filter(e=>e!=="default").map(e=>(0,F.jsx)(`option`,{value:e,children:e},e))]})})]}),n.length>0&&(0,F.jsxs)(W,{gap:1,children:[(0,F.jsx)(V,{children:`record`}),(0,F.jsx)(Lw,{size:`xs`,width:`70px`,children:(0,F.jsx)(zw,{value:_,onChange:e=>{v(Number(e.target.value))},children:n.map((e,t)=>(0,F.jsxs)(`option`,{value:t,children:[`#`,t+1]},e.key??t))})})]})]}),(0,F.jsxs)(W,{children:[x!==void 0&&(0,F.jsx)(V,{color:`fg.error`,fontSize:`xs`,children:x}),(0,F.jsx)(UC,{size:`xs`,onClick:()=>{ae()},disabled:!k||y,loading:y,children:`Save`})]})]}),!b9(d.steps)&&(Object.keys(l.fields).length>0||D.length>0)&&(0,F.jsxs)(W,{role:`alert`,"data-testid":`missing-emit`,gap:2,p:2,borderWidth:`1px`,borderColor:`orange.300`,rounded:`md`,fontSize:`xs`,justify:`space-between`,children:[(0,F.jsx)(V,{children:`This recipe has no Emit step, so a run reads these values but returns no records.`}),(0,F.jsx)(UC,{size:`xs`,variant:`outline`,onClick:()=>{f({...d,steps:soe(d.steps)})},children:`Add Emit step`})]}),(0,F.jsx)(goe,{suggestions:D,onAdd:e=>{ne([e])},onAddAll:()=>{ne(D)}}),(0,F.jsxs)(_oe,{onPill:re,onCard:e=>{oe(e)},children:[Object.keys(l.fields).length===0&&D.length===0&&(0,F.jsx)(V,{fontSize:`xs`,color:`fg.muted`,p:2,children:`No output fields yet. Drag a pill from a Steps card, or a selection from the content pane, onto this list; or pick values and they show up above as proposals; or add a field by hand.`}),(0,F.jsx)(rw,{gap:2,children:Object.entries(l.fields).map(([e,t])=>(0,F.jsx)(F9,{name:e,field:t,target:e,input:d,record:O,rejected:r,scopeIds:E,hoveredStepId:C,onHoverStepId:w,setRule:te,onFieldChange:t=>{A(e,t)},onRename:t=>{ee(e,t)},onRemove:()=>{A(e,void 0)},onExplainMissing:s===void 0?void 0:()=>{s(_,e)},onExplainRejected:c===void 0?void 0:()=>{let t=r.findIndex(t=>t.field===e);t!==-1&&c(t)}},e))})]}),(0,F.jsx)(I,{flexShrink:0,children:(0,F.jsx)(UC,{size:`xs`,variant:`outline`,onClick:ie,children:`+ field`})})]})}function P9(e){let t=typeof e.step.id==`string`?[e.step.id]:[];return e.kind===`bracket`?[...t,...e.children.flatMap(e=>P9(e)),...(e.elseChildren??[]).flatMap(e=>P9(e))]:t}function F9({name:e,field:t,target:n,input:r,record:i,rejected:a,scopeIds:o,depth:s=0,hoveredStepId:c,onHoverStepId:l,setRule:u,onFieldChange:d,onRename:f,onRemove:p,onExplainMissing:m,onExplainRejected:h}){if(t.type===`object`&&t.fields!==void 0)return(0,F.jsxs)(rw,{gap:1,children:[(0,F.jsx)(T9,{name:e,field:t,scopeIds:o,depth:s,onFieldChange:d,onRename:f,onRemove:p,onRuleChange:()=>{}}),Object.entries(t.fields).map(([e,f])=>(0,F.jsx)(F9,{name:e,field:f,target:`${n}.${e}`,input:r,record:i,rejected:a,scopeIds:o,depth:s+1,hoveredStepId:c,onHoverStepId:l,setRule:u,onFieldChange:n=>{d({...t,fields:{...t.fields,[e]:n}})},onRename:n=>{let r={},i=Object.entries(t.fields??{});for(let[t,a]of i)r[t===e?n:t]=a;d({...t,fields:r})},onRemove:()=>{let n={...t.fields};delete n[e],d({...t,fields:n})}},e))]});if(t.type===`array`&&t.items?.type===`object`&&t.items.fields!==void 0){let i=r.mapping[n],a=S9(i)?i:void 0,f=t.items,p=f.fields;return(0,F.jsxs)(rw,{gap:1,borderWidth:`1px`,borderRadius:`md`,p:2,ml:s*5,children:[(0,F.jsxs)(W,{gap:2,children:[(0,F.jsx)(V,{fontWeight:`medium`,fontSize:`sm`,children:e}),(0,F.jsx)(V,{fontSize:`xs`,color:`fg.muted`,children:`each`}),(0,F.jsx)(Dw,{size:`xs`,width:`140px`,placeholder:`list id (e.g. items)`,value:a?.each??``,onChange:e=>{u(n,e.target.value===``?void 0:{each:e.target.value,fields:a?.fields??{}})}})]}),Object.entries(p).map(([e,r])=>{let i=a?.fields[e],m=typeof i?.from==`string`?i.from:void 0;return(0,F.jsx)(T9,{name:e,field:r,rule:i,scopeIds:o,depth:s+1,stepId:m,highlighted:m!==void 0&&m===c,onHoverStepId:l,onFieldChange:n=>{d({...t,items:{...f,fields:{...p,[e]:n}}})},onRename:n=>{let r={};for(let[t,i]of Object.entries(p))r[t===e?n:t]=i;d({...t,items:{...f,fields:r}})},onRemove:()=>{let n={...p};delete n[e],d({...t,items:{...f,fields:n}})},onRuleChange:t=>{let r={...a?.fields};t===void 0?delete r[e]:r[e]=t,u(n,{each:a?.each??``,fields:r})}},e)})]})}let g=r.mapping[n],_=g===void 0||S9(g)?void 0:g,v=i?.data[e],y=i?.mapping?.[n],b=a.filter(e=>e.field===n),x=typeof _?.from==`string`?_.from:void 0;return(0,F.jsx)(T9,{name:e,field:t,rule:_,scopeIds:o,trace:y,value:v,missing:v===null,rejected:b.length===0?void 0:{count:b.length,reason:b[b.length-1].reason},depth:s,stepId:x,highlighted:x!==void 0&&x===c,onHoverStepId:l,onFieldChange:d,onRename:f,onRemove:p,onRuleChange:e=>{u(n,e)},onExplainMissing:m,onExplainRejected:h})}function I9(e){if(e.trim()===``)return{ok:!1};try{return{ok:!0,value:JSON.parse(e)}}catch{return{ok:!1}}}function Doe(e){let t={};for(let[n,r]of Object.entries(e)){if(!r.enabled)continue;let e=I9(r.text);e.ok&&(t[n]=e.value)}return Object.keys(t).length===0?void 0:t}var L9=ZE(e=>({entries:{},setEnabled:(t,n)=>{e(e=>({entries:{...e.entries,[t]:{text:e.entries[t]?.text??`null`,enabled:n}}}))},setText:(t,n)=>{e(e=>({entries:{...e.entries,[t]:{enabled:e.entries[t]?.enabled??!1,text:n}}}))}})),Ooe={hook:`hook`,captcha:`captcha solver`,access:`access plugin`};function koe({remote:e}){let t=L9(e=>e.entries),n=L9(e=>e.setEnabled),r=L9(e=>e.setText);return e.length===0?null:(0,F.jsxs)(rw,{gap:1,mt:1,"data-testid":`hook-stubs`,children:[(0,F.jsx)(V,{fontSize:`xs`,children:`These call outside this machine: a sample run waits for them, and they may cost.`}),e.map(e=>{let i=t[e.name],a=e.kind===`hook`,o=i?.text??`null`,s=i?.enabled??!1,c=I9(o).ok;return(0,F.jsxs)(W,{gap:2,wrap:`wrap`,"data-testid":`remote-${e.name}`,children:[(0,F.jsx)(V,{fontSize:`xs`,children:`${Ooe[e.kind]} ${e.name} → ${e.label}`}),a&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(JC,{size:`xs`,checked:s,onCheckedChange:t=>{n(e.name,t.checked===!0)},children:[(0,F.jsx)(QC,{}),(0,F.jsx)(ZC,{}),(0,F.jsx)(YC,{children:`stub ${e.name}`})]}),(0,F.jsx)(Dw,{size:`xs`,width:`220px`,fontFamily:`mono`,"aria-label":`stub value of ${e.name}`,"aria-invalid":!c,value:o,onChange:t=>{r(e.name,t.target.value)}}),!c&&(0,F.jsx)(V,{fontSize:`xs`,color:`red.fg`,children:`not JSON: the hook is called`})]})]},`${e.kind}:${e.name}`)})]})}var Aoe=/^[a-z0-9][a-z0-9-]*$/,joe=`https://example.com`;function R9(e){if(e.trim()!==``)try{let{protocol:t}=new URL(e.trim());return t===`http:`||t===`https:`?void 0:`use an http:// or https:// address`}catch{return`use a full address, like https://example.com/books`}}function z9(e,t,n=joe){return B9(e,t,{mode:`web`,start:[{url:n}],steps:[{type:`goto`,url:`{{start.url}}`},{type:`emit`}]})}function Moe(e,t,n,r){return B9(e,t,{mode:`api`,start:[{url:n}],steps:[{type:`request`,id:`doc`,url:`{{start.url}}`,as:r}]})}function Noe(e,t,n){return B9(e,t,{mode:`api`,start:[{url:n}],steps:[{type:`request`,id:`doc`,url:`{{start.url}}`}]})}function B9(e,t,n){let r=e.endsWith(`/`)?e.slice(0,-1):e;return{outputPath:`${r}/${t}.ocw-out.json`,output:{kind:`output`,id:t,version:1,fields:{}},inputPath:`${r}/${t}.ocw-in.json`,input:{kind:`input`,id:t,output:t,...n,mapping:{}}}}function V9(e){let t=e.replace(/\.[^.]+$/,``).toLowerCase().split(/[^a-z0-9]+/).filter(e=>e!==``).join(`-`);return t===``?`document`:t}var Poe=new Set([`www`,`en`,`uk`,`com`,`co`,`org`,`net`,`gov`,`edu`,`io`,`eu`,`us`,`de`,`fr`,`es`,`it`,`nl`,`info`,`app`,`dev`]);function Foe(e){let t;try{t=new URL(e)}catch{return`document`}let n=t.hostname.split(`.`).filter(e=>!Poe.has(e)).slice(0,2),r=t.pathname.split(`/`).filter(e=>e!==``).map(e=>e.replace(/\.[^.]+$/,``)),i=r.length===0?void 0:r[r.length-1],a=r.length<2?void 0:r[r.length-2],o=i===void 0?[]:a!==void 0&&/^\d+$/.test(i)?[a,i]:[i];return V9([...n,...o].join(` `)).slice(0,48).replace(/-$/,``)}function H9(e,t){let n=new Set(t);if(!n.has(e))return e;for(let t=2;;t+=1)if(!n.has(`${e}-${t}`))return`${e}-${t}`}function Ioe({folder:e,open:t,onClose:n,onCreated:r}){let[i,a]=(0,P.useState)(``),[o,s]=(0,P.useState)(``),[c,l]=(0,P.useState)(),u=tO(),d=i.length===0?void 0:U9(i),f=R9(o);function p(){n(),a(``),s(``),l(void 0)}async function m(){if(e===void 0||U9(i)!==void 0||R9(o)!==void 0)return;l(void 0);let t=z9(e,i,o.trim()===``?void 0:o.trim());try{await u.mutateAsync({path:t.outputPath,recipe:t.output}),await u.mutateAsync({path:t.inputPath,recipe:t.input}),r(i),p()}catch(e){l(e instanceof Error?e.message:String(e))}}return(0,F.jsx)(ow,{open:t,onOpenChange:e=>{e.open||p()},children:(0,F.jsxs)(g_,{children:[(0,F.jsx)(dw,{}),(0,F.jsx)(sw,{children:(0,F.jsxs)(cw,{children:[(0,F.jsxs)(pw,{display:`flex`,flexDirection:`row`,alignItems:`center`,justifyContent:`space-between`,children:[(0,F.jsx)(lw,{children:`New recipe`}),(0,F.jsx)(uw,{asChild:!0,children:(0,F.jsx)(ew,{size:`sm`,"aria-label":`Close`})})]}),(0,F.jsxs)(fw,{display:`flex`,flexDirection:`column`,gap:3,pb:4,children:[(0,F.jsxs)(xw,{invalid:d!==void 0,children:[(0,F.jsx)(Sw,{children:`Recipe id`}),(0,F.jsx)(Dw,{size:`sm`,placeholder:`books`,value:i,onChange:e=>{a(e.target.value)},onKeyDown:e=>{e.key===`Enter`&&m()}}),d!==void 0&&(0,F.jsx)(ww,{children:d})]}),(0,F.jsxs)(xw,{invalid:f!==void 0,children:[(0,F.jsx)(Sw,{children:`Start URL (optional)`}),(0,F.jsx)(Dw,{size:`sm`,placeholder:`https://example.com/books`,value:o,onChange:e=>{s(e.target.value)},onKeyDown:e=>{e.key===`Enter`&&m()}}),f!==void 0&&(0,F.jsx)(ww,{children:f})]}),(0,F.jsxs)(V,{fontSize:`xs`,color:`fg.muted`,children:[`Writes `,(0,F.jsxs)(V,{as:`span`,fontFamily:`mono`,children:[i||`<id>`,`.ocw-in.json`]}),` and`,` `,(0,F.jsxs)(V,{as:`span`,fontFamily:`mono`,children:[i||`<id>`,`.ocw-out.json`]})," into the open folder: a `web` recipe with one page and no fields mapped yet, ready to build out in the Steps tab."]}),c!==void 0&&(0,F.jsx)(V,{color:`fg.error`,fontSize:`sm`,children:c}),(0,F.jsx)(UC,{size:`sm`,colorPalette:`brand`,alignSelf:`flex-end`,onClick:()=>{m()},disabled:e===void 0||i.length===0||d!==void 0||f!==void 0||u.isPending,loading:u.isPending,children:`Create`})]})]})})]})})}function U9(e){return Aoe.test(e)?void 0:`lowercase letters, digits and hyphens, starting with a letter or digit`}function W9(e){return[...e.dataTransfer.types].includes(`Files`)}function Loe(e){W9(e)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)}function Roe({onFile:e,children:t,...n}){let[r,i]=(0,P.useState)(0),a=r>0;function o(e){W9(e)&&(e.preventDefault(),i(e=>e+1))}function s(e){W9(e)&&i(e=>Math.max(0,e-1))}function c(t){if(!W9(t))return;t.preventDefault(),i(0);let n=t.dataTransfer.files[0];n!==void 0&&e(n)}return(0,F.jsxs)(I,{position:`relative`,"data-testid":`document-drop-zone`,onDragEnter:o,onDragOver:Loe,onDragLeave:s,onDrop:c,...n,children:[t,a&&(0,F.jsx)(I,{role:`status`,position:`absolute`,inset:0,zIndex:`overlay`,display:`flex`,alignItems:`center`,justifyContent:`center`,bg:`brand.subtle/80`,borderWidth:`3px`,borderStyle:`dashed`,borderColor:`brand.solid`,pointerEvents:`none`,children:(0,F.jsx)(V,{fontSize:`lg`,fontWeight:`semibold`,color:`brand.fg`,children:`Drop to load this file`})})]})}function G9(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function zoe(e){let t=Array.isArray(e.steps)?e.steps[0]:void 0;return e.mode===`api`&&G9(t)&&t.type===`request`&&t.url===`{{start.url}}`}function Boe(e,t){if(!G9(e)||e.kind!==`input`||!Array.isArray(e.start))return{kind:`new`};let[n,...r]=e.start;if(!G9(n)||!(t.kind===`document`?zoe(e):e.mode===`web`))return{kind:`new`};let i=typeof n.url==`string`?n.url:void 0;return{kind:`replace`,recipe:{...e,start:[{...n,url:t.url},...r]},previous:i}}function Voe(e){if(e!==void 0)try{return JSON.parse(e)}catch{return}}function K9(e,t){return e.kind===`document`?t:e.url}function q9(){let e=ET(),t=tO();return async(n,r,i)=>{let{openFolder:a,selectedRecipeId:o}=G.getState(),s=a===void 0?void 0:e.getQueryData(VD(a))?.recipes.find(e=>e.id===o),c=Boe(Voe(s?.text),n);if(XD(),s!==void 0&&c.kind===`replace`)return await t.mutateAsync({path:s.file,recipe:c.recipe}),`Loaded ${K9(n,r)} into “${s.id??s.file}”${c.previous===void 0?``:`, replacing ${c.previous}`}.`;if(await i(),s!==void 0)return`“${s.id??s.file}” reads ${n.kind===`document`?`a web page`:`a document`}, so ${K9(n,r)} started a new recipe instead. “${s.id??s.file}” is unchanged.`}}var Hoe={odt:{what:`an OpenDocument text document`,instead:`Open it in Word or LibreOffice, save it as .docx or .pdf, and load that file.`},odp:{what:`an OpenDocument presentation`,instead:`Open it in PowerPoint or LibreOffice, save it as .pptx or .pdf, and load that file.`},rtf:{what:`a Rich Text document`,instead:`Open it in Word, save it as .docx or .pdf, and load that file.`},pages:{what:`an Apple Pages document`,instead:`Export it from Pages as .pdf or .docx, and load that file.`},numbers:{what:`an Apple Numbers spreadsheet`,instead:`Export it from Numbers as .xlsx or .csv, and load that file.`},key:{what:`an Apple Keynote presentation`,instead:`Export it from Keynote as .pptx or .pdf, and load that file.`},zip:{what:`a compressed archive`,instead:`Unpack it and load the file you want from inside.`},rar:{what:`a compressed archive`,instead:`Unpack it and load the file you want from inside.`},"7z":{what:`a compressed archive`,instead:`Unpack it and load the file you want from inside.`},png:{what:`a picture`,instead:`The Studio reads text, tables and data, not pictures. If it is a scan, use the text version of the document.`},jpg:{what:`a picture`,instead:`The Studio reads text, tables and data, not pictures. If it is a scan, use the text version of the document.`},jpeg:{what:`a picture`,instead:`The Studio reads text, tables and data, not pictures. If it is a scan, use the text version of the document.`},gif:{what:`a picture`,instead:`The Studio reads text, tables and data, not pictures.`}};function J9(e){let t=/\.([a-z0-9]+)$/i.exec(e.split(/[?#]/,1)[0])?.[1]?.toLowerCase(),n=t===void 0?void 0:Hoe[t];if(n!==void 0)return`“${e.split(/[\\/]/).pop()??e}” is ${n.what}, which the Studio cannot read yet. ${n.instead}`}function Y9(){let e=BD(),t=tO(),n=G(e=>e.commitFolder),r=G(e=>e.selectRecipe);return async(i,a,o)=>{let s=(await e.openWorkspace(i)).recipes.map(e=>e.id).filter(e=>e!==void 0),c=H9(V9(a),s),l=Noe(i,c,o);await t.mutateAsync({path:l.outputPath,recipe:l.output}),await t.mutateAsync({path:l.inputPath,recipe:l.input}),G.getState().openFolder!==i&&n(i),r(c)}}function Uoe(){let e=rO(),t=Y9(),n=q9(),r=G(e=>e.folder),i=G(e=>e.openFolder),[a,o]=(0,P.useState)(),[s,c]=(0,P.useState)(!1),[l,u]=(0,P.useState)();async function d(a){let s=(i??r).trim();if(s===``){o(`Type a workspace folder in the toolbar first, then drop the file again: that is where the copy and the recipe go.`);return}let l=J9(a.name);if(l!==void 0){o(l);return}o(void 0),u(void 0),c(!0);try{let{url:r}=await e.mutateAsync({folder:s,name:a.name,bytes:await Woe(a)});u(await n({kind:`document`,url:r},a.name,async()=>{await t(s,a.name,r)}))}catch(e){o(e instanceof Error?e.message:String(e))}finally{c(!1)}}return{importFile:d,pending:s,error:a,notice:l}}function Woe(e){return new Promise((t,n)=>{let r=new FileReader;r.addEventListener(`error`,()=>{n(r.error??Error(`could not read ${e.name}`))}),r.addEventListener(`load`,()=>{let e=String(r.result);t(e.slice(e.indexOf(`,`)+1))}),r.readAsDataURL(e)})}function Goe(e){return e.slice(Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`))+1)}function X9(){let e=BD(),t=G(e=>e.commitFolder),n=G(e=>e.selectRecipe),r=Y9();return(0,P.useCallback)(async(i,a)=>{let o=await e.openPath(i,a);o.kind===`document`?await r(o.folder,Goe(o.path),o.url):(t(o.folder),o.kind===`recipe`&&o.recipeId!==void 0&&n(o.recipeId))},[e,t,n,r])}function Koe(){let e=BD(),t=X9(),[n,r]=(0,P.useState)();return(0,P.useEffect)(()=>{let n=e.initialOpen;if(n===void 0)return;let i=()=>{let e=new URLSearchParams(globalThis.location.search);e.delete(`open`),globalThis.history.replaceState({},``,`${globalThis.location.pathname}?${e.toString()}`)};(async()=>{try{await t(n,e.initialFolder)}catch(e){r(e instanceof Error?e.message:String(e))}finally{i()}})()},[]),n}function qoe(e){return e instanceof Error?e.message:String(e)}function Joe(){let e=BD(),t=X9(),n=G(e=>e.selectRecipe),r=ZD(e=>e.askPick),[i,a]=(0,P.useState)();return(0,P.useEffect)(()=>e.subscribe(i=>{if(i.type!==`ui-request`)return;let{requestId:o,request:s}=i;if(a(void 0),s.kind===`pick`){n(s.recipeId),r({requestId:o,recipeId:s.recipeId,selector:s.selector,text:s.text,add:s.add});return}(async()=>{let n=!0,r=`Opened ${s.path}.`;try{await t(s.path,s.workspace)}catch(e){n=!1,r=qoe(e),a(r)}try{await e.reportUiOutcome(o,n,r)}catch{}})()}),[e,t,n,r]),i}function Yoe({open:e,onClose:t,onLoad:n}){let[r,i]=(0,P.useState)(``),a=r.trim()===``?void 0:R9(r),o=r.trim()!==``&&a===void 0;function s(){i(``),t()}function c(){o&&(n(r.trim()),s())}return(0,F.jsx)(ow,{open:e,onOpenChange:e=>{e.open||s()},children:(0,F.jsxs)(g_,{children:[(0,F.jsx)(dw,{}),(0,F.jsx)(sw,{children:(0,F.jsxs)(cw,{children:[(0,F.jsxs)(pw,{display:`flex`,flexDirection:`row`,alignItems:`center`,justifyContent:`space-between`,children:[(0,F.jsx)(lw,{children:`Load a web page`}),(0,F.jsx)(uw,{asChild:!0,children:(0,F.jsx)(ew,{size:`sm`,"aria-label":`Close`})})]}),(0,F.jsxs)(fw,{display:`flex`,flexDirection:`column`,gap:3,pb:4,children:[(0,F.jsxs)(xw,{invalid:a!==void 0,children:[(0,F.jsx)(Sw,{children:`Page address`}),(0,F.jsx)(Dw,{size:`sm`,placeholder:`https://example.com/books`,value:r,onChange:e=>{i(e.target.value)},onKeyDown:e=>{e.key===`Enter`&&c()}}),a!==void 0&&(0,F.jsx)(ww,{children:a}),(0,F.jsx)(Cw,{children:`Becomes the open recipe's start page, or a new recipe when none reads a web page.`})]}),(0,F.jsx)(UC,{size:`sm`,colorPalette:`brand`,alignSelf:`flex-end`,disabled:!o,onClick:c,children:`Load`})]})]})})]})})}function Xoe(){let e=BD(),t=tO(),n=q9(),r=G(e=>e.folder),i=G(e=>e.openFolder),a=G(e=>e.commitFolder),o=G(e=>e.selectRecipe),[s,c]=(0,P.useState)(!1),[l,u]=(0,P.useState)(),[d,f]=(0,P.useState)();async function p(n,r){let i=(await e.openWorkspace(n)).recipes.map(e=>e.id).filter(e=>e!==void 0),{kind:s}=await e.detectUrl(r),c=H9(Foe(r),i),l=s===`html`||s===`unknown`?z9(n,c,r):Moe(n,c,r,s);await t.mutateAsync({path:l.outputPath,recipe:l.output}),await t.mutateAsync({path:l.inputPath,recipe:l.input}),G.getState().openFolder!==n&&a(n),o(c)}async function m(e){let t=(i??r).trim();if(t===``){u(`Open a workspace folder first (Recipe ▾ → Open folder…): that is where the recipe is written.`);return}let a=J9(e.trim());if(a!==void 0){u(a);return}u(void 0),f(void 0),c(!0);try{let r=e.trim();f(await n({kind:`url`,url:r},r,async()=>{await p(t,r)}))}catch(e){u(e instanceof Error?e.message:String(e))}finally{c(!1)}}return{loadUrl:m,pending:s,error:l,notice:d}}function Zoe(){let e=globalThis.opencrawDesktop;return typeof e?.chooseFolder==`function`?{chooseFolder:e.chooseFolder}:void 0}function Qoe({hooks:e}){return e===void 0?null:(0,F.jsxs)(I,{px:4,py:1,bg:`orange.subtle`,color:`orange.fg`,fontSize:`sm`,"data-testid":`hooks-bar`,children:[`Hooks loaded from ${e.source} (runs as your code): ${e.names.length===0?`none exported`:e.names.join(`, `)}`,e.remote!==void 0&&(0,F.jsx)(koe,{remote:e.remote})]})}function $oe(){let e=BD(),t=G(e=>e.commitFolder),[n,r]=(0,P.useState)(!1),[i,a]=(0,P.useState)();async function o(){a(void 0),r(!0);try{let n=await e.chooseFolder();return n===void 0?`cancelled`:(t(n),`picked`)}catch(e){return a(e instanceof Error?e.message:String(e)),`unavailable`}finally{r(!1)}}return{browse:o,pending:n,error:i}}function Z9({label:e,title:t,disabled:n,loading:r,items:i}){let[a,o]=(0,P.useState)(!1),s=(0,P.useRef)(null);return(0,P.useEffect)(()=>{if(!a)return;let e=e=>{if(e instanceof KeyboardEvent){e.key===`Escape`&&o(!1);return}s.current!==null&&!s.current.contains(e.target)&&o(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,e)}},[a]),(0,F.jsxs)(I,{ref:s,position:`relative`,flexShrink:0,children:[(0,F.jsx)(UC,{size:`sm`,variant:`outline`,maxW:`16em`,title:t,disabled:n,loading:r,"aria-haspopup":`menu`,"aria-expanded":a,onClick:()=>{o(e=>!e)},children:(0,F.jsx)(I,{as:`span`,display:`block`,truncate:!0,maxW:`15em`,title:e,children:e})}),a&&(0,F.jsx)(I,{role:`menu`,position:`absolute`,top:`100%`,left:0,mt:1,zIndex:`dropdown`,minW:`14em`,py:1,bg:`bg`,borderWidth:`1px`,borderRadius:`md`,boxShadow:`md`,children:i.map(e=>(0,F.jsxs)(I,{children:[e.divider===!0&&(0,F.jsx)(I,{borderTopWidth:`1px`,my:1}),e.heading!==void 0&&(0,F.jsx)(I,{px:3,py:1,fontSize:`xs`,color:`fg.muted`,children:e.heading}),(0,F.jsx)(I,{as:`button`,role:`menuitem`,display:`block`,w:`full`,textAlign:`left`,px:3,py:1,fontSize:`sm`,cursor:e.disabled===!0?`not-allowed`:`pointer`,opacity:e.disabled===!0?.5:1,_hover:e.disabled===!0?void 0:{bg:`bg.muted`},"aria-disabled":e.disabled===!0,onClick:()=>{e.disabled!==!0&&(o(!1),e.onSelect())},children:e.label})]},e.label))})]})}function ese({loading:e,onLoadDocument:t,onLoadUrl:n}){return(0,F.jsx)(Z9,{label:`Load ▾`,title:`Bring in the document or page the recipe reads (a file can also be dropped anywhere)`,disabled:e,loading:e,items:[{label:`Document…`,onSelect:t},{label:`Web page (URL)…`,onSelect:n}]})}function tse({open:e,onClose:t,folder:n,onFolderChange:r,onOpen:i,onBrowse:a,browsing:o}){function s(){n.trim()!==``&&(i(),t())}return(0,F.jsx)(ow,{open:e,onOpenChange:e=>{e.open||t()},children:(0,F.jsxs)(g_,{children:[(0,F.jsx)(dw,{}),(0,F.jsx)(sw,{children:(0,F.jsxs)(cw,{children:[(0,F.jsxs)(pw,{display:`flex`,flexDirection:`row`,alignItems:`center`,justifyContent:`space-between`,children:[(0,F.jsx)(lw,{children:`Open folder`}),(0,F.jsx)(uw,{asChild:!0,children:(0,F.jsx)(ew,{size:`sm`,"aria-label":`Close`})})]}),(0,F.jsxs)(fw,{display:`flex`,flexDirection:`column`,gap:3,pb:4,children:[(0,F.jsx)(Dw,{size:`sm`,placeholder:`recipe folder`,value:n,onChange:e=>{r(e.target.value)},onKeyDown:e=>{e.key===`Enter`&&s()}}),(0,F.jsxs)(V,{fontSize:`xs`,color:`fg.muted`,children:[`A folder of `,(0,F.jsx)(V,{as:`span`,fontFamily:`mono`,children:`.ocw-in.json`}),` and `,(0,F.jsx)(V,{as:`span`,fontFamily:`mono`,children:`.ocw-out.json`}),` recipes, or an empty one to start in.`]}),(0,F.jsxs)(W,{justifyContent:`flex-end`,children:[a!==void 0&&(0,F.jsx)(UC,{size:`sm`,variant:`outline`,onClick:a,disabled:o,loading:o,title:`Pick the folder in the operating system dialog`,children:`Browse…`}),(0,F.jsx)(UC,{size:`sm`,colorPalette:`brand`,onClick:s,disabled:n.trim()===``,children:`Open`})]})]})]})})]})})}function nse({inputs:e,selectedRecipeId:t,hasFolder:n,onSelectRecipe:r,onNewRecipe:i,onOpenFolder:a}){let o=e.length===0?[{label:n?`No recipes in this folder`:`Open a folder first`,onSelect:()=>{},disabled:!0,heading:`Open recipe`}]:e.map((e,n)=>{let i=e.id??e.file;return{label:i===t?`✓ ${i}`:i,onSelect:()=>{r(i)},...n===0&&{heading:`Open recipe`}}});return(0,F.jsx)(Z9,{label:t===void 0?`Recipe ▾`:`Recipe: ${t} ▾`,title:`Open, create or switch the recipe being edited`,items:[...o,{label:`New recipe…`,onSelect:i,disabled:!n,divider:!0},{label:`Open folder…`,onSelect:a}]})}function rse(){let e=mte()>0;return(0,F.jsx)(V,{role:`status`,fontSize:`sm`,color:`fg.muted`,flexShrink:0,children:e?`Saving…`:`All changes saved`})}var ise=`.pdf,.xlsx,.xlsm,.xls,.ods,.csv,.tsv,.pptx,.docx,.md,.markdown,.html,.htm,.json,.jsonl,.yaml,.yml,.xml`;function ase(e){return/[^/\\]+(?=[/\\]*$)/u.exec(e)?.[0]??``}function ose({folder:e,onFolderChange:t,onOpen:n,onChooseFolder:r,onBrowse:i,browsing:a,openFolder:o,inputs:s,selectedRecipeId:c,onSelectRecipe:l,onRecipeCreated:u,onImportFile:d,onLoadUrl:f,importing:p,running:m,onRunSample:h,onStop:g,onClear:_}){let v=(0,P.useRef)(null),[y,b]=(0,P.useState)(!1),[x,S]=(0,P.useState)(!1),[C,w]=(0,P.useState)(!1);return(0,F.jsxs)(W,{gap:2,p:2,borderBottomWidth:`1px`,wrap:`wrap`,children:[(0,F.jsx)(_te,{}),(0,F.jsx)(nse,{inputs:s,selectedRecipeId:c,hasFolder:o!==void 0,onSelectRecipe:l,onNewRecipe:()=>{b(!0)},onOpenFolder:()=>{r===void 0?i===void 0?w(!0):i().then(e=>{e===`unavailable`&&w(!0)}):r()}}),(0,F.jsx)(ese,{loading:p,onLoadDocument:()=>{v.current?.click()},onLoadUrl:()=>{S(!0)}}),(0,F.jsx)(`input`,{ref:v,type:`file`,accept:ise,"aria-label":`Load document`,hidden:!0,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t!==void 0&&d(t)}}),o!==void 0&&(0,F.jsx)(V,{fontSize:`sm`,color:`fg.muted`,truncate:!0,maxW:`14em`,title:o,children:ase(o)}),(0,F.jsx)(rse,{}),(0,F.jsxs)(W,{gap:2,flexShrink:0,ml:`auto`,children:[(0,F.jsx)(Tte,{}),(0,F.jsx)(UC,{size:`sm`,colorPalette:`brand`,onClick:h,disabled:c===void 0||m,loading:m,children:`Run sample`}),(0,F.jsx)(UC,{size:`sm`,variant:`outline`,onClick:g,disabled:!m,children:`Stop`}),(0,F.jsx)(UC,{size:`sm`,variant:`ghost`,onClick:_,disabled:m,title:`Clear the records, trace and selection left from the last source`,children:`Clear`})]}),(0,F.jsx)(Ioe,{folder:o,open:y,onClose:()=>{b(!1)},onCreated:u}),(0,F.jsx)(Yoe,{open:x,onClose:()=>{S(!1)},onLoad:f}),(0,F.jsx)(tse,{open:C,onClose:()=>{w(!1)},folder:e,onFolderChange:t,onOpen:n,onBrowse:i===void 0?void 0:()=>{i()},browsing:a})]})}var sse=8e3;function cse(){let[e]=(0,P.useState)(()=>Vte());return(0,F.jsx)(DT,{client:e,children:(0,F.jsx)(nn,{value:gte,children:(0,F.jsx)(lse,{})})})}function lse(){let e=BD();Wte(),Cte();let t=G(e=>e.folder),n=G(e=>e.openFolder),r=G(e=>e.selectedRecipeId),i=G(e=>e.editorTab),a=G(e=>e.setFolder),o=G(e=>e.commitFolder),s=G(e=>e.selectRecipe),c=G(e=>e.setEditorTab),l=G(e=>e.hoveredStepId),u=G(e=>e.setHoveredStepId),[d,f]=(0,P.useState)([70,30]),[p,m]=(0,P.useState)([50,50]),h=HD(n),g=$D(),_=QD(),v=YD(e=>e.running),y=YD(e=>e.error),b=Hte(),x=L9(e=>e.entries),S=Ute(),C=tO(),w=iO(),T=Jte(),E=Uoe(),D=Xoe(),O=$oe(),k=Koe(),A=Joe();(0,P.useEffect)(()=>{e.initialFolder!==void 0&&o(e.initialFolder)},[]),(0,P.useEffect)(()=>{if(r!==void 0||h.data===void 0)return;let e=h.data.recipes.find(e=>e.kind===`input`);e?.id!==void 0&&s(e.id)},[h.data,r,s]);let ee=(0,P.useMemo)(()=>{if(_!==void 0&&_.kind===`input`)try{let e=JSON.parse(_.text).output;return h.data?.recipes.find(t=>t.kind===`output`&&t.id===e)}catch{return}},[_,h.data]),te=(0,P.useMemo)(()=>{if(_===void 0||_.kind!==`input`)return{};try{let e=JSON.parse(_.text).mapping;return e===void 0?{}:loe(e)}catch{return{}}},[_]),ne=Object.keys(te).find(e=>te[e]===l&&l!==void 0),re=(0,P.useMemo)(()=>Zoe(),[]),ie=re===void 0?void 0:()=>{re.chooseFolder()},ae=e=>{T.mutate(e)},oe=k??A??E.error??D.error??O.error??Q9(h.error)??(y===void 0?void 0:FD(y)),se=E.notice??D.notice,[ce,j]=(0,P.useState)();(0,P.useEffect)(()=>{if(se===void 0)return;let e=setTimeout(()=>{j(se)},sse);return()=>{clearTimeout(e)}},[se]);let le=se===ce?void 0:se;return(0,F.jsx)(vk.Provider,{value:h.data?.hooks?.names,children:(0,F.jsxs)(Roe,{onFile:e=>{E.importFile(e)},h:`100vh`,display:`flex`,flexDirection:`column`,children:[(0,F.jsx)(ose,{folder:t,onFolderChange:a,onOpen:()=>{o(t)},onChooseFolder:ie,onBrowse:O.browse,browsing:O.pending,openFolder:n,inputs:g,selectedRecipeId:r,onSelectRecipe:s,onRecipeCreated:s,onImportFile:e=>{E.importFile(e)},onLoadUrl:e=>{D.loadUrl(e)},importing:E.pending||D.pending,running:v,onRunSample:()=>{r!==void 0&&b.mutate({recipeId:r,stubs:Doe(x)})},onStop:()=>{S.mutate()},onClear:()=>{XD(),T.reset()}}),(0,F.jsx)(Qoe,{hooks:h.data?.hooks}),le!==void 0&&oe===void 0&&(0,F.jsx)(I,{role:`status`,px:4,py:1,bg:`brand.subtle`,color:`brand.fg`,fontSize:`sm`,children:le}),oe!==void 0&&(0,F.jsx)(I,{px:4,py:1,bg:`red.subtle`,color:`red.fg`,fontSize:`sm`,children:oe}),(0,F.jsxs)(Qw,{orientation:`vertical`,panels:[{id:`workspace`,minSize:20},{id:`preview`,minSize:10}],size:d,onResize:e=>{f(e.size)},flex:`1`,minH:`0`,children:[(0,F.jsx)($w,{id:`workspace`,overflow:`hidden`,children:(0,F.jsxs)(Qw,{panels:[{id:`content`,minSize:20},{id:`editor`,minSize:20}],size:p,onResize:e=>{m(e.size)},h:`full`,children:[(0,F.jsx)($w,{id:`content`,overflow:`auto`,children:(0,F.jsx)(QG,{recipe:_,onSaveOutline:async(e,t)=>{await w.mutateAsync({path:e,outline:t})},onSaveRecipe:async(e,t)=>{await C.mutateAsync({path:e,recipe:t})}})}),(0,F.jsx)(nT,{id:`content:editor`}),(0,F.jsxs)($w,{id:`editor`,overflow:`hidden`,display:`flex`,flexDirection:`column`,children:[(0,F.jsxs)(W,{gap:1,px:2,pt:2,borderBottomWidth:`1px`,flexShrink:0,children:[(0,F.jsx)($9,{label:`Steps`,active:i===`steps`,onClick:()=>{c(`steps`)}}),(0,F.jsx)($9,{label:`Record`,active:i===`record`,onClick:()=>{c(`record`)},switchOnDrag:!0}),(0,F.jsx)($9,{label:`JSON`,active:i===`json`,onClick:()=>{c(`json`)}}),i===`steps`&&(0,F.jsx)(I,{ml:`auto`,pb:1,children:(0,F.jsx)(kte,{})})]}),(0,F.jsxs)(I,{flex:`1`,minH:`0`,overflow:`auto`,children:[i===`steps`&&(0,F.jsx)(UV,{recipe:_,onSaveOutline:async(e,t)=>{await w.mutateAsync({path:e,outline:t})}}),i===`record`&&(0,F.jsx)(use,{inputRecipe:_,outputRecipe:ee,onSaveInput:async(e,t)=>{await C.mutateAsync({path:e,recipe:t})},onSaveOutput:async(e,t)=>{await C.mutateAsync({path:e,recipe:t})},onSaveOutline:async(e,t)=>{await w.mutateAsync({path:e,outline:t})},onExplainMissing:r===void 0?void 0:(e,t)=>{ae({kind:`missing`,recipeId:r,recordIndex:e,field:t})},onExplainRejected:r===void 0?void 0:e=>{ae({kind:`rejected`,recipeId:r,rejectedIndex:e})}}),i===`json`&&(0,F.jsx)(Hae,{recipe:_,onSave:async(e,t)=>{await C.mutateAsync({path:e,recipe:t})}})]})]})]})}),(0,F.jsx)(nT,{id:`workspace:preview`}),(0,F.jsx)($w,{id:`preview`,overflow:`hidden`,borderTopWidth:`1px`,children:(0,F.jsx)(dse,{onExplainMissing:r===void 0?void 0:(e,t)=>{ae({kind:`missing`,recipeId:r,recordIndex:e,field:t})},onExplainRejected:r===void 0?void 0:e=>{ae({kind:`rejected`,recipeId:r,rejectedIndex:e})},whyLoading:T.isPending,whyView:T.data,whyError:Q9(T.error),highlightedField:ne,onHoverField:e=>{u(e===void 0?void 0:te[e])}})})]})]})})}function use(e){let t=YD(e=>e.records),n=YD(e=>e.rejected);return(0,F.jsx)(Eoe,{...e,records:t,rejected:n})}function dse(e){let t=YD(e=>e.records),n=YD(e=>e.rejected),r=YD(e=>e.traceLines);return(0,F.jsx)(ooe,{...e,records:t,traceLines:r,rejected:n})}function Q9(e){if(e!=null)return FD(e instanceof Error?e.message:String(e))}function fse(e){let t=new Set(e.dataTransfer.types);return t.has(`application/x-opencraw-pill`)||t.has(`application/x-opencraw-card`)}var pse=450;function $9({label:e,active:t,onClick:n,switchOnDrag:r=!1}){let i=(0,P.useRef)(void 0),a=()=>{i.current!==void 0&&clearTimeout(i.current),i.current=void 0},o=e=>{r&&!t&&fse(e)&&(e.preventDefault(),i.current??=setTimeout(()=>{i.current=void 0,n()},pse))};return(0,F.jsx)(V,{as:`button`,px:3,py:1,fontSize:`sm`,fontWeight:t?`semibold`:`normal`,color:t?`fg`:`fg.muted`,borderBottomWidth:`2px`,borderColor:t?`colorPalette.solid`:`transparent`,colorPalette:`brand`,cursor:`pointer`,onClick:n,onDragEnter:o,onDragOver:o,onDragLeave:a,onDrop:a,children:e})}nt.createRoot(document.getElementById(`root`)).render((0,F.jsx)(P.StrictMode,{children:(0,F.jsx)(cse,{})}));export{bW as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{t as e}from"./index-B40d4kiB.js";var t={9306(e,t,n){var r=n(4901),i=n(6823),a=TypeError;e.exports=function(e){if(r(e))return e;throw new a(i(e)+` is not a function`)}},3506(e,t,n){var r=n(3925),i=String,a=TypeError;e.exports=function(e){if(r(e))return e;throw new a(`Can't set `+i(e)+` as a prototype`)}},7080(e,t,n){var r=n(4402).has;e.exports=function(e){return r(e),e}},3463(e){var t=TypeError;e.exports=function(e){if(typeof e==`string`)return e;throw new t(`Argument is not a string`)}},4328(e,t,n){var r=n(4995),i=new r.WeakMap,a=r.set,o=r.remove;e.exports=function(e){return a(i,e,1),o(i,e),e}},6557(e,t,n){var r=n(4995).has;e.exports=function(e){return r(e),e}},6469(e,t,n){var r=n(8227),i=n(2360),a=n(4913).f,o=r(`unscopables`),s=Array.prototype;s[o]===void 0&&a(s,o,{configurable:!0,value:i(null)}),e.exports=function(e){s[o][e]=!0}},679(e,t,n){var r=n(1625),i=TypeError;e.exports=function(e,t){if(r(t,e))return e;throw new i(`Incorrect invocation`)}},3972(e,t,n){var r=n(34),i=String,a=TypeError;e.exports=function(e){if(e===void 0||r(e))return e;throw new a(i(e)+` is not an object or undefined`)}},8551(e,t,n){var r=n(34),i=String,a=TypeError;e.exports=function(e){if(r(e))return e;throw new a(i(e)+` is not an object`)}},4154(e,t,n){var r=n(6955),i=TypeError;e.exports=function(e){if(r(e)===`Uint8Array`)return e;throw new i(`Argument is not an Uint8Array`)}},7811(e){e.exports=typeof ArrayBuffer<`u`&&typeof DataView<`u`},7394(e,t,n){var r=n(4576),i=n(6706),a=n(2195),o=r.ArrayBuffer,s=r.TypeError;e.exports=o&&i(o.prototype,`byteLength`,`get`)||function(e){if(a(e)!==`ArrayBuffer`)throw new s(`ArrayBuffer expected`);return e.byteLength}},3238(e,t,n){var r=n(4576),i=n(7811),a=n(7394),o=r.DataView;e.exports=function(e){if(!i||a(e)!==0)return!1;try{return new o(e),!1}catch{return!0}}},5169(e,t,n){var r=n(3238),i=TypeError;e.exports=function(e){if(r(e))throw new i(`ArrayBuffer is detached`);return e}},4644(e,t,n){var r=n(7811),i=n(3724),a=n(4576),o=n(4901),s=n(34),c=n(9297),l=n(6955),u=n(6823),d=n(6699),f=n(6840),p=n(2106),m=n(1625),h=n(2787),g=n(2967),_=n(8227),v=n(3392),y=n(1181),b=y.enforce,x=y.get,S=a.Int8Array,C=S&&S.prototype,w=a.Uint8ClampedArray,T=w&&w.prototype,E=S&&h(S),D=C&&h(C),O=Object.prototype,k=a.TypeError,A=_(`toStringTag`),j=v(`TYPED_ARRAY_TAG`),M=`TypedArrayConstructor`,N=r&&!!g&&l(a.opera)!==`Opera`,P=!1,F,I,L,R={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},ee={BigInt64Array:8,BigUint64Array:8},te=function(e){if(!s(e))return!1;var t=l(e);return t===`DataView`||c(R,t)||c(ee,t)},ne=function(e){var t=h(e);if(s(t)){var n=x(t);return n&&c(n,M)?n[M]:ne(t)}},z=function(e){if(!s(e))return!1;var t=l(e);return c(R,t)||c(ee,t)},re=function(e){if(z(e))return e;throw new k(`Target is not a typed array`)},ie=function(e){if(o(e)&&(!g||m(E,e)))return e;throw new k(u(e)+` is not a typed array constructor`)},B=function(e,t,n,r){if(i){if(n)for(var o in R){var s=a[o];if(s&&c(s.prototype,e))try{delete s.prototype[e]}catch{try{s.prototype[e]=t}catch{}}}(!D[e]||n)&&f(D,e,n?t:N&&C[e]||t,r)}},V=function(e,t,n){var r,o;if(i){if(g){if(n){for(r in R)if(o=a[r],o&&c(o,e))try{delete o[e]}catch{}}if(!E[e]||n)try{return f(E,e,n?t:N&&E[e]||t)}catch{}else return}for(r in R)o=a[r],o&&(!o[e]||n)&&f(o,e,t)}};for(F in R)I=a[F],L=I&&I.prototype,L?b(L)[M]=I:N=!1;for(F in ee)I=a[F],L=I&&I.prototype,L&&(b(L)[M]=I);if((!N||!o(E)||E===Function.prototype)&&(E=function(){throw new k(`Incorrect invocation`)},N))for(F in R)a[F]&&g(a[F],E);if((!N||!D||D===O)&&(D=E.prototype,N))for(F in R)a[F]&&g(a[F].prototype,D);if(N&&h(T)!==D&&g(T,D),i&&!c(D,A))for(F in P=!0,p(D,A,{configurable:!0,get:function(){return s(this)?this[j]:void 0}}),R)a[F]&&d(a[F].prototype,j,F);e.exports={NATIVE_ARRAY_BUFFER_VIEWS:N,TYPED_ARRAY_TAG:P&&j,aTypedArray:re,aTypedArrayConstructor:ie,exportTypedArrayMethod:B,exportTypedArrayStaticMethod:V,getTypedArrayConstructor:ne,isView:te,isTypedArray:z,TypedArray:E,TypedArrayPrototype:D}},5370(e,t,n){var r=n(6198);e.exports=function(e,t,n){for(var i=0,a=arguments.length>2?n:r(t),o=new e(a);a>i;)o[i]=t[i++];return o}},9617(e,t,n){var r=n(5397),i=n(5610),a=n(6198),o=function(e){return function(t,n,o){var s=r(t),c=a(s);if(c===0)return!e&&-1;var l=i(o,c),u;if(e&&n!==n){for(;c>l;)if(u=s[l++],u!==u)return!0}else for(;c>l;l++)if((e||l in s)&&s[l]===n)return e||l||0;return!e&&-1}};e.exports={includes:o(!0),indexOf:o(!1)}},4527(e,t,n){var r=n(3724),i=n(4376),a=TypeError,o=Object.getOwnPropertyDescriptor;e.exports=r&&!function(){if(this!==void 0)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(e){return e instanceof TypeError}}()?function(e,t){if(i(e)&&!o(e,`length`).writable)throw new a(`Cannot set read only .length`);return e.length=t}:function(e,t){return e.length=t}},7680(e,t,n){e.exports=n(9504)([].slice)},2804(e){var t=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`,n=t+`+/`,r=t+`-_`,i=function(e){for(var t={},n=0;n<64;n++)t[e.charAt(n)]=n;return t};e.exports={i2c:n,c2i:i(n),i2cUrl:r,c2iUrl:i(r)}},6319(e,t,n){var r=n(8551),i=n(9539);e.exports=function(e,t,n,a){try{return a?t(r(n)[0],n[1]):t(n)}catch(t){i(e,`throw`,t)}}},2195(e,t,n){var r=n(9504),i=r({}.toString),a=r(``.slice);e.exports=function(e){return a(i(e),8,-1)}},6955(e,t,n){var r=n(2140),i=n(4901),a=n(2195),o=n(8227)(`toStringTag`),s=Object,c=a(function(){return arguments}())===`Arguments`,l=function(e,t){try{return e[t]}catch{}};e.exports=r?a:function(e){var t,n,r;return e===void 0?`Undefined`:e===null?`Null`:typeof(n=l(t=s(e),o))==`string`?n:c?a(t):(r=a(t))===`Object`&&i(t.callee)?`Arguments`:r}},7740(e,t,n){var r=n(9297),i=n(5031),a=n(7347),o=n(4913);e.exports=function(e,t,n){for(var s=i(t),c=o.f,l=a.f,u=0;u<s.length;u++){var d=s[u];!r(e,d)&&!(n&&r(n,d))&&c(e,d,l(t,d))}}},2211(e,t,n){e.exports=!n(9039)(function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})},2529(e){e.exports=function(e,t){return{value:e,done:t}}},6699(e,t,n){var r=n(3724),i=n(4913),a=n(6980);e.exports=r?function(e,t,n){return i.f(e,t,a(1,n))}:function(e,t,n){return e[t]=n,e}},6980(e){e.exports=function(e,t){return{enumerable:!(e&1),configurable:!(e&2),writable:!(e&4),value:t}}},4659(e,t,n){var r=n(3724),i=n(4913),a=n(6980);e.exports=function(e,t,n){r?i.f(e,t,a(0,n)):e[t]=n}},2106(e,t,n){var r=n(283),i=n(4913);e.exports=function(e,t,n){return n.get&&r(n.get,t,{getter:!0}),n.set&&r(n.set,t,{setter:!0}),i.f(e,t,n)}},6840(e,t,n){var r=n(4901),i=n(4913),a=n(283),o=n(9433);e.exports=function(e,t,n,s){s||={};var c=s.enumerable,l=s.name===void 0?t:s.name;if(r(n)&&a(n,l,s),s.global)c?e[t]=n:o(t,n);else{try{s.unsafe?e[t]&&(c=!0):delete e[t]}catch{}c?e[t]=n:i.f(e,t,{value:n,enumerable:!1,configurable:!s.nonConfigurable,writable:!s.nonWritable})}return e}},6279(e,t,n){var r=n(6840);e.exports=function(e,t,n){for(var i in t)r(e,i,t[i],n);return e}},9433(e,t,n){var r=n(4576),i=Object.defineProperty;e.exports=function(e,t){try{i(r,e,{value:t,configurable:!0,writable:!0})}catch{r[e]=t}return t}},3724(e,t,n){e.exports=!n(9039)(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})},4055(e,t,n){var r=n(4576),i=n(34),a=r.document,o=i(a)&&i(a.createElement);e.exports=function(e){return o?a.createElement(e):{}}},6837(e){var t=TypeError,n=9007199254740991;e.exports=function(e){if(e>n)throw new t(`Maximum allowed index exceeded`);return e}},5002(e){e.exports={IndexSizeError:{s:`INDEX_SIZE_ERR`,c:1,m:1},DOMStringSizeError:{s:`DOMSTRING_SIZE_ERR`,c:2,m:0},HierarchyRequestError:{s:`HIERARCHY_REQUEST_ERR`,c:3,m:1},WrongDocumentError:{s:`WRONG_DOCUMENT_ERR`,c:4,m:1},InvalidCharacterError:{s:`INVALID_CHARACTER_ERR`,c:5,m:1},NoDataAllowedError:{s:`NO_DATA_ALLOWED_ERR`,c:6,m:0},NoModificationAllowedError:{s:`NO_MODIFICATION_ALLOWED_ERR`,c:7,m:1},NotFoundError:{s:`NOT_FOUND_ERR`,c:8,m:1},NotSupportedError:{s:`NOT_SUPPORTED_ERR`,c:9,m:1},InUseAttributeError:{s:`INUSE_ATTRIBUTE_ERR`,c:10,m:1},InvalidStateError:{s:`INVALID_STATE_ERR`,c:11,m:1},SyntaxError:{s:`SYNTAX_ERR`,c:12,m:1},InvalidModificationError:{s:`INVALID_MODIFICATION_ERR`,c:13,m:1},NamespaceError:{s:`NAMESPACE_ERR`,c:14,m:1},InvalidAccessError:{s:`INVALID_ACCESS_ERR`,c:15,m:1},ValidationError:{s:`VALIDATION_ERR`,c:16,m:0},TypeMismatchError:{s:`TYPE_MISMATCH_ERR`,c:17,m:1},SecurityError:{s:`SECURITY_ERR`,c:18,m:1},NetworkError:{s:`NETWORK_ERR`,c:19,m:1},AbortError:{s:`ABORT_ERR`,c:20,m:1},URLMismatchError:{s:`URL_MISMATCH_ERR`,c:21,m:1},QuotaExceededError:{s:`QUOTA_EXCEEDED_ERR`,c:22,m:1},TimeoutError:{s:`TIMEOUT_ERR`,c:23,m:1},InvalidNodeTypeError:{s:`INVALID_NODE_TYPE_ERR`,c:24,m:1},DataCloneError:{s:`DATA_CLONE_ERR`,c:25,m:1}}},8727(e){e.exports=[`constructor`,`hasOwnProperty`,`isPrototypeOf`,`propertyIsEnumerable`,`toLocaleString`,`toString`,`valueOf`]},2839(e,t,n){var r=n(4576).navigator,i=r&&r.userAgent;e.exports=i?String(i):``},9519(e,t,n){var r=n(4576),i=n(2839),a=r.process,o=r.Deno,s=a&&a.versions||o&&o.version,c=s&&s.v8,l,u;c&&(l=c.split(`.`),u=l[0]>0&&l[0]<4?1:+(l[0]+l[1])),!u&&i&&(l=i.match(/Edge\/(\d+)/),(!l||l[1]>=74)&&(l=i.match(/Chrome\/(\d+)/),l&&(u=+l[1]))),e.exports=u},6193(e,t,n){var r=n(9504),i=Error,a=r(``.replace),o=(function(e){return String(new i(e).stack)})(`zxcasd`),s=/\n\s*at [^:]*:[^\n]*/,c=s.test(o);e.exports=function(e,t){if(c&&typeof e==`string`&&!i.prepareStackTrace)for(;t--;)e=a(e,s,``);return e}},6518(e,t,n){var r=n(4576),i=n(7347).f,a=n(6699),o=n(6840),s=n(9433),c=n(7740),l=n(2796);e.exports=function(e,t){var n=e.target,u=e.global,d=e.stat,f,p=u?r:d?r[n]||s(n,{}):r[n]&&r[n].prototype,m,h,g,_;if(p)for(m in t){if(g=t[m],e.dontCallGetSet?(_=i(p,m),h=_&&_.value):h=p[m],f=l(u?m:n+(d?`.`:`#`)+m,e.forced),!f&&h!==void 0){if(typeof g==typeof h)continue;c(g,h)}(e.sham||h&&h.sham)&&a(g,`sham`,!0),o(p,m,g,e)}}},9039(e){e.exports=function(e){try{return!!e()}catch{return!0}}},8745(e,t,n){var r=n(616),i=Function.prototype,a=i.apply,o=i.call;e.exports=typeof Reflect==`object`&&Reflect.apply||(r?o.bind(a):function(){return o.apply(a,arguments)})},6080(e,t,n){var r=n(7476),i=n(9306),a=n(616),o=r(r.bind);e.exports=function(e,t){return i(e),t===void 0?e:a?o(e,t):function(){return e.apply(t,arguments)}}},616(e,t,n){e.exports=!n(9039)(function(){var e=function(){}.bind();return typeof e!=`function`||e.hasOwnProperty(`prototype`)})},9565(e,t,n){var r=n(616),i=Function.prototype.call;e.exports=r?i.bind(i):function(){return i.apply(i,arguments)}},350(e,t,n){var r=n(3724),i=n(9297),a=Function.prototype,o=r&&Object.getOwnPropertyDescriptor,s=i(a,`name`);e.exports={EXISTS:s,PROPER:s&&function(){}.name===`something`,CONFIGURABLE:s&&(!r||r&&o(a,`name`).configurable)}},6706(e,t,n){var r=n(9504),i=n(9306);e.exports=function(e,t,n){try{return r(i(Object.getOwnPropertyDescriptor(e,t)[n]))}catch{}}},7476(e,t,n){var r=n(2195),i=n(9504);e.exports=function(e){if(r(e)===`Function`)return i(e)}},9504(e,t,n){var r=n(616),i=Function.prototype,a=i.call,o=r&&i.bind.bind(a,a);e.exports=r?o:function(e){return function(){return a.apply(e,arguments)}}},944(e){var t=TypeError;e.exports=function(e){var n=e&&e.alphabet;if(n===void 0||n===`base64`||n===`base64url`)return n||`base64`;throw new t("Incorrect `alphabet` option")}},7751(e,t,n){var r=n(4576),i=n(4901),a=function(e){return i(e)?e:void 0};e.exports=function(e,t){return arguments.length<2?a(r[e]):r[e]&&r[e][t]}},1767(e){e.exports=function(e){return{iterator:e,next:e.next,done:!1}}},8646(e,t,n){var r=n(9565),i=n(8551),a=n(1767),o=n(3085);e.exports=function(e,t){(!t||typeof e!=`string`)&&i(e);var n=o(e);return a(i(n===void 0?e:r(n,e)))}},8563(e,t,n){var r=n(9565),i=n(4901),a=n(8551),o=n(6823),s=n(3085),c=TypeError;e.exports=function(e,t){var n=arguments.length<2?s(e):t;if(i(n))return a(r(n,e));throw new c(o(e)+` is not iterable`)}},3085(e,t,n){var r=n(2195),i=n(4117),a=n(5966),o=n(8227)(`iterator`),s=Array.prototype;e.exports=function(e){if(!i(e))return a(e,o)||a(e,`@@iterator`)||(r(e)===`Arguments`?s[o]:void 0)}},5966(e,t,n){var r=n(9306),i=n(4117);e.exports=function(e,t){var n=e[t];return i(n)?void 0:r(n)}},3789(e,t,n){var r=n(9306),i=n(8551),a=n(9565),o=n(1291),s=n(1767),c=`Invalid size`,l=RangeError,u=TypeError,d=Math.max,f=function(e,t){this.set=e,this.size=d(t,0),this.has=r(e.has),this.keys=r(e.keys)};f.prototype={getIterator:function(){return s(i(a(this.keys,this.set)))},includes:function(e){return a(this.has,this.set,e)}},e.exports=function(e){i(e);var t=+e.size;if(t!==t)throw new u(c);var n=o(t);if(n<0)throw new l(c);return new f(e,n)}},4576(e){var t=function(e){return e&&e.Math===Math&&e};e.exports=t(typeof globalThis==`object`&&globalThis)||t(typeof window==`object`&&window)||t(typeof self==`object`&&self)||t(typeof global==`object`&&global)||t(typeof this==`object`&&this)||(function(){return this})()||Function(`return this`)()},9297(e,t,n){var r=n(9504),i=n(8981),a=r({}.hasOwnProperty);e.exports=Object.hasOwn||function(e,t){return a(i(e),t)}},421(e){e.exports={}},397(e,t,n){e.exports=n(7751)(`document`,`documentElement`)},5917(e,t,n){var r=n(3724),i=n(9039),a=n(4055);e.exports=!r&&!i(function(){return Object.defineProperty(a(`div`),"a",{get:function(){return 7}}).a!==7})},7055(e,t,n){var r=n(9504),i=n(9039),a=n(2195),o=Object,s=r(``.split);e.exports=i(function(){return!o(`z`).propertyIsEnumerable(0)})?function(e){return a(e)===`String`?s(e,``):o(e)}:o},3167(e,t,n){var r=n(4901),i=n(34),a=n(2967);e.exports=function(e,t,n){var o,s;return a&&r(o=t.constructor)&&o!==n&&i(s=o.prototype)&&s!==n.prototype&&a(e,s),e}},3706(e,t,n){var r=n(9504),i=n(4901),a=n(7629),o=r(Function.toString);i(a.inspectSource)||(a.inspectSource=function(e){return o(e)}),e.exports=a.inspectSource},1181(e,t,n){var r=n(8622),i=n(4576),a=n(34),o=n(6699),s=n(9297),c=n(7629),l=n(6119),u=n(421),d=`Object already initialized`,f=i.TypeError,p=i.WeakMap,m,h,g,_=function(e){return g(e)?h(e):m(e,{})},v=function(e){return function(t){var n;if(!a(t)||(n=h(t)).type!==e)throw new f(`Incompatible receiver, `+e+` required`);return n}};if(r||c.state){var y=c.state||=new p;y.get=y.get,y.has=y.has,y.set=y.set,m=function(e,t){if(y.has(e))throw new f(d);return t.facade=e,y.set(e,t),t},h=function(e){return y.get(e)||{}},g=function(e){return y.has(e)}}else{var b=l(`state`);u[b]=!0,m=function(e,t){if(s(e,b))throw new f(d);return t.facade=e,o(e,b,t),t},h=function(e){return s(e,b)?e[b]:{}},g=function(e){return s(e,b)}}e.exports={set:m,get:h,has:g,enforce:_,getterFor:v}},4209(e,t,n){var r=n(8227),i=n(6269),a=r(`iterator`),o=Array.prototype;e.exports=function(e){return e!==void 0&&(i.Array===e||o[a]===e)}},4376(e,t,n){var r=n(2195);e.exports=Array.isArray||function(e){return r(e)===`Array`}},1108(e,t,n){var r=n(6955);e.exports=function(e){var t=r(e);return t===`BigInt64Array`||t===`BigUint64Array`}},4901(e){var t=typeof document==`object`&&document.all;e.exports=t===void 0&&t!==void 0?function(e){return typeof e==`function`||e===t}:function(e){return typeof e==`function`}},2796(e,t,n){var r=n(9039),i=n(4901),a=/#|\.prototype\./,o=function(e,t){var n=c[s(e)];return n===u?!0:n===l?!1:i(t)?r(t):!!t},s=o.normalize=function(e){return String(e).replace(a,`.`).toLowerCase()},c=o.data={},l=o.NATIVE=`N`,u=o.POLYFILL=`P`;e.exports=o},4117(e){e.exports=function(e){return e==null}},34(e,t,n){var r=n(4901);e.exports=function(e){return typeof e==`object`?e!==null:r(e)}},3925(e,t,n){var r=n(34);e.exports=function(e){return r(e)||e===null}},6395(e){e.exports=!1},5810(e,t,n){var r=n(34),i=n(1181).get;e.exports=function(e){if(!r(e))return!1;var t=i(e);return!!t&&t.type===`RawJSON`}},757(e,t,n){var r=n(7751),i=n(4901),a=n(1625),o=n(7040),s=Object;e.exports=o?function(e){return typeof e==`symbol`}:function(e){var t=r(`Symbol`);return i(t)&&a(t.prototype,s(e))}},507(e,t,n){var r=n(9565);e.exports=function(e,t,n){for(var i=n?e:e.iterator,a=e.next,o,s;!(o=r(a,i)).done;)if(s=t(o.value),s!==void 0)return s}},2652(e,t,n){var r=n(6080),i=n(9565),a=n(8551),o=n(6823),s=n(4209),c=n(6198),l=n(1625),u=n(8563),d=n(3085),f=n(9539),p=TypeError,m=function(e,t){this.stopped=e,this.result=t},h=m.prototype;e.exports=function(e,t,n){var g=n&&n.that,_=!!(n&&n.AS_ENTRIES),v=!!(n&&n.IS_RECORD),y=!!(n&&n.IS_ITERATOR),b=!!(n&&n.INTERRUPTED),x=r(t,g),S,C,w,T,E,D,O,k=function(e){var t=S;return S=void 0,t&&f(t,`normal`),new m(!0,e)},A=function(e){return _?(a(e),b?x(e[0],e[1],k):x(e[0],e[1])):b?x(e,k):x(e)};if(v)S=e.iterator;else if(y)S=e;else{if(C=d(e),!C)throw new p(o(e)+` is not iterable`);if(s(C)){for(w=0,T=c(e);T>w;w++)if(E=A(e[w]),E&&l(h,E))return E;return new m(!1)}S=u(e,C)}for(D=v?e.next:S.next;!(O=i(D,S)).done;){var j=O.value;try{E=A(j)}catch(e){if(S)f(S,`throw`,e);else throw e}if(typeof E==`object`&&E&&l(h,E))return E}return new m(!1)}},6859(e){e.exports=function(e){e.iterator=e.next=e.nextHandler=e.mapper=e.predicate=e.inner=e.iterables=e.iters=e.openIters=e.padding=e.finishResults=e.buffer=null}},1385(e,t,n){var r=n(9539);e.exports=function(e,t,n){for(var i=e.length-1;i>=0;i--)if(e[i]!==void 0)try{n=r(e[i].iterator,t,n)}catch(e){t=`throw`,n=e}if(t===`throw`)throw n;return n}},9539(e,t,n){var r=n(9565),i=n(8551),a=n(5966);e.exports=function(e,t,n){var o,s;i(e);try{if(o=a(e,`return`),!o){if(t===`throw`)throw n;return n}o=r(o,e)}catch(e){s=!0,o=e}if(t===`throw`)throw n;if(s)throw o;return i(o),n}},9462(e,t,n){var r=n(9565),i=n(2360),a=n(6699),o=n(6279),s=n(8227),c=n(1181),l=n(5966),u=n(7657).IteratorPrototype,d=n(2529),f=n(9539),p=n(1385),m=n(6859),h=s(`toStringTag`),g=`IteratorHelper`,_=`WrapForValidIterator`,v=`normal`,y=`throw`,b=c.set,x=function(e){var t=c.getterFor(e?_:g);return o(i(u),{next:function(){var n=t(this);if(e)return n.nextHandler();if(n.done)return d(void 0,!0);try{var r=n.nextHandler();return n.done&&m(n),n.returnHandlerResult?r:d(r,n.done)}catch(e){throw n.done=!0,m(n),e}},return:function(){var n=t(this),i=n.iterator,a=n.inner,o=n.openIters,s=n.done;if(n.done=!0,e){var c=l(i,`return`);return c?r(c,i):d(void 0,!0)}if(m(n),s)return d(void 0,!0);if(a)try{f(a.iterator,v)}catch(e){return f(i,y,e)}if(o)try{p(o,v)}catch(e){if(i)return f(i,y,e);throw e}return i&&f(i,v),d(void 0,!0)}})},S=x(!0),C=x(!1);a(C,h,`Iterator Helper`),e.exports=function(e,t,n){var r=function(r,i){i?(i.iterator=r.iterator,i.next=r.next):i=r,i.type=t?_:g,i.returnHandlerResult=!!n,i.nextHandler=e,i.counter=0,i.done=!1,b(this,i)};return r.prototype=t?S:C,r}},684(e){e.exports=function(e,t){var n=typeof Iterator==`function`&&Iterator.prototype[e];if(n)try{n.call({next:null},t).next()}catch{return!0}}},4549(e,t,n){var r=n(4576);e.exports=function(e,t){var n=r.Iterator,i=n&&n.prototype,a=i&&i[e],o=!1;if(a)try{a.call({next:function(){return{done:!0}},return:function(){o=!0}},-1)}catch(e){e instanceof t||(o=!1)}if(!o)return a}},7657(e,t,n){var r=n(9039),i=n(4901),a=n(34),o=n(2360),s=n(2787),c=n(6840),l=n(8227),u=n(6395),d=l(`iterator`),f=!1,p,m,h;[].keys&&(h=[].keys(),`next`in h?(m=s(s(h)),m!==Object.prototype&&(p=m)):f=!0),!a(p)||r(function(){var e={};return p[d].call(e)!==e})?p={}:u&&(p=o(p)),i(p[d])||c(p,d,function(){return this}),e.exports={IteratorPrototype:p,BUGGY_SAFARI_ITERATORS:f}},6269(e){e.exports=Object.create?Object.create(null):{}},6198(e,t,n){var r=n(8014);e.exports=function(e){return r(e.length)}},283(e,t,n){var r=n(9504),i=n(9039),a=n(4901),o=n(9297),s=n(3724),c=n(350).CONFIGURABLE,l=n(3706),u=n(1181),d=u.enforce,f=u.get,p=String,m=Object.defineProperty,h=r(``.slice),g=r(``.replace),_=r([].join),v=s&&!i(function(){return m(function(){},`length`,{value:8}).length!==8}),y=String(String).split(`String`),b=e.exports=function(e,t,n){h(p(t),0,7)===`Symbol(`&&(t=`[`+g(p(t),/^Symbol\(([^)]*)\).*$/,`$1`)+`]`),n&&n.getter&&(t=`get `+t),n&&n.setter&&(t=`set `+t),(!o(e,`name`)||c&&e.name!==t)&&(s?m(e,`name`,{value:t,configurable:!0}):e.name=t),v&&n&&o(n,`arity`)&&e.length!==n.arity&&m(e,`length`,{value:n.arity});try{n&&o(n,`constructor`)&&n.constructor?s&&m(e,`prototype`,{writable:!1}):e.prototype&&=void 0}catch{}var r=d(e);return o(r,`source`)||(r.source=_(y,typeof t==`string`?t:``)),e};Function.prototype.toString=b(function(){return a(this)&&f(this).source||l(this)},`toString`)},2248(e,t,n){var r=n(9504),i=Map.prototype;e.exports={Map,set:r(i.set),get:r(i.get),has:r(i.has),remove:r(i.delete),proto:i}},741(e){var t=Math.ceil,n=Math.floor;e.exports=Math.trunc||function(e){var r=+e;return(r>0?n:t)(r)}},7819(e,t,n){e.exports=!n(9039)(function(){var e=`9007199254740993`,t=JSON.rawJSON(e);return!JSON.isRawJSON(t)||JSON.stringify(t)!==e})},6043(e,t,n){var r=n(9306),i=TypeError,a=function(e){var t,n;this.promise=new e(function(e,r){if(t!==void 0||n!==void 0)throw new i(`Bad Promise constructor`);t=e,n=r}),this.resolve=r(t),this.reject=r(n)};e.exports.f=function(e){return new a(e)}},2603(e,t,n){var r=n(655);e.exports=function(e,t){return e===void 0?arguments.length<2?``:t:r(e)}},4149(e){var t=RangeError;e.exports=function(e){if(e===e)return e;throw new t(`NaN is not allowed`)}},2360(e,t,n){var r=n(8551),i=n(6801),a=n(8727),o=n(421),s=n(397),c=n(4055),l=n(6119),u=`>`,d=`<`,f=`prototype`,p=`script`,m=l(`IE_PROTO`),h=function(){},g=function(e){return d+p+u+e+d+`/`+p+u},_=function(e){e.write(g(``)),e.close();var t=e.parentWindow.Object;return e=null,t},v=function(){var e=c(`iframe`),t=`java`+p+`:`,n;return e.style.display=`none`,s.appendChild(e),e.src=String(t),n=e.contentWindow.document,n.open(),n.write(g(`document.F=Object`)),n.close(),n.F},y,b=function(){try{y=new ActiveXObject(`htmlfile`)}catch{}b=typeof document<`u`?document.domain&&y?_(y):v():_(y);for(var e=a.length;e--;)delete b[f][a[e]];return b()};o[m]=!0,e.exports=Object.create||function(e,t){var n;return e===null?n=b():(h[f]=r(e),n=new h,h[f]=null,n[m]=e),t===void 0?n:i.f(n,t)}},6801(e,t,n){var r=n(3724),i=n(8686),a=n(4913),o=n(8551),s=n(5397),c=n(1072);t.f=r&&!i?Object.defineProperties:function(e,t){o(e);for(var n=s(t),r=c(t),i=r.length,l=0,u;i>l;)a.f(e,u=r[l++],n[u]);return e}},4913(e,t,n){var r=n(3724),i=n(5917),a=n(8686),o=n(8551),s=n(6969),c=TypeError,l=Object.defineProperty,u=Object.getOwnPropertyDescriptor,d=`enumerable`,f=`configurable`,p=`writable`;t.f=r?a?function(e,t,n){if(o(e),t=s(t),o(n),typeof e==`function`&&t===`prototype`&&`value`in n&&p in n&&!n[p]){var r=u(e,t);r&&r[p]&&(e[t]=n.value,n={configurable:f in n?n[f]:r[f],enumerable:d in n?n[d]:r[d],writable:!1})}return l(e,t,n)}:l:function(e,t,n){if(o(e),t=s(t),o(n),i)try{return l(e,t,n)}catch{}if(`get`in n||`set`in n)throw new c(`Accessors not supported`);return`value`in n&&(e[t]=n.value),e}},7347(e,t,n){var r=n(3724),i=n(9565),a=n(8773),o=n(6980),s=n(5397),c=n(6969),l=n(9297),u=n(5917),d=Object.getOwnPropertyDescriptor;t.f=r?d:function(e,t){if(e=s(e),t=c(t),u)try{return d(e,t)}catch{}if(l(e,t))return o(!i(a.f,e,t),e[t])}},8480(e,t,n){var r=n(1828),i=n(8727).concat(`length`,`prototype`);t.f=Object.getOwnPropertyNames||function(e){return r(e,i)}},3717(e,t){t.f=Object.getOwnPropertySymbols},2787(e,t,n){var r=n(9297),i=n(4901),a=n(8981),o=n(6119),s=n(2211),c=o(`IE_PROTO`),l=Object,u=l.prototype;e.exports=s?l.getPrototypeOf:function(e){var t=a(e);if(r(t,c))return t[c];var n=t.constructor;return i(n)&&t instanceof n?n.prototype:t instanceof l?u:null}},1625(e,t,n){e.exports=n(9504)({}.isPrototypeOf)},1828(e,t,n){var r=n(9504),i=n(9297),a=n(5397),o=n(9617).indexOf,s=n(421),c=r([].push);e.exports=function(e,t){var n=a(e),r=0,l=[],u;for(u in n)!i(s,u)&&i(n,u)&&c(l,u);for(;t.length>r;)i(n,u=t[r++])&&(~o(l,u)||c(l,u));return l}},1072(e,t,n){var r=n(1828),i=n(8727);e.exports=Object.keys||function(e){return r(e,i)}},8773(e,t){var n={}.propertyIsEnumerable,r=Object.getOwnPropertyDescriptor;t.f=r&&!n.call({1:2},1)?function(e){var t=r(this,e);return!!t&&t.enumerable}:n},2967(e,t,n){var r=n(6706),i=n(34),a=n(7750),o=n(3506);e.exports=Object.setPrototypeOf||(`__proto__`in{}?function(){var e=!1,t={},n;try{n=r(Object.prototype,`__proto__`,`set`),n(t,[]),e=t instanceof Array}catch{}return function(t,r){return a(t),o(r),i(t)&&(e?n(t,r):t.__proto__=r),t}}():void 0)},4270(e,t,n){var r=n(9565),i=n(4901),a=n(34),o=TypeError;e.exports=function(e,t){var n,s;if(t===`string`&&i(n=e.toString)&&!a(s=r(n,e))||i(n=e.valueOf)&&!a(s=r(n,e))||t!==`string`&&i(n=e.toString)&&!a(s=r(n,e)))return s;throw new o(`Can't convert object to primitive value`)}},5031(e,t,n){var r=n(7751),i=n(9504),a=n(8480),o=n(3717),s=n(8551),c=i([].concat);e.exports=r(`Reflect`,`ownKeys`)||function(e){var t=a.f(s(e)),n=o.f;return n?c(t,n(e)):t}},8235(e,t,n){var r=n(9504),i=n(9297),a=SyntaxError,o=parseInt,s=String.fromCharCode,c=r(``.charAt),l=r(``.slice),u=r(/./.exec),d={'\\"':`"`,"\\\\":`\\`,"\\/":`/`,"\\b":`\b`,"\\f":`\f`,"\\n":`
|
|
1
|
+
import{t as e}from"./index-fZYNgtd-.js";var t={9306(e,t,n){var r=n(4901),i=n(6823),a=TypeError;e.exports=function(e){if(r(e))return e;throw new a(i(e)+` is not a function`)}},3506(e,t,n){var r=n(3925),i=String,a=TypeError;e.exports=function(e){if(r(e))return e;throw new a(`Can't set `+i(e)+` as a prototype`)}},7080(e,t,n){var r=n(4402).has;e.exports=function(e){return r(e),e}},3463(e){var t=TypeError;e.exports=function(e){if(typeof e==`string`)return e;throw new t(`Argument is not a string`)}},4328(e,t,n){var r=n(4995),i=new r.WeakMap,a=r.set,o=r.remove;e.exports=function(e){return a(i,e,1),o(i,e),e}},6557(e,t,n){var r=n(4995).has;e.exports=function(e){return r(e),e}},6469(e,t,n){var r=n(8227),i=n(2360),a=n(4913).f,o=r(`unscopables`),s=Array.prototype;s[o]===void 0&&a(s,o,{configurable:!0,value:i(null)}),e.exports=function(e){s[o][e]=!0}},679(e,t,n){var r=n(1625),i=TypeError;e.exports=function(e,t){if(r(t,e))return e;throw new i(`Incorrect invocation`)}},3972(e,t,n){var r=n(34),i=String,a=TypeError;e.exports=function(e){if(e===void 0||r(e))return e;throw new a(i(e)+` is not an object or undefined`)}},8551(e,t,n){var r=n(34),i=String,a=TypeError;e.exports=function(e){if(r(e))return e;throw new a(i(e)+` is not an object`)}},4154(e,t,n){var r=n(6955),i=TypeError;e.exports=function(e){if(r(e)===`Uint8Array`)return e;throw new i(`Argument is not an Uint8Array`)}},7811(e){e.exports=typeof ArrayBuffer<`u`&&typeof DataView<`u`},7394(e,t,n){var r=n(4576),i=n(6706),a=n(2195),o=r.ArrayBuffer,s=r.TypeError;e.exports=o&&i(o.prototype,`byteLength`,`get`)||function(e){if(a(e)!==`ArrayBuffer`)throw new s(`ArrayBuffer expected`);return e.byteLength}},3238(e,t,n){var r=n(4576),i=n(7811),a=n(7394),o=r.DataView;e.exports=function(e){if(!i||a(e)!==0)return!1;try{return new o(e),!1}catch{return!0}}},5169(e,t,n){var r=n(3238),i=TypeError;e.exports=function(e){if(r(e))throw new i(`ArrayBuffer is detached`);return e}},4644(e,t,n){var r=n(7811),i=n(3724),a=n(4576),o=n(4901),s=n(34),c=n(9297),l=n(6955),u=n(6823),d=n(6699),f=n(6840),p=n(2106),m=n(1625),h=n(2787),g=n(2967),_=n(8227),v=n(3392),y=n(1181),b=y.enforce,x=y.get,S=a.Int8Array,C=S&&S.prototype,w=a.Uint8ClampedArray,T=w&&w.prototype,E=S&&h(S),D=C&&h(C),O=Object.prototype,k=a.TypeError,A=_(`toStringTag`),j=v(`TYPED_ARRAY_TAG`),M=`TypedArrayConstructor`,N=r&&!!g&&l(a.opera)!==`Opera`,P=!1,F,I,L,R={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},ee={BigInt64Array:8,BigUint64Array:8},te=function(e){if(!s(e))return!1;var t=l(e);return t===`DataView`||c(R,t)||c(ee,t)},ne=function(e){var t=h(e);if(s(t)){var n=x(t);return n&&c(n,M)?n[M]:ne(t)}},z=function(e){if(!s(e))return!1;var t=l(e);return c(R,t)||c(ee,t)},re=function(e){if(z(e))return e;throw new k(`Target is not a typed array`)},ie=function(e){if(o(e)&&(!g||m(E,e)))return e;throw new k(u(e)+` is not a typed array constructor`)},B=function(e,t,n,r){if(i){if(n)for(var o in R){var s=a[o];if(s&&c(s.prototype,e))try{delete s.prototype[e]}catch{try{s.prototype[e]=t}catch{}}}(!D[e]||n)&&f(D,e,n?t:N&&C[e]||t,r)}},V=function(e,t,n){var r,o;if(i){if(g){if(n){for(r in R)if(o=a[r],o&&c(o,e))try{delete o[e]}catch{}}if(!E[e]||n)try{return f(E,e,n?t:N&&E[e]||t)}catch{}else return}for(r in R)o=a[r],o&&(!o[e]||n)&&f(o,e,t)}};for(F in R)I=a[F],L=I&&I.prototype,L?b(L)[M]=I:N=!1;for(F in ee)I=a[F],L=I&&I.prototype,L&&(b(L)[M]=I);if((!N||!o(E)||E===Function.prototype)&&(E=function(){throw new k(`Incorrect invocation`)},N))for(F in R)a[F]&&g(a[F],E);if((!N||!D||D===O)&&(D=E.prototype,N))for(F in R)a[F]&&g(a[F].prototype,D);if(N&&h(T)!==D&&g(T,D),i&&!c(D,A))for(F in P=!0,p(D,A,{configurable:!0,get:function(){return s(this)?this[j]:void 0}}),R)a[F]&&d(a[F].prototype,j,F);e.exports={NATIVE_ARRAY_BUFFER_VIEWS:N,TYPED_ARRAY_TAG:P&&j,aTypedArray:re,aTypedArrayConstructor:ie,exportTypedArrayMethod:B,exportTypedArrayStaticMethod:V,getTypedArrayConstructor:ne,isView:te,isTypedArray:z,TypedArray:E,TypedArrayPrototype:D}},5370(e,t,n){var r=n(6198);e.exports=function(e,t,n){for(var i=0,a=arguments.length>2?n:r(t),o=new e(a);a>i;)o[i]=t[i++];return o}},9617(e,t,n){var r=n(5397),i=n(5610),a=n(6198),o=function(e){return function(t,n,o){var s=r(t),c=a(s);if(c===0)return!e&&-1;var l=i(o,c),u;if(e&&n!==n){for(;c>l;)if(u=s[l++],u!==u)return!0}else for(;c>l;l++)if((e||l in s)&&s[l]===n)return e||l||0;return!e&&-1}};e.exports={includes:o(!0),indexOf:o(!1)}},4527(e,t,n){var r=n(3724),i=n(4376),a=TypeError,o=Object.getOwnPropertyDescriptor;e.exports=r&&!function(){if(this!==void 0)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(e){return e instanceof TypeError}}()?function(e,t){if(i(e)&&!o(e,`length`).writable)throw new a(`Cannot set read only .length`);return e.length=t}:function(e,t){return e.length=t}},7680(e,t,n){e.exports=n(9504)([].slice)},2804(e){var t=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`,n=t+`+/`,r=t+`-_`,i=function(e){for(var t={},n=0;n<64;n++)t[e.charAt(n)]=n;return t};e.exports={i2c:n,c2i:i(n),i2cUrl:r,c2iUrl:i(r)}},6319(e,t,n){var r=n(8551),i=n(9539);e.exports=function(e,t,n,a){try{return a?t(r(n)[0],n[1]):t(n)}catch(t){i(e,`throw`,t)}}},2195(e,t,n){var r=n(9504),i=r({}.toString),a=r(``.slice);e.exports=function(e){return a(i(e),8,-1)}},6955(e,t,n){var r=n(2140),i=n(4901),a=n(2195),o=n(8227)(`toStringTag`),s=Object,c=a(function(){return arguments}())===`Arguments`,l=function(e,t){try{return e[t]}catch{}};e.exports=r?a:function(e){var t,n,r;return e===void 0?`Undefined`:e===null?`Null`:typeof(n=l(t=s(e),o))==`string`?n:c?a(t):(r=a(t))===`Object`&&i(t.callee)?`Arguments`:r}},7740(e,t,n){var r=n(9297),i=n(5031),a=n(7347),o=n(4913);e.exports=function(e,t,n){for(var s=i(t),c=o.f,l=a.f,u=0;u<s.length;u++){var d=s[u];!r(e,d)&&!(n&&r(n,d))&&c(e,d,l(t,d))}}},2211(e,t,n){e.exports=!n(9039)(function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})},2529(e){e.exports=function(e,t){return{value:e,done:t}}},6699(e,t,n){var r=n(3724),i=n(4913),a=n(6980);e.exports=r?function(e,t,n){return i.f(e,t,a(1,n))}:function(e,t,n){return e[t]=n,e}},6980(e){e.exports=function(e,t){return{enumerable:!(e&1),configurable:!(e&2),writable:!(e&4),value:t}}},4659(e,t,n){var r=n(3724),i=n(4913),a=n(6980);e.exports=function(e,t,n){r?i.f(e,t,a(0,n)):e[t]=n}},2106(e,t,n){var r=n(283),i=n(4913);e.exports=function(e,t,n){return n.get&&r(n.get,t,{getter:!0}),n.set&&r(n.set,t,{setter:!0}),i.f(e,t,n)}},6840(e,t,n){var r=n(4901),i=n(4913),a=n(283),o=n(9433);e.exports=function(e,t,n,s){s||={};var c=s.enumerable,l=s.name===void 0?t:s.name;if(r(n)&&a(n,l,s),s.global)c?e[t]=n:o(t,n);else{try{s.unsafe?e[t]&&(c=!0):delete e[t]}catch{}c?e[t]=n:i.f(e,t,{value:n,enumerable:!1,configurable:!s.nonConfigurable,writable:!s.nonWritable})}return e}},6279(e,t,n){var r=n(6840);e.exports=function(e,t,n){for(var i in t)r(e,i,t[i],n);return e}},9433(e,t,n){var r=n(4576),i=Object.defineProperty;e.exports=function(e,t){try{i(r,e,{value:t,configurable:!0,writable:!0})}catch{r[e]=t}return t}},3724(e,t,n){e.exports=!n(9039)(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})},4055(e,t,n){var r=n(4576),i=n(34),a=r.document,o=i(a)&&i(a.createElement);e.exports=function(e){return o?a.createElement(e):{}}},6837(e){var t=TypeError,n=9007199254740991;e.exports=function(e){if(e>n)throw new t(`Maximum allowed index exceeded`);return e}},5002(e){e.exports={IndexSizeError:{s:`INDEX_SIZE_ERR`,c:1,m:1},DOMStringSizeError:{s:`DOMSTRING_SIZE_ERR`,c:2,m:0},HierarchyRequestError:{s:`HIERARCHY_REQUEST_ERR`,c:3,m:1},WrongDocumentError:{s:`WRONG_DOCUMENT_ERR`,c:4,m:1},InvalidCharacterError:{s:`INVALID_CHARACTER_ERR`,c:5,m:1},NoDataAllowedError:{s:`NO_DATA_ALLOWED_ERR`,c:6,m:0},NoModificationAllowedError:{s:`NO_MODIFICATION_ALLOWED_ERR`,c:7,m:1},NotFoundError:{s:`NOT_FOUND_ERR`,c:8,m:1},NotSupportedError:{s:`NOT_SUPPORTED_ERR`,c:9,m:1},InUseAttributeError:{s:`INUSE_ATTRIBUTE_ERR`,c:10,m:1},InvalidStateError:{s:`INVALID_STATE_ERR`,c:11,m:1},SyntaxError:{s:`SYNTAX_ERR`,c:12,m:1},InvalidModificationError:{s:`INVALID_MODIFICATION_ERR`,c:13,m:1},NamespaceError:{s:`NAMESPACE_ERR`,c:14,m:1},InvalidAccessError:{s:`INVALID_ACCESS_ERR`,c:15,m:1},ValidationError:{s:`VALIDATION_ERR`,c:16,m:0},TypeMismatchError:{s:`TYPE_MISMATCH_ERR`,c:17,m:1},SecurityError:{s:`SECURITY_ERR`,c:18,m:1},NetworkError:{s:`NETWORK_ERR`,c:19,m:1},AbortError:{s:`ABORT_ERR`,c:20,m:1},URLMismatchError:{s:`URL_MISMATCH_ERR`,c:21,m:1},QuotaExceededError:{s:`QUOTA_EXCEEDED_ERR`,c:22,m:1},TimeoutError:{s:`TIMEOUT_ERR`,c:23,m:1},InvalidNodeTypeError:{s:`INVALID_NODE_TYPE_ERR`,c:24,m:1},DataCloneError:{s:`DATA_CLONE_ERR`,c:25,m:1}}},8727(e){e.exports=[`constructor`,`hasOwnProperty`,`isPrototypeOf`,`propertyIsEnumerable`,`toLocaleString`,`toString`,`valueOf`]},2839(e,t,n){var r=n(4576).navigator,i=r&&r.userAgent;e.exports=i?String(i):``},9519(e,t,n){var r=n(4576),i=n(2839),a=r.process,o=r.Deno,s=a&&a.versions||o&&o.version,c=s&&s.v8,l,u;c&&(l=c.split(`.`),u=l[0]>0&&l[0]<4?1:+(l[0]+l[1])),!u&&i&&(l=i.match(/Edge\/(\d+)/),(!l||l[1]>=74)&&(l=i.match(/Chrome\/(\d+)/),l&&(u=+l[1]))),e.exports=u},6193(e,t,n){var r=n(9504),i=Error,a=r(``.replace),o=(function(e){return String(new i(e).stack)})(`zxcasd`),s=/\n\s*at [^:]*:[^\n]*/,c=s.test(o);e.exports=function(e,t){if(c&&typeof e==`string`&&!i.prepareStackTrace)for(;t--;)e=a(e,s,``);return e}},6518(e,t,n){var r=n(4576),i=n(7347).f,a=n(6699),o=n(6840),s=n(9433),c=n(7740),l=n(2796);e.exports=function(e,t){var n=e.target,u=e.global,d=e.stat,f,p=u?r:d?r[n]||s(n,{}):r[n]&&r[n].prototype,m,h,g,_;if(p)for(m in t){if(g=t[m],e.dontCallGetSet?(_=i(p,m),h=_&&_.value):h=p[m],f=l(u?m:n+(d?`.`:`#`)+m,e.forced),!f&&h!==void 0){if(typeof g==typeof h)continue;c(g,h)}(e.sham||h&&h.sham)&&a(g,`sham`,!0),o(p,m,g,e)}}},9039(e){e.exports=function(e){try{return!!e()}catch{return!0}}},8745(e,t,n){var r=n(616),i=Function.prototype,a=i.apply,o=i.call;e.exports=typeof Reflect==`object`&&Reflect.apply||(r?o.bind(a):function(){return o.apply(a,arguments)})},6080(e,t,n){var r=n(7476),i=n(9306),a=n(616),o=r(r.bind);e.exports=function(e,t){return i(e),t===void 0?e:a?o(e,t):function(){return e.apply(t,arguments)}}},616(e,t,n){e.exports=!n(9039)(function(){var e=function(){}.bind();return typeof e!=`function`||e.hasOwnProperty(`prototype`)})},9565(e,t,n){var r=n(616),i=Function.prototype.call;e.exports=r?i.bind(i):function(){return i.apply(i,arguments)}},350(e,t,n){var r=n(3724),i=n(9297),a=Function.prototype,o=r&&Object.getOwnPropertyDescriptor,s=i(a,`name`);e.exports={EXISTS:s,PROPER:s&&function(){}.name===`something`,CONFIGURABLE:s&&(!r||r&&o(a,`name`).configurable)}},6706(e,t,n){var r=n(9504),i=n(9306);e.exports=function(e,t,n){try{return r(i(Object.getOwnPropertyDescriptor(e,t)[n]))}catch{}}},7476(e,t,n){var r=n(2195),i=n(9504);e.exports=function(e){if(r(e)===`Function`)return i(e)}},9504(e,t,n){var r=n(616),i=Function.prototype,a=i.call,o=r&&i.bind.bind(a,a);e.exports=r?o:function(e){return function(){return a.apply(e,arguments)}}},944(e){var t=TypeError;e.exports=function(e){var n=e&&e.alphabet;if(n===void 0||n===`base64`||n===`base64url`)return n||`base64`;throw new t("Incorrect `alphabet` option")}},7751(e,t,n){var r=n(4576),i=n(4901),a=function(e){return i(e)?e:void 0};e.exports=function(e,t){return arguments.length<2?a(r[e]):r[e]&&r[e][t]}},1767(e){e.exports=function(e){return{iterator:e,next:e.next,done:!1}}},8646(e,t,n){var r=n(9565),i=n(8551),a=n(1767),o=n(3085);e.exports=function(e,t){(!t||typeof e!=`string`)&&i(e);var n=o(e);return a(i(n===void 0?e:r(n,e)))}},8563(e,t,n){var r=n(9565),i=n(4901),a=n(8551),o=n(6823),s=n(3085),c=TypeError;e.exports=function(e,t){var n=arguments.length<2?s(e):t;if(i(n))return a(r(n,e));throw new c(o(e)+` is not iterable`)}},3085(e,t,n){var r=n(2195),i=n(4117),a=n(5966),o=n(8227)(`iterator`),s=Array.prototype;e.exports=function(e){if(!i(e))return a(e,o)||a(e,`@@iterator`)||(r(e)===`Arguments`?s[o]:void 0)}},5966(e,t,n){var r=n(9306),i=n(4117);e.exports=function(e,t){var n=e[t];return i(n)?void 0:r(n)}},3789(e,t,n){var r=n(9306),i=n(8551),a=n(9565),o=n(1291),s=n(1767),c=`Invalid size`,l=RangeError,u=TypeError,d=Math.max,f=function(e,t){this.set=e,this.size=d(t,0),this.has=r(e.has),this.keys=r(e.keys)};f.prototype={getIterator:function(){return s(i(a(this.keys,this.set)))},includes:function(e){return a(this.has,this.set,e)}},e.exports=function(e){i(e);var t=+e.size;if(t!==t)throw new u(c);var n=o(t);if(n<0)throw new l(c);return new f(e,n)}},4576(e){var t=function(e){return e&&e.Math===Math&&e};e.exports=t(typeof globalThis==`object`&&globalThis)||t(typeof window==`object`&&window)||t(typeof self==`object`&&self)||t(typeof global==`object`&&global)||t(typeof this==`object`&&this)||(function(){return this})()||Function(`return this`)()},9297(e,t,n){var r=n(9504),i=n(8981),a=r({}.hasOwnProperty);e.exports=Object.hasOwn||function(e,t){return a(i(e),t)}},421(e){e.exports={}},397(e,t,n){e.exports=n(7751)(`document`,`documentElement`)},5917(e,t,n){var r=n(3724),i=n(9039),a=n(4055);e.exports=!r&&!i(function(){return Object.defineProperty(a(`div`),"a",{get:function(){return 7}}).a!==7})},7055(e,t,n){var r=n(9504),i=n(9039),a=n(2195),o=Object,s=r(``.split);e.exports=i(function(){return!o(`z`).propertyIsEnumerable(0)})?function(e){return a(e)===`String`?s(e,``):o(e)}:o},3167(e,t,n){var r=n(4901),i=n(34),a=n(2967);e.exports=function(e,t,n){var o,s;return a&&r(o=t.constructor)&&o!==n&&i(s=o.prototype)&&s!==n.prototype&&a(e,s),e}},3706(e,t,n){var r=n(9504),i=n(4901),a=n(7629),o=r(Function.toString);i(a.inspectSource)||(a.inspectSource=function(e){return o(e)}),e.exports=a.inspectSource},1181(e,t,n){var r=n(8622),i=n(4576),a=n(34),o=n(6699),s=n(9297),c=n(7629),l=n(6119),u=n(421),d=`Object already initialized`,f=i.TypeError,p=i.WeakMap,m,h,g,_=function(e){return g(e)?h(e):m(e,{})},v=function(e){return function(t){var n;if(!a(t)||(n=h(t)).type!==e)throw new f(`Incompatible receiver, `+e+` required`);return n}};if(r||c.state){var y=c.state||=new p;y.get=y.get,y.has=y.has,y.set=y.set,m=function(e,t){if(y.has(e))throw new f(d);return t.facade=e,y.set(e,t),t},h=function(e){return y.get(e)||{}},g=function(e){return y.has(e)}}else{var b=l(`state`);u[b]=!0,m=function(e,t){if(s(e,b))throw new f(d);return t.facade=e,o(e,b,t),t},h=function(e){return s(e,b)?e[b]:{}},g=function(e){return s(e,b)}}e.exports={set:m,get:h,has:g,enforce:_,getterFor:v}},4209(e,t,n){var r=n(8227),i=n(6269),a=r(`iterator`),o=Array.prototype;e.exports=function(e){return e!==void 0&&(i.Array===e||o[a]===e)}},4376(e,t,n){var r=n(2195);e.exports=Array.isArray||function(e){return r(e)===`Array`}},1108(e,t,n){var r=n(6955);e.exports=function(e){var t=r(e);return t===`BigInt64Array`||t===`BigUint64Array`}},4901(e){var t=typeof document==`object`&&document.all;e.exports=t===void 0&&t!==void 0?function(e){return typeof e==`function`||e===t}:function(e){return typeof e==`function`}},2796(e,t,n){var r=n(9039),i=n(4901),a=/#|\.prototype\./,o=function(e,t){var n=c[s(e)];return n===u?!0:n===l?!1:i(t)?r(t):!!t},s=o.normalize=function(e){return String(e).replace(a,`.`).toLowerCase()},c=o.data={},l=o.NATIVE=`N`,u=o.POLYFILL=`P`;e.exports=o},4117(e){e.exports=function(e){return e==null}},34(e,t,n){var r=n(4901);e.exports=function(e){return typeof e==`object`?e!==null:r(e)}},3925(e,t,n){var r=n(34);e.exports=function(e){return r(e)||e===null}},6395(e){e.exports=!1},5810(e,t,n){var r=n(34),i=n(1181).get;e.exports=function(e){if(!r(e))return!1;var t=i(e);return!!t&&t.type===`RawJSON`}},757(e,t,n){var r=n(7751),i=n(4901),a=n(1625),o=n(7040),s=Object;e.exports=o?function(e){return typeof e==`symbol`}:function(e){var t=r(`Symbol`);return i(t)&&a(t.prototype,s(e))}},507(e,t,n){var r=n(9565);e.exports=function(e,t,n){for(var i=n?e:e.iterator,a=e.next,o,s;!(o=r(a,i)).done;)if(s=t(o.value),s!==void 0)return s}},2652(e,t,n){var r=n(6080),i=n(9565),a=n(8551),o=n(6823),s=n(4209),c=n(6198),l=n(1625),u=n(8563),d=n(3085),f=n(9539),p=TypeError,m=function(e,t){this.stopped=e,this.result=t},h=m.prototype;e.exports=function(e,t,n){var g=n&&n.that,_=!!(n&&n.AS_ENTRIES),v=!!(n&&n.IS_RECORD),y=!!(n&&n.IS_ITERATOR),b=!!(n&&n.INTERRUPTED),x=r(t,g),S,C,w,T,E,D,O,k=function(e){var t=S;return S=void 0,t&&f(t,`normal`),new m(!0,e)},A=function(e){return _?(a(e),b?x(e[0],e[1],k):x(e[0],e[1])):b?x(e,k):x(e)};if(v)S=e.iterator;else if(y)S=e;else{if(C=d(e),!C)throw new p(o(e)+` is not iterable`);if(s(C)){for(w=0,T=c(e);T>w;w++)if(E=A(e[w]),E&&l(h,E))return E;return new m(!1)}S=u(e,C)}for(D=v?e.next:S.next;!(O=i(D,S)).done;){var j=O.value;try{E=A(j)}catch(e){if(S)f(S,`throw`,e);else throw e}if(typeof E==`object`&&E&&l(h,E))return E}return new m(!1)}},6859(e){e.exports=function(e){e.iterator=e.next=e.nextHandler=e.mapper=e.predicate=e.inner=e.iterables=e.iters=e.openIters=e.padding=e.finishResults=e.buffer=null}},1385(e,t,n){var r=n(9539);e.exports=function(e,t,n){for(var i=e.length-1;i>=0;i--)if(e[i]!==void 0)try{n=r(e[i].iterator,t,n)}catch(e){t=`throw`,n=e}if(t===`throw`)throw n;return n}},9539(e,t,n){var r=n(9565),i=n(8551),a=n(5966);e.exports=function(e,t,n){var o,s;i(e);try{if(o=a(e,`return`),!o){if(t===`throw`)throw n;return n}o=r(o,e)}catch(e){s=!0,o=e}if(t===`throw`)throw n;if(s)throw o;return i(o),n}},9462(e,t,n){var r=n(9565),i=n(2360),a=n(6699),o=n(6279),s=n(8227),c=n(1181),l=n(5966),u=n(7657).IteratorPrototype,d=n(2529),f=n(9539),p=n(1385),m=n(6859),h=s(`toStringTag`),g=`IteratorHelper`,_=`WrapForValidIterator`,v=`normal`,y=`throw`,b=c.set,x=function(e){var t=c.getterFor(e?_:g);return o(i(u),{next:function(){var n=t(this);if(e)return n.nextHandler();if(n.done)return d(void 0,!0);try{var r=n.nextHandler();return n.done&&m(n),n.returnHandlerResult?r:d(r,n.done)}catch(e){throw n.done=!0,m(n),e}},return:function(){var n=t(this),i=n.iterator,a=n.inner,o=n.openIters,s=n.done;if(n.done=!0,e){var c=l(i,`return`);return c?r(c,i):d(void 0,!0)}if(m(n),s)return d(void 0,!0);if(a)try{f(a.iterator,v)}catch(e){return f(i,y,e)}if(o)try{p(o,v)}catch(e){if(i)return f(i,y,e);throw e}return i&&f(i,v),d(void 0,!0)}})},S=x(!0),C=x(!1);a(C,h,`Iterator Helper`),e.exports=function(e,t,n){var r=function(r,i){i?(i.iterator=r.iterator,i.next=r.next):i=r,i.type=t?_:g,i.returnHandlerResult=!!n,i.nextHandler=e,i.counter=0,i.done=!1,b(this,i)};return r.prototype=t?S:C,r}},684(e){e.exports=function(e,t){var n=typeof Iterator==`function`&&Iterator.prototype[e];if(n)try{n.call({next:null},t).next()}catch{return!0}}},4549(e,t,n){var r=n(4576);e.exports=function(e,t){var n=r.Iterator,i=n&&n.prototype,a=i&&i[e],o=!1;if(a)try{a.call({next:function(){return{done:!0}},return:function(){o=!0}},-1)}catch(e){e instanceof t||(o=!1)}if(!o)return a}},7657(e,t,n){var r=n(9039),i=n(4901),a=n(34),o=n(2360),s=n(2787),c=n(6840),l=n(8227),u=n(6395),d=l(`iterator`),f=!1,p,m,h;[].keys&&(h=[].keys(),`next`in h?(m=s(s(h)),m!==Object.prototype&&(p=m)):f=!0),!a(p)||r(function(){var e={};return p[d].call(e)!==e})?p={}:u&&(p=o(p)),i(p[d])||c(p,d,function(){return this}),e.exports={IteratorPrototype:p,BUGGY_SAFARI_ITERATORS:f}},6269(e){e.exports=Object.create?Object.create(null):{}},6198(e,t,n){var r=n(8014);e.exports=function(e){return r(e.length)}},283(e,t,n){var r=n(9504),i=n(9039),a=n(4901),o=n(9297),s=n(3724),c=n(350).CONFIGURABLE,l=n(3706),u=n(1181),d=u.enforce,f=u.get,p=String,m=Object.defineProperty,h=r(``.slice),g=r(``.replace),_=r([].join),v=s&&!i(function(){return m(function(){},`length`,{value:8}).length!==8}),y=String(String).split(`String`),b=e.exports=function(e,t,n){h(p(t),0,7)===`Symbol(`&&(t=`[`+g(p(t),/^Symbol\(([^)]*)\).*$/,`$1`)+`]`),n&&n.getter&&(t=`get `+t),n&&n.setter&&(t=`set `+t),(!o(e,`name`)||c&&e.name!==t)&&(s?m(e,`name`,{value:t,configurable:!0}):e.name=t),v&&n&&o(n,`arity`)&&e.length!==n.arity&&m(e,`length`,{value:n.arity});try{n&&o(n,`constructor`)&&n.constructor?s&&m(e,`prototype`,{writable:!1}):e.prototype&&=void 0}catch{}var r=d(e);return o(r,`source`)||(r.source=_(y,typeof t==`string`?t:``)),e};Function.prototype.toString=b(function(){return a(this)&&f(this).source||l(this)},`toString`)},2248(e,t,n){var r=n(9504),i=Map.prototype;e.exports={Map,set:r(i.set),get:r(i.get),has:r(i.has),remove:r(i.delete),proto:i}},741(e){var t=Math.ceil,n=Math.floor;e.exports=Math.trunc||function(e){var r=+e;return(r>0?n:t)(r)}},7819(e,t,n){e.exports=!n(9039)(function(){var e=`9007199254740993`,t=JSON.rawJSON(e);return!JSON.isRawJSON(t)||JSON.stringify(t)!==e})},6043(e,t,n){var r=n(9306),i=TypeError,a=function(e){var t,n;this.promise=new e(function(e,r){if(t!==void 0||n!==void 0)throw new i(`Bad Promise constructor`);t=e,n=r}),this.resolve=r(t),this.reject=r(n)};e.exports.f=function(e){return new a(e)}},2603(e,t,n){var r=n(655);e.exports=function(e,t){return e===void 0?arguments.length<2?``:t:r(e)}},4149(e){var t=RangeError;e.exports=function(e){if(e===e)return e;throw new t(`NaN is not allowed`)}},2360(e,t,n){var r=n(8551),i=n(6801),a=n(8727),o=n(421),s=n(397),c=n(4055),l=n(6119),u=`>`,d=`<`,f=`prototype`,p=`script`,m=l(`IE_PROTO`),h=function(){},g=function(e){return d+p+u+e+d+`/`+p+u},_=function(e){e.write(g(``)),e.close();var t=e.parentWindow.Object;return e=null,t},v=function(){var e=c(`iframe`),t=`java`+p+`:`,n;return e.style.display=`none`,s.appendChild(e),e.src=String(t),n=e.contentWindow.document,n.open(),n.write(g(`document.F=Object`)),n.close(),n.F},y,b=function(){try{y=new ActiveXObject(`htmlfile`)}catch{}b=typeof document<`u`?document.domain&&y?_(y):v():_(y);for(var e=a.length;e--;)delete b[f][a[e]];return b()};o[m]=!0,e.exports=Object.create||function(e,t){var n;return e===null?n=b():(h[f]=r(e),n=new h,h[f]=null,n[m]=e),t===void 0?n:i.f(n,t)}},6801(e,t,n){var r=n(3724),i=n(8686),a=n(4913),o=n(8551),s=n(5397),c=n(1072);t.f=r&&!i?Object.defineProperties:function(e,t){o(e);for(var n=s(t),r=c(t),i=r.length,l=0,u;i>l;)a.f(e,u=r[l++],n[u]);return e}},4913(e,t,n){var r=n(3724),i=n(5917),a=n(8686),o=n(8551),s=n(6969),c=TypeError,l=Object.defineProperty,u=Object.getOwnPropertyDescriptor,d=`enumerable`,f=`configurable`,p=`writable`;t.f=r?a?function(e,t,n){if(o(e),t=s(t),o(n),typeof e==`function`&&t===`prototype`&&`value`in n&&p in n&&!n[p]){var r=u(e,t);r&&r[p]&&(e[t]=n.value,n={configurable:f in n?n[f]:r[f],enumerable:d in n?n[d]:r[d],writable:!1})}return l(e,t,n)}:l:function(e,t,n){if(o(e),t=s(t),o(n),i)try{return l(e,t,n)}catch{}if(`get`in n||`set`in n)throw new c(`Accessors not supported`);return`value`in n&&(e[t]=n.value),e}},7347(e,t,n){var r=n(3724),i=n(9565),a=n(8773),o=n(6980),s=n(5397),c=n(6969),l=n(9297),u=n(5917),d=Object.getOwnPropertyDescriptor;t.f=r?d:function(e,t){if(e=s(e),t=c(t),u)try{return d(e,t)}catch{}if(l(e,t))return o(!i(a.f,e,t),e[t])}},8480(e,t,n){var r=n(1828),i=n(8727).concat(`length`,`prototype`);t.f=Object.getOwnPropertyNames||function(e){return r(e,i)}},3717(e,t){t.f=Object.getOwnPropertySymbols},2787(e,t,n){var r=n(9297),i=n(4901),a=n(8981),o=n(6119),s=n(2211),c=o(`IE_PROTO`),l=Object,u=l.prototype;e.exports=s?l.getPrototypeOf:function(e){var t=a(e);if(r(t,c))return t[c];var n=t.constructor;return i(n)&&t instanceof n?n.prototype:t instanceof l?u:null}},1625(e,t,n){e.exports=n(9504)({}.isPrototypeOf)},1828(e,t,n){var r=n(9504),i=n(9297),a=n(5397),o=n(9617).indexOf,s=n(421),c=r([].push);e.exports=function(e,t){var n=a(e),r=0,l=[],u;for(u in n)!i(s,u)&&i(n,u)&&c(l,u);for(;t.length>r;)i(n,u=t[r++])&&(~o(l,u)||c(l,u));return l}},1072(e,t,n){var r=n(1828),i=n(8727);e.exports=Object.keys||function(e){return r(e,i)}},8773(e,t){var n={}.propertyIsEnumerable,r=Object.getOwnPropertyDescriptor;t.f=r&&!n.call({1:2},1)?function(e){var t=r(this,e);return!!t&&t.enumerable}:n},2967(e,t,n){var r=n(6706),i=n(34),a=n(7750),o=n(3506);e.exports=Object.setPrototypeOf||(`__proto__`in{}?function(){var e=!1,t={},n;try{n=r(Object.prototype,`__proto__`,`set`),n(t,[]),e=t instanceof Array}catch{}return function(t,r){return a(t),o(r),i(t)&&(e?n(t,r):t.__proto__=r),t}}():void 0)},4270(e,t,n){var r=n(9565),i=n(4901),a=n(34),o=TypeError;e.exports=function(e,t){var n,s;if(t===`string`&&i(n=e.toString)&&!a(s=r(n,e))||i(n=e.valueOf)&&!a(s=r(n,e))||t!==`string`&&i(n=e.toString)&&!a(s=r(n,e)))return s;throw new o(`Can't convert object to primitive value`)}},5031(e,t,n){var r=n(7751),i=n(9504),a=n(8480),o=n(3717),s=n(8551),c=i([].concat);e.exports=r(`Reflect`,`ownKeys`)||function(e){var t=a.f(s(e)),n=o.f;return n?c(t,n(e)):t}},8235(e,t,n){var r=n(9504),i=n(9297),a=SyntaxError,o=parseInt,s=String.fromCharCode,c=r(``.charAt),l=r(``.slice),u=r(/./.exec),d={'\\"':`"`,"\\\\":`\\`,"\\/":`/`,"\\b":`\b`,"\\f":`\f`,"\\n":`
|
|
2
2
|
`,"\\r":`\r`,"\\t":` `},f=/^[\da-f]{4}$/i,p=/^[\u0000-\u001F]$/;e.exports=function(e,t){for(var n=!0,r=``;t<e.length;){var m=c(e,t);if(m===`\\`){var h=l(e,t,t+2);if(i(d,h))r+=d[h],t+=2;else if(h===`\\u`){t+=2;var g=l(e,t,t+4);if(!u(f,g))throw new a(`Bad Unicode escape at: `+t);r+=s(o(g,16)),t+=4}else throw new a(`Unknown escape sequence: "`+h+`"`)}else if(m===`"`){n=!1,t++;break}else{if(u(p,m))throw new a(`Bad control character in string literal at: `+t);r+=m,t++}}if(n)throw new a(`Unterminated string at: `+t);return{value:r,end:t}}},1103(e){e.exports=function(e){try{return{error:!1,value:e()}}catch(e){return{error:!0,value:e}}}},3438(e,t,n){var r=n(8551),i=n(34),a=n(6043);e.exports=function(e,t){if(r(e),i(t)&&t.constructor===e)return t;var n=a.f(e),o=n.resolve;return o(t),n.promise}},7750(e,t,n){var r=n(4117),i=TypeError;e.exports=function(e){if(r(e))throw new i(`Can't call method on `+e);return e}},9286(e,t,n){var r=n(4402),i=n(8469),a=r.Set,o=r.add;e.exports=function(e){var t=new a;return i(e,function(e){o(t,e)}),t}},3440(e,t,n){var r=n(7080),i=n(4402),a=n(9286),o=n(5170),s=n(3789),c=n(8469),l=n(507),u=i.has,d=i.remove;e.exports=function(e){var t=r(this),n=s(e),i=a(t);return o(i)<=n.size?c(i,function(e){n.includes(e)&&d(i,e)}):l(n.getIterator(),function(e){u(i,e)&&d(i,e)}),i}},4402(e,t,n){var r=n(9504),i=Set.prototype;e.exports={Set,add:r(i.add),has:r(i.has),remove:r(i.delete),proto:i}},8750(e,t,n){var r=n(7080),i=n(4402),a=n(5170),o=n(3789),s=n(8469),c=n(507),l=i.Set,u=i.add,d=i.has;e.exports=function(e){var t=r(this),n=o(e),i=new l;return a(t)>n.size?c(n.getIterator(),function(e){d(t,e)&&u(i,e)}):s(t,function(e){n.includes(e)&&u(i,e)}),i}},4449(e,t,n){var r=n(7080),i=n(4402).has,a=n(5170),o=n(3789),s=n(8469),c=n(507),l=n(9539);e.exports=function(e){var t=r(this),n=o(e);if(a(t)<=n.size)return s(t,function(e){if(n.includes(e))return!1},!0)!==!1;var u=n.getIterator();return c(u,function(e){if(i(t,e))return l(u.iterator,`normal`,!1)})!==!1}},3838(e,t,n){var r=n(7080),i=n(5170),a=n(8469),o=n(3789);e.exports=function(e){var t=r(this),n=o(e);return i(t)>n.size?!1:a(t,function(e){if(!n.includes(e))return!1},!0)!==!1}},8527(e,t,n){var r=n(7080),i=n(4402).has,a=n(5170),o=n(3789),s=n(507),c=n(9539);e.exports=function(e){var t=r(this),n=o(e);if(a(t)<n.size)return!1;var l=n.getIterator();return s(l,function(e){if(!i(t,e))return c(l.iterator,`normal`,!1)})!==!1}},8469(e,t,n){var r=n(9504),i=n(507),a=n(4402),o=a.Set,s=a.proto,c=r(s.forEach),l=r(s.keys),u=l(new o).next;e.exports=function(e,t,n){return n?i({iterator:l(e),next:u},t):c(e,t)}},4916(e,t,n){var r=n(7751),i=function(e){return{size:e,has:function(){return!1},keys:function(){return{next:function(){return{done:!0}}}}}},a=function(e){return{size:e,has:function(){return!0},keys:function(){throw Error(`e`)}}};e.exports=function(e,t){var n=r(`Set`);try{new n()[e](i(0));try{return new n()[e](i(-1)),!1}catch{if(!t)return!0;try{return new n()[e](a(-1/0)),!1}catch{return t(new n([1,2])[e](a(1/0)))}}}catch{return!1}}},9835(e){e.exports=function(e){try{var t=new Set,n=t[e]({size:0,has:function(){return!0},keys:function(){return Object.defineProperty({},"next",{get:function(){return t.clear(),t.add(4),function(){return{done:!0}}}})}});return n.size===1&&n.values().next().value===4}catch{return!1}}},5170(e,t,n){e.exports=n(6706)(n(4402).proto,`size`,`get`)||function(e){return e.size}},3650(e,t,n){var r=n(7080),i=n(4402),a=n(9286),o=n(3789),s=n(507),c=i.add,l=i.has,u=i.remove;e.exports=function(e){var t=r(this),n=o(e).getIterator(),i=a(t);return s(n,function(e){l(t,e)?u(i,e):c(i,e)}),i}},4204(e,t,n){var r=n(7080),i=n(4402).add,a=n(9286),o=n(3789),s=n(507);e.exports=function(e){var t=r(this),n=o(e).getIterator(),c=a(t);return s(n,function(e){i(c,e)}),c}},6119(e,t,n){var r=n(5745),i=n(3392),a=r(`keys`);e.exports=function(e){return a[e]||(a[e]=i(e))}},7629(e,t,n){var r=n(6395),i=n(4576),a=n(9433),o=`__core-js_shared__`,s=e.exports=i[o]||a(o,{});(s.versions||=[]).push({version:`3.50.0`,mode:r?`pure`:`global`,copyright:`© 2013–2025 Denis Pushkarev (zloirock.ru), 2025–2026 CoreJS Company (core-js.io). All rights reserved.`,license:`https://github.com/zloirock/core-js/blob/v3.50.0/LICENSE`,source:`https://github.com/zloirock/core-js`})},5745(e,t,n){var r=n(7629),i=Object.create||Object;e.exports=function(e,t){return r[e]||(r[e]=t||i(null))}},4495(e,t,n){var r=n(9519),i=n(9039),a=n(4576).String;e.exports=!!Object.getOwnPropertySymbols&&!i(function(){var e=Symbol(`symbol detection`);return!a(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&r&&r<41})},1240(e,t,n){e.exports=n(9504)(1.1.valueOf)},5610(e,t,n){var r=n(1291),i=Math.max,a=Math.min;e.exports=function(e,t){var n=r(e);return n<0?i(n+t,0):a(n,t)}},5854(e,t,n){var r=n(2777),i=TypeError;e.exports=function(e){var t=r(e,`number`);if(typeof t==`number`)throw new i(`Can't convert number to bigint`);return BigInt(t)}},5397(e,t,n){var r=n(7055),i=n(7750);e.exports=function(e){return r(i(e))}},1291(e,t,n){var r=n(741);e.exports=function(e){var t=+e;return t!==t||t===0?0:r(t)}},8014(e,t,n){var r=n(1291),i=Math.min;e.exports=function(e){var t=r(e);return t>0?i(t,9007199254740991):0}},8981(e,t,n){var r=n(7750),i=Object;e.exports=function(e){return i(r(e))}},9590(e,t,n){var r=n(1291),i=RangeError;e.exports=function(e){var t=r(e);if(t<0)throw new i(`The argument can't be less than 0`);return t}},2777(e,t,n){var r=n(9565),i=n(34),a=n(757),o=n(5966),s=n(4270),c=n(8227),l=TypeError,u=c(`toPrimitive`);e.exports=function(e,t){if(!i(e)||a(e))return e;var n=o(e,u),c;if(n){if(t===void 0&&(t=`default`),c=r(n,e,t),!i(c)||a(c))return c;throw new l(`Can't convert object to primitive value`)}return t===void 0&&(t=`number`),s(e,t)}},6969(e,t,n){var r=n(2777),i=n(757);e.exports=function(e){var t=r(e,`string`);return i(t)?t:t+``}},2140(e,t,n){var r=n(8227)(`toStringTag`),i={};i[r]=`z`,e.exports=String(i)===`[object z]`},655(e,t,n){var r=n(6955),i=String;e.exports=function(e){if(r(e)===`Symbol`)throw TypeError(`Cannot convert a Symbol value to a string`);return i(e)}},6823(e){var t=String;e.exports=function(e){try{return t(e)}catch{return`Object`}}},3392(e,t,n){var r=n(9504),i=0,a=Math.random(),o=r(1.1.toString);e.exports=function(e){return`Symbol(`+(e===void 0?``:e)+`)_`+o(++i+a,36)}},9143(e,t,n){var r=n(4576),i=n(9504),a=n(3972),o=n(3463),s=n(9297),c=n(2804),l=n(944),u=n(5169),d=c.c2i,f=c.c2iUrl,p=r.SyntaxError,m=r.TypeError,h=r.Array,g=i(``.charAt),_=Math.floor,v=function(e,t){for(var n=e.length;t<n;t++){var r=g(e,t);if(r!==` `&&r!==` `&&r!==`
|
|
3
3
|
`&&r!==`\f`&&r!==`\r`)break}return t},y=function(e,t,n){var r=e.length;r<4&&(e+=r===2?`AA`:`A`);var i=(t[g(e,0)]<<18)+(t[g(e,1)]<<12)+(t[g(e,2)]<<6)+t[g(e,3)],a=[i>>16&255,i>>8&255,i&255];if(r===2){if(n&&a[1]!==0)throw new p(`Extra bits`);return[a[0]]}if(r===3){if(n&&a[2]!==0)throw new p(`Extra bits`);return[a[0],a[1]]}return a},b=function(e,t,n){for(var r=t.length,i=0;i<r;i++)e[n+i]=t[i];return n+r};e.exports=function(e,t,n,r){o(e),a(t);var i=l(t)===`base64`?d:f,c=t?t.lastChunkHandling:void 0;if(c===void 0&&(c=`loose`),c!==`loose`&&c!==`strict`&&c!==`stop-before-partial`)throw new m("Incorrect `lastChunkHandling` option");n&&u(n.buffer);var x=e.length,S=n||h(_(x*3/4)),C=0,w=0,T=``,E=0;if(r)for(;;){if(E=v(e,E),E===x){if(T.length>0){if(c===`stop-before-partial`)break;if(c===`loose`){if(T.length===1)throw new p(`Malformed padding: exactly one additional character`);C=b(S,y(T,i,!1),C)}else throw new p(`Missing padding`)}w=x;break}var D=g(e,E);if(++E,D===`=`){if(T.length<2)throw new p(`Padding is too early`);if(E=v(e,E),T.length===2){if(E===x){if(c===`stop-before-partial`)break;throw new p(`Malformed padding: only one =`)}g(e,E)===`=`&&(++E,E=v(e,E))}if(E<x)throw new p(`Unexpected character after padding`);C=b(S,y(T,i,c===`strict`),C),w=x;break}if(!s(i,D))throw new p(`Unexpected character`);var O=r-C;if(O===1&&T.length===2||O===2&&T.length===3||(T+=D,T.length===4&&(C=b(S,y(T,i,!1),C),T=``,w=E,C===r)))break}return n||(S.length=C),{bytes:S,read:w,written:C}}},2303(e,t,n){var r=n(4576),i=n(9504),a=r.Uint8Array,o=r.SyntaxError,s=Math.min,c=i(``.match);e.exports=function(e,t){var n=e.length;if(n%2!=0)throw new o(`String should be an even number of characters`);for(var r=t?s(t.length,n/2):n/2,i=t||new a(r),l=c(e,/[\S\s]{2}/g),u=0;u<r;u++){var d=+(`0x`+l[u]+`0`);if(d!==d)throw new o(`String should only contain hex characters`);i[u]=d>>4}return{bytes:i,read:u<<1}}},7416(e,t,n){var r=n(9039),i=n(8227),a=n(3724),o=n(6395),s=i(`iterator`);e.exports=!r(function(){var e=new URL(`b?a=1&b=2&c=3`,`https://a`),t=e.searchParams,n=new URLSearchParams(`a=1&a=2&b=3`),r=``;return e.pathname=`c%20d`,t.forEach(function(e,n){t.delete(`b`),r+=n+e}),n.delete(`a`,2),n.delete(`b`,void 0),o&&(!e.toJSON||!n.has(`a`,1)||n.has(`a`,2)||!n.has(`a`,void 0)||n.has(`b`))||!t.size&&(o||!a)||!t.sort||e.href!==`https://a/c%20d?a=1&c=3`||t.get(`c`)!==`3`||String(new URLSearchParams(`?a=1`))!==`a=1`||!t[s]||new URL(`https://a@b`).username!==`a`||new URLSearchParams(new URLSearchParams(`a=b`)).get(`a`)!==`b`||new URL(`https://тест`).host!==`xn--e1aybc`||new URL(`https://a#б`).hash!==`#%D0%B1`||r!==`a1c3`||new URL(`https://x`,void 0).host!==`x`})},7040(e,t,n){e.exports=n(4495)&&!Symbol.sham&&typeof Symbol.iterator==`symbol`},8686(e,t,n){var r=n(3724),i=n(9039);e.exports=r&&i(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})},2812(e){var t=TypeError;e.exports=function(e,n){if(e<n)throw new t(`Not enough arguments`);return e}},8622(e,t,n){var r=n(4576),i=n(4901),a=r.WeakMap;e.exports=i(a)&&/native code/.test(String(a))},4995(e,t,n){var r=n(9504),i=WeakMap.prototype;e.exports={WeakMap,set:r(i.set),get:r(i.get),has:r(i.has),remove:r(i.delete)}},8227(e,t,n){var r=n(4576),i=n(5745),a=n(9297),o=n(3392),s=n(4495),c=n(7040),l=r.Symbol,u=i(`wks`),d=c?l.for||l:l&&l.withoutSetter||o;e.exports=function(e){return a(u,e)||(u[e]=s&&a(l,e)?l[e]:d(`Symbol.`+e)),u[e]}},4423(e,t,n){var r=n(6518),i=n(9617).includes,a=n(9039),o=n(6469),s=a(function(){return![,].includes()}),c=a(function(){return[,1].includes(void 0,1)});r({target:`Array`,proto:!0,forced:s||c},{includes:function(e){return i(this,e,arguments.length>1?arguments[1]:void 0)}}),o(`includes`)},4114(e,t,n){var r=n(6518),i=n(8981),a=n(6198),o=n(4527),s=n(6837);r({target:`Array`,proto:!0,arity:1,forced:n(9039)(function(){return[].push.call({length:4294967296},1)!==4294967297})||!function(){try{Object.defineProperty([],"length",{writable:!1}).push()}catch(e){return e instanceof TypeError}}()},{push:function(e){var t=i(this),n=a(t),r=arguments.length;s(n+r);for(var c=0;c<r;c++)t[n]=arguments[c],n++;return o(t,n),n}})},8111(e,t,n){var r=n(6518),i=n(4576),a=n(679),o=n(8551),s=n(4901),c=n(2787),l=n(2106),u=n(4659),d=n(9039),f=n(9297),p=n(8227),m=n(7657).IteratorPrototype,h=n(3724),g=n(6395),_=`constructor`,v=`Iterator`,y=p(`toStringTag`),b=TypeError,x=i[v],S=g||!s(x)||x.prototype!==m||!d(function(){x({})}),C=function(){if(a(this,m),c(this)===m)throw new b(`Abstract class Iterator not directly constructable`)},w=function(e,t){h?l(m,e,{configurable:!0,get:function(){return t},set:function(t){if(o(this),this===m)throw new b(`You can't redefine this property`);f(this,e)?this[e]=t:u(this,e,t)}}):m[e]=t};f(m,y)||w(y,v),(S||!f(m,_)||m[_]===Object)&&w(_,C),C.prototype=m,r({global:!0,constructor:!0,forced:S},{Iterator:C})},9314(e,t,n){var r=n(6518),i=n(9565),a=n(8551),o=n(1767),s=n(4149),c=n(9590),l=n(9539),u=n(9462),d=n(684),f=n(4549),p=n(6395),m=RangeError,h=1/0,g=!p&&!d(`drop`,0),_=!p&&!g&&f(`drop`,RangeError),v=p||g||_||!function(){try{Iterator.prototype.drop.call({next:function(){return{done:!0}}},9007199254740992)}catch(e){return e instanceof m}}(),y=u(function(){for(var e=this.iterator,t=this.next,n,r;this.remaining;)if(this.remaining--,n=a(i(t,e)),r=this.done=!!n.done,r)return;if(n=a(i(t,e)),r=this.done=!!n.done,!r)return n.value});r({target:`Iterator`,proto:!0,real:!0,forced:v},{drop:function(e){a(this);var t;try{if(t=c(s(+e)),t>9007199254740991&&t!==h)throw new m(`The argument should be a safe integer`)}catch(e){l(this,`throw`,e)}return _?i(_,this,t):new y(o(this),{remaining:t})}})},1148(e,t,n){var r=n(6518),i=n(9565),a=n(2652),o=n(9306),s=n(8551),c=n(1767),l=n(9539),u=n(4549)(`every`,TypeError);r({target:`Iterator`,proto:!0,real:!0,forced:u},{every:function(e){s(this);try{o(e)}catch(e){l(this,`throw`,e)}if(u)return i(u,this,e);var t=c(this),n=0;return!a(t,function(t,r){if(!e(t,n++))return r()},{IS_RECORD:!0,INTERRUPTED:!0}).stopped}})},2489(e,t,n){var r=n(6518),i=n(9565),a=n(9306),o=n(8551),s=n(1767),c=n(9462),l=n(6319),u=n(6395),d=n(9539),f=n(684),p=n(4549),m=!u&&!f(`filter`,function(){}),h=!u&&!m&&p(`filter`,TypeError),g=u||m||h,_=c(function(){for(var e=this.iterator,t=this.predicate,n=this.next,r,a,s;;){if(r=o(i(n,e)),a=this.done=!!r.done,a)return;if(s=r.value,l(e,t,[s,this.counter++],!0))return s}});r({target:`Iterator`,proto:!0,real:!0,forced:g},{filter:function(e){o(this);try{a(e)}catch(e){d(this,`throw`,e)}return h?i(h,this,e):new _(s(this),{predicate:e})}})},116(e,t,n){var r=n(6518),i=n(9565),a=n(2652),o=n(9306),s=n(8551),c=n(1767),l=n(9539),u=n(4549)(`find`,TypeError);r({target:`Iterator`,proto:!0,real:!0,forced:u},{find:function(e){s(this);try{o(e)}catch(e){l(this,`throw`,e)}if(u)return i(u,this,e);var t=c(this),n=0;return a(t,function(t,r){if(e(t,n++))return r(t)},{IS_RECORD:!0,INTERRUPTED:!0}).result}})},531(e,t,n){var r=n(6518),i=n(9565),a=n(9306),o=n(8551),s=n(1767),c=n(8646),l=n(9462),u=n(9539),d=n(9039),f=n(6395),p=n(684),m=n(4549),h=!f&&d(function(){return[1].values().flatMap(function(){return[1]}).find(function(){return!0})!==1}),g=!f&&!h&&!p(`flatMap`,function(){}),_=!f&&!h&&!g&&m(`flatMap`,TypeError),v=f||h||g||_,y=l(function(){for(var e=this.iterator,t=this.mapper,n,r;;){if(r=this.inner)try{if(n=o(i(r.next,r.iterator)),!n.done)return n.value;this.inner=null}catch(t){u(e,`throw`,t)}if(n=o(i(this.next,e)),this.done=!!n.done)return;try{this.inner=c(t(n.value,this.counter++),!1)}catch(t){u(e,`throw`,t)}}});r({target:`Iterator`,proto:!0,real:!0,forced:v},{flatMap:function(e){o(this);try{a(e)}catch(e){u(this,`throw`,e)}return _?i(_,this,e):new y(s(this),{mapper:e,inner:null})}})},7588(e,t,n){var r=n(6518),i=n(9565),a=n(2652),o=n(9306),s=n(8551),c=n(1767),l=n(9539),u=n(4549)(`forEach`,TypeError);r({target:`Iterator`,proto:!0,real:!0,forced:u},{forEach:function(e){s(this);try{o(e)}catch(e){l(this,`throw`,e)}if(u)return i(u,this,e);var t=c(this),n=0;a(t,function(t){e(t,n++)},{IS_RECORD:!0})}})},1701(e,t,n){var r=n(6518),i=n(9565),a=n(9306),o=n(8551),s=n(1767),c=n(9462),l=n(6319),u=n(9539),d=n(684),f=n(4549),p=n(6395),m=!p&&!d(`map`,function(){}),h=!p&&!m&&f(`map`,TypeError),g=p||m||h,_=c(function(){var e=this.iterator,t=o(i(this.next,e));if(!(this.done=!!t.done))return l(e,this.mapper,[t.value,this.counter++],!0)});r({target:`Iterator`,proto:!0,real:!0,forced:g},{map:function(e){o(this);try{a(e)}catch(e){u(this,`throw`,e)}return h?i(h,this,e):new _(s(this),{mapper:e})}})},3579(e,t,n){var r=n(6518),i=n(9565),a=n(2652),o=n(9306),s=n(8551),c=n(1767),l=n(9539),u=n(4549)(`some`,TypeError);r({target:`Iterator`,proto:!0,real:!0,forced:u},{some:function(e){s(this);try{o(e)}catch(e){l(this,`throw`,e)}if(u)return i(u,this,e);var t=c(this),n=0;return a(t,function(t,r){if(e(t,n++))return r()},{IS_RECORD:!0,INTERRUPTED:!0}).stopped}})},4972(e,t,n){var r=n(6518),i=n(9565),a=n(8551),o=n(1767),s=n(4149),c=n(9590),l=n(9462),u=n(9539),d=n(684),f=n(4549),p=n(6395),m=RangeError,h=1/0,g=!p&&!d(`take`,1),_=!p&&!g&&f(`take`,RangeError),v=p||g||_||!function(){try{Iterator.prototype.take.call({next:function(){return{done:!0}}},9007199254740992)}catch(e){return e instanceof m}}(),y=l(function(){var e=this.iterator;if(!this.remaining--)return this.done=!0,u(e,`normal`,void 0);var t=a(i(this.next,e));if(!(this.done=!!t.done))return t.value});r({target:`Iterator`,proto:!0,real:!0,forced:v},{take:function(e){a(this);var t;try{if(t=c(s(+e)),t>9007199254740991&&t!==h)throw new m(`The argument should be a safe integer`)}catch(e){u(this,`throw`,e)}return _?i(_,this,t):new y(o(this),{remaining:t})}})},1806(e,t,n){var r=n(6518),i=n(8551),a=n(4659),o=n(2652),s=n(1767);r({target:`Iterator`,proto:!0,real:!0},{toArray:function(){var e=[],t=0;return o(s(i(this)),function(n){a(e,t++,n)},{IS_RECORD:!0}),e}})},9112(e,t,n){var r=n(6518),i=n(3724),a=n(4576),o=n(7751),s=n(9504),c=n(9565),l=n(4901),u=n(34),d=n(4376),f=n(9297),p=n(655),m=n(6198),h=n(4659),g=n(9039),_=n(8235),v=n(4495),y=a.JSON,b=a.Number,x=a.SyntaxError,S=y&&y.parse,C=o(`Object`,`keys`),w=Object.getOwnPropertyDescriptor,T=s(``.charAt),E=s(``.slice),D=s(/./.exec),O=s([].push),k=/^\d$/,A=/^[1-9]$/,j=/^[\d-]$/,M=/^[\t\n\r ]$/,N=0,P=1,F=function(e,t){e=p(e);var n=new ee(e,0),r=n.parse(),i=r.value,a=n.skip(M,r.end);if(a<e.length)throw new x(`Unexpected extra character: "`+T(e,a)+`" after the parsed data at: `+a);return l(t)?I({"":i},``,t,r):i},I=function(e,t,n,r){var i=e[t],a=r&&i===r.value,o=a&&typeof r.source==`string`?{source:r.source}:{},s,l,p,h,g;if(u(i)){var _=d(i),v=a?r.nodes:_?[]:{};if(_)for(s=v.length,p=m(i),h=0;h<p;h++)L(i,h,I(i,``+h,n,h<s?v[h]:void 0));else for(l=C(i),p=m(l),h=0;h<p;h++)g=l[h],L(i,g,I(i,g,n,f(v,g)?v[g]:void 0))}return c(n,e,t,i,o)},L=function(e,t,n){if(i){var r=w(e,t);if(r&&!r.configurable)return}n===void 0?delete e[t]:h(e,t,n)},R=function(e,t,n,r){this.value=e,this.end=t,this.source=n,this.nodes=r},ee=function(e,t){this.source=e,this.index=t};ee.prototype={fork:function(e){return new ee(this.source,e)},parse:function(){var e=this.source,t=this.skip(M,this.index),n=this.fork(t),r=T(e,t);if(D(j,r))return n.number();switch(r){case`{`:return n.object();case`[`:return n.array();case`"`:return n.string();case`t`:return n.keyword(!0);case`f`:return n.keyword(!1);case`n`:return n.keyword(null)}throw new x(`Unexpected character: "`+r+`" at: `+t)},node:function(e,t,n,r,i){return new R(t,r,e?null:E(this.source,n,r),i)},object:function(){for(var e=this.source,t=this.index+1,n=!1,r={},i={},a=!1;t<e.length;){if(t=this.until([`"`,`}`],t),T(e,t)===`}`&&!n){t++,a=!0;break}var o=this.fork(t).string(),s=o.value;t=o.end,t=this.until([`:`],t)+1,t=this.skip(M,t),o=this.fork(t).parse(),h(i,s,o),h(r,s,o.value),t=this.until([`,`,`}`],o.end);var c=T(e,t);if(c===`,`)n=!0,t++;else if(c===`}`){t++,a=!0;break}}if(!a)throw new x(`Unterminated object at: `+t);return this.node(P,r,this.index,t,i)},array:function(){for(var e=this.source,t=this.index+1,n=!1,r=[],i=[],a=!1;t<e.length;){if(t=this.skip(M,t),T(e,t)===`]`&&!n){t++,a=!0;break}var o=this.fork(t).parse();if(O(i,o),O(r,o.value),t=this.until([`,`,`]`],o.end),T(e,t)===`,`)n=!0,t++;else if(T(e,t)===`]`){t++,a=!0;break}}if(!a)throw new x(`Unterminated array at: `+t);return this.node(P,r,this.index,t,i)},string:function(){var e=this.index,t=_(this.source,this.index+1);return this.node(N,t.value,e,t.end)},number:function(){var e=this.source,t=this.index,n=t;if(T(e,n)===`-`&&n++,T(e,n)===`0`)n++;else if(D(A,T(e,n)))n=this.skip(k,n+1);else throw new x(`Failed to parse number at: `+n);if(T(e,n)===`.`){var r=n+1;if(n=this.skip(k,r),r===n)throw new x(`Failed to parse number's fraction at: `+n)}if(T(e,n)===`e`||T(e,n)===`E`){n++,(T(e,n)===`+`||T(e,n)===`-`)&&n++;var i=n;if(n=this.skip(k,n),i===n)throw new x(`Failed to parse number's exponent value at: `+n)}return this.node(N,b(E(e,t,n)),t,n)},keyword:function(e){var t=``+e,n=this.index,r=n+t.length;if(E(this.source,n,r)!==t)throw new x(`Failed to parse value at: `+n);return this.node(N,e,n,r)},skip:function(e,t){for(var n=this.source;t<n.length&&D(e,T(n,t));t++);return t},until:function(e,t){t=this.skip(M,t);for(var n=T(this.source,t),r=0;r<e.length;r++)if(e[r]===n)return t;throw new x(`Unexpected character: "`+n+`" at: `+t)}};var te=g(function(){var e=`9007199254740993`,t;return S(e,function(e,n,r){t=r.source}),t!==e}),ne=v&&!g(function(){return 1/S(`-0 `)!=-1/0});r({target:`JSON`,stat:!0,forced:te},{parse:function(e,t){return ne&&!l(t)?S(e):F(e,t)}})},3110(e,t,n){var r=n(6518),i=n(7751),a=n(9565),o=n(9504),s=n(9039),c=n(4376),l=n(4901),u=n(34),d=n(2360),f=n(5810),p=n(757),m=n(2195),h=n(1240),g=n(9617).includes,_=n(9297),v=n(655),y=n(8235),b=n(3392),x=n(4495),S=n(7819),C=String,w=TypeError,T=i(`JSON`,`stringify`),E=i(`BigInt`),D=o(``.valueOf),O=o((!0).valueOf),k=E&&o(E.prototype.valueOf),A=o(/./.exec),j=o(``.charAt),M=o(``.charCodeAt),N=o(``.replace),P=o(``.slice),F=o([].push),I=o([].pop),L=o(1.1.toString),R=/[\uD800-\uDFFF]/g,ee=/^[\uD800-\uDBFF]$/,te=/^[\uDC00-\uDFFF]$/,ne=/^\d+$/,z=b(),re=b(),ie=b(),B=z.length,V=re.length,ae=!x||s(function(){var e=i(`Symbol`)(`stringify detection`);return T([e])!==`[null]`||T({a:e})!==`{}`||T(Object(e))!==`{}`}),oe=s(function(){return T(`\udf06\ud834`)!==`"\\udf06\\ud834"`||T(`\udead`)!==`"\\udead"`}),se=S?i(`JSON`,`isRawJSON`):f,ce=ae?function(e,t,n){return T(e,function(e,n){var r=a(t,this,e,n);if(!p(r))return r},n)}:T,le=function(e,t,n){var r=j(n,t-1),i=j(n,t+1);return A(ee,e)&&!A(te,i)||A(te,e)&&!A(ee,r)?`\\u`+L(M(e,0),16):e},ue=function(e){if(c(e)){for(var t=e.length,n=[],r=d(null),i=0;i<t;i++){var a=e[i],o;if(typeof a==`string`)o=a;else if(typeof a==`number`||m(a)===`Number`||m(a)===`String`)o=v(a);else continue;_(r,o)||(r[o]=!0,F(n,o))}return n}},de=function(e,t){try{return e(t),!0}catch{return!1}},fe=function(e){var t=m(e);return t===`Number`&&de(h,e)||t===`String`&&de(D,e)||t===`Boolean`&&de(O,e)||!!k&&t===`BigInt`&&de(k,e)},pe=function(e){if(!u(e)||l(e)||c(e))return!1;try{return!fe(e)}catch{return!0}},me=function(e,t){return{toJSON:function(){var n=e[t];if(u(n)||typeof n==`bigint`){var r=n.toJSON;l(r)&&(n=a(r,n,t))}return n}}},H=function(e){for(var t=0,n=e.length;t<n;t++)if(A(ne,e[t]))return re;return``},he=function(e,t,n){for(var r=d(null),i=0,a=t.length;i<a;i++){var o=t[i];r[n+o]=me(e,o)}return r[ie]=null,r};T&&r({target:`JSON`,stat:!0,arity:3,forced:ae||oe||!S},{stringify:function(e,t,n){var r=l(t)?t:void 0,i=r?void 0:ue(t),o=i&&H(i),s=[],u=[],d=[],f,p=!1,m=!0,h=ce(e,function(e,t){if(e=C(e),i){if(e===ie){I(u),f=I(d);return}if(m)m=!1;else if(this!==f&&!c(this)&&!g(i,e))return}else r&&(t=a(r,this,e,t));if(se(t))return S?t:(p=!0,z+(F(s,t.rawJSON)-1));if(i&&pe(t)){if(g(u,t))throw new w(`Converting circular structure to JSON`);var n=he(t,i,o);return F(u,t),F(d,f),f=n,o&&(p=!0),n}return t},n);if(typeof h!=`string`||(oe&&(h=N(h,R,le)),!p))return h;for(var _=``,v=h.length,b=0;b<v;b++){var x=j(h,b);if(x===`"`){var T=y(h,++b).end-1,E=P(h,b,T);P(E,0,B)===z?_+=s[P(E,B)]:P(E,0,V)===re?_+=`"`+P(E,V)+`"`:_+=`"`+E+`"`,b=T}else _+=x}return _}})},2731(e,t,n){var r=n(6518),i=n(9306),a=n(2248),o=n(6395),s=a.get,c=a.has,l=a.set;r({target:`Map`,proto:!0,real:!0,forced:o},{getOrInsertComputed:function(e,t){var n=c(this,e);if(i(t),n)return s(this,e);e===0&&1/e==-1/0&&(e=0);var r=t(e);return l(this,e,r),r}})},5367(e,t,n){var r=n(6518),i=n(2248),a=n(6395),o=i.get,s=i.has,c=i.set;r({target:`Map`,proto:!0,real:!0,forced:a},{getOrInsert:function(e,t){return s(this,e)?o(this,e):(c(this,e,t),t)}})},3068(e,t,n){var r=n(6518),i=n(9504),a=n(2652),o=RangeError,s=TypeError,c=1/0,l=NaN,u=Math.abs,d=Math.pow,f=i([].push),p=d(2,1023),m=d(2,53)-1,h=Number.MAX_VALUE,g=d(2,971),_={},v={},y={},b={},x={},S=function(e,t){var n=e+t;return{hi:n,lo:t-(n-e)}};r({target:`Math`,stat:!0},{sumPrecise:function(e){var t=[],n=0,r=b;switch(a(e,function(e){if(++n>m)throw new o(`Maximum allowed index exceeded`);if(typeof e!=`number`)throw new s(`Value is not a number`);r!==_&&(e===e?e===c?r=r===v?_:y:e===-c?r=r===y?_:v:(e!==0||1/e===c)&&(r===b||r===x)&&(r=x,f(t,e)):r=_)}),r){case _:return l;case v:return-c;case y:return c;case b:return-0}for(var i=[],d=0,C,w,T,E,D,O,k=0;k<t.length;k++){C=t[k];for(var A=0,j=0;j<i.length;j++){if(w=i[j],u(C)<u(w)&&(O=C,C=w,w=O),T=S(C,w),E=T.hi,D=T.lo,u(E)===c){var M=E===c?1:-1;d+=M,C=C-M*p-M*p,u(C)<u(w)&&(O=C,C=w,w=O),T=S(C,w),E=T.hi,D=T.lo}D!==0&&(i[A++]=D),C=E}i.length=A,C!==0&&f(i,C)}var N=i.length-1;if(E=0,D=0,d!==0){var P=N>=0?i[N]:0;if(N--,u(d)>1||d>0&&P>0||d<0&&P<0)return d>0?c:-c;if(T=S(d*p,P/2),E=T.hi,D=T.lo,D*=2,u(2*E)===c)return E>0?E===p&&D===-(g/2)&&N>=0&&i[N]<0?h:c:E===-p&&D===g/2&&N>=0&&i[N]>0?-h:-c;D!==0&&(i[++N]=D,D=0),E*=2}for(;N>=0&&(T=S(E,i[N--]),E=T.hi,D=T.lo,D===0););return N>=0&&(D<0&&i[N]<0||D>0&&i[N]>0)&&(w=D*2,C=E+w,w===C-E&&(E=C)),E}})},1689(e,t,n){var r=n(6518),i=n(4576),a=n(8745),o=n(7680),s=n(3438),c=n(6043),l=n(9306),u=n(1103),d=n(9039),f=i.Promise,p=!1;r({target:`Promise`,stat:!0,forced:!f||!f.try||d(function(){var e=f.resolve();return f.try(function(t){return p=t===8,e},8)!==e})||!p},{try:function(e){var t=arguments.length>1?o(arguments,1):[],n=u(function(){return a(l(e),void 0,t)});if(!n.error)return s(this,n.value);var r=c.f(this),i=r.reject;return i(n.value),r.promise}})},7642(e,t,n){var r=n(6518),i=n(3440),a=n(9039);r({target:`Set`,proto:!0,real:!0,forced:!n(4916)(`difference`,function(e){return e.size===0})||a(function(){var e={size:1,has:function(){return!0},keys:function(){var e=0;return{next:function(){var n=e++>1;return t.has(1)&&t.clear(),{done:n,value:2}}}}},t=new Set([1,2,3,4]);return t.difference(e).size!==3})},{difference:i})},8004(e,t,n){var r=n(6518),i=n(9039),a=n(8750);r({target:`Set`,proto:!0,real:!0,forced:!n(4916)(`intersection`,function(e){return e.size===2&&e.has(1)&&e.has(2)})||i(function(){return String(Array.from(new Set([1,2,3]).intersection(new Set([3,2]))))!==`3,2`})},{intersection:a})},3853(e,t,n){var r=n(6518),i=n(4449);r({target:`Set`,proto:!0,real:!0,forced:!n(4916)(`isDisjointFrom`,function(e){return!e})},{isDisjointFrom:i})},5876(e,t,n){var r=n(6518),i=n(3838);r({target:`Set`,proto:!0,real:!0,forced:!n(4916)(`isSubsetOf`,function(e){return e})},{isSubsetOf:i})},2475(e,t,n){var r=n(6518),i=n(8527);r({target:`Set`,proto:!0,real:!0,forced:!n(4916)(`isSupersetOf`,function(e){return!e})},{isSupersetOf:i})},5024(e,t,n){var r=n(6518),i=n(3650),a=n(9835);r({target:`Set`,proto:!0,real:!0,forced:!n(4916)(`symmetricDifference`)||!a(`symmetricDifference`)},{symmetricDifference:i})},1698(e,t,n){var r=n(6518),i=n(4204),a=n(9835);r({target:`Set`,proto:!0,real:!0,forced:!n(4916)(`union`)||!a(`union`)},{union:i})},9577(e,t,n){var r=n(4644),i=n(1108),a=n(6198),o=n(1291),s=n(5854),c=r.aTypedArray,l=r.getTypedArrayConstructor,u=r.exportTypedArrayMethod,d=RangeError,f=function(){try{new Int8Array(1).with(2,{valueOf:function(){throw 8}})}catch(e){return e===8}}(),p=f&&function(){try{new Int8Array(1).with(-.5,1)}catch{return!0}}();u(`with`,{with:function(e,t){var n=c(this),r=a(n),u=o(e),f=u<0?r+u:u,p=i(n)?s(t):+t;if(f>=r||f<0)throw new d(`Incorrect index`);for(var m=new(l(n))(r),h=0;h<r;h++)m[h]=h===f?p:n[h];return m}}.with,!f||p)},5213(e,t,n){var r=n(6518),i=n(4576),a=n(5370),o=n(9143),s=i.Uint8Array,c=!s||!s.fromBase64||!function(){try{s.fromBase64(`a`);return}catch{}try{s.fromBase64(``,null)}catch{return!0}}();s&&r({target:`Uint8Array`,stat:!0,forced:c},{fromBase64:function(e){return a(s,o(e,arguments.length>1?arguments[1]:void 0,null,9007199254740991).bytes)}})},6632(e,t,n){var r=n(6518),i=n(4576),a=n(9143),o=n(4154),s=i.Uint8Array,c=!s||!s.prototype.setFromBase64||!function(){var e=new s([255,255,255,255,255]);try{e.setFromBase64(``,null);return}catch{}try{e.setFromBase64(`a`);return}catch{}try{e.setFromBase64(`MjYyZg===`)}catch{return e[0]===50&&e[1]===54&&e[2]===50&&e[3]===255&&e[4]===255}}();s&&r({target:`Uint8Array`,proto:!0,forced:c},{setFromBase64:function(e){o(this);var t=a(e,arguments.length>1?arguments[1]:void 0,this,this.length);return{read:t.read,written:t.written}}})},4226(e,t,n){var r=n(6518),i=n(4576),a=n(3463),o=n(4154),s=n(5169),c=n(2303);function l(){try{new Uint8Array(new ArrayBuffer(16,{maxByteLength:1024})).setFromHex(`cafed00d`)}catch{return!0}}i.Uint8Array&&r({target:`Uint8Array`,proto:!0,forced:l()},{setFromHex:function(e){o(this),a(e),s(this.buffer);var t=c(e,this).read;return{read:t,written:t/2}}})},9486(e,t,n){var r=n(6518),i=n(4576),a=n(9504),o=n(3972),s=n(4154),c=n(5169),l=n(2804),u=n(944),d=l.i2c,f=l.i2cUrl,p=Math.floor,m=Math.ceil,h=a(``.charAt),g=i.Uint8Array,_=i.Array,v=a([].join),y=!g||!g.prototype.toBase64||!function(){try{new g().toBase64(null)}catch{return!0}}();g&&r({target:`Uint8Array`,proto:!0,forced:y},{toBase64:function(){var e=s(this),t=arguments.length?o(arguments[0]):void 0,n=u(t)===`base64`?d:f,r=!!t&&!!t.omitPadding;c(this.buffer);for(var i=0,a=e.length,l=_(r?p(a/3)*4+(a%3?a%3+1:0):m(a/3)*4),g=0,y,b=function(e){return h(n,y>>6*e&63)};i+2<a;i+=3)y=(e[i]<<16)+(e[i+1]<<8)+e[i+2],l[g++]=b(3),l[g++]=b(2),l[g++]=b(1),l[g++]=b(0);return i+2===a?(y=(e[i]<<16)+(e[i+1]<<8),l[g++]=b(3),l[g++]=b(2),l[g++]=b(1),r||(l[g++]=`=`)):i+1===a&&(y=e[i]<<16,l[g++]=b(3),l[g++]=b(2),r||(l[g++]=`=`,l[g++]=`=`)),v(l,``)}})},456(e,t,n){var r=n(6518),i=n(4576),a=n(9504),o=n(4154),s=n(5169),c=a(1.1.toString),l=a([].join),u=Array,d=i.Uint8Array,f=!d||!d.prototype.toHex||!(function(){try{return new d([255,255,255,255,255,255,255,255]).toHex()===`ffffffffffffffff`}catch{return!1}})();d&&r({target:`Uint8Array`,proto:!0,forced:f},{toHex:function(){o(this),s(this.buffer);for(var e=u(this.length),t=0,n=this.length;t<n;t++){var r=c(this[t],16);e[t]=r.length===1?`0`+r:r}return l(e,``)}})},9452(e,t,n){var r=n(6518),i=n(9306),a=n(6557),o=n(4328),s=n(4995),c=n(6395),l=s.get,u=s.has,d=s.set;r({target:`WeakMap`,proto:!0,real:!0,forced:c||!function(){try{WeakMap.prototype.getOrInsertComputed&&new WeakMap().getOrInsertComputed(1,function(){throw 1})}catch(e){return e instanceof TypeError}}()},{getOrInsertComputed:function(e,t){if(c||a(this),o(e),i(t),u(this,e))return l(this,e);var n=t(e);return d(this,e,n),n}})},8454(e,t,n){var r=n(6518),i=n(4995),a=n(6395),o=i.get,s=i.has,c=i.set;r({target:`WeakMap`,proto:!0,real:!0,forced:a},{getOrInsert:function(e,t){return s(this,e)?o(this,e):(c(this,e,t),t)}})},4979(e,t,n){var r=n(6518),i=n(4576),a=n(7751),o=n(6980),s=n(4913).f,c=n(9297),l=n(679),u=n(3167),d=n(2603),f=n(5002),p=n(6193),m=n(3724),h=n(6395),g=`DOMException`,_=a(`Error`),v=a(g),y=function(){l(this,b);var e=arguments.length,t=d(e<1?void 0:arguments[0]),n=new v(t,d(e<2?void 0:arguments[1],`Error`)),r=new _(t);return r.name=g,s(n,`stack`,o(1,p(r.stack,1))),u(n,this,y),n},b=y.prototype=v.prototype,x=`stack`in new _(g),S=`stack`in new v(1,2),C=v&&m&&Object.getOwnPropertyDescriptor(i,g),w=!!C&&!(C.writable&&C.configurable),T=x&&!w&&!S;r({global:!0,constructor:!0,forced:h||T},{DOMException:T?y:v});var E=a(g),D=E.prototype;if(D.constructor!==E){for(var O in h||s(D,`constructor`,o(1,E)),f)if(c(f,O)){var k=f[O],A=k.s;c(E,A)||s(E,A,o(6,k.c))}}},5781(e,t,n){var r=n(6518),i=n(7751),a=n(2812),o=n(655),s=n(7416),c=i(`URL`);r({target:`URL`,stat:!0,forced:!s},{parse:function(e){var t=a(arguments.length,1),n=o(e),r=t<2||arguments[1]===void 0?void 0:o(arguments[1]);try{return new c(n,r)}catch{return null}}})}},n={};function r(e){let i=n[e];if(i!==void 0)return i.exports;let a=n[e]={exports:{}};return t[e].call(a.exports,a,a.exports,r),a.exports}r.d=(e,t)=>{if(Array.isArray(t))for(var n=0;n<t.length;){var i=t[n++],a=t[n++];r.o(e,i)?a===0&&n++:a===0?Object.defineProperty(e,i,{enumerable:!0,value:t[n++]}):Object.defineProperty(e,i,{enumerable:!0,get:a})}else for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r(4423),r(4114),r(8111),r(2489),r(5367),r(2731),r(7642),r(8004),r(3853),r(5876),r(2475),r(5024),r(1698),r(9577),r(6632),r(4226),r(9486),r(456),r(5781);var i=typeof process==`object`&&process+``==`[object process]`&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!==`browser`),a=[1/0,1/0,-1/0,-1/0],o=new Float32Array(a),s=[.001,0,0,.001,0,0],c=`http://www.w3.org/2000/svg`,l={ANY:1,DISPLAY:2,PRINT:4,SAVE:8,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},u={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},d=`pdfjs_internal_id_`,f=`pdfjs_internal_editor_`,p={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},m={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,INK_COLOR_AND_OPACITY:24,HIGHLIGHT_COLOR:31,HIGHLIGHT_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},h={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},g={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_ADD_TO_PATH:4,STROKE_ADD_TO_PATH:5,FILL_STROKE_ADD_TO_PATH:6,ADD_TO_PATH:7,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},_={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},v={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26,RICHMEDIA:27},y={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},b={ERRORS:0,WARNINGS:1,INFOS:5},x={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93,rawFillPath:94},S={moveTo:0,lineTo:1,curveTo:2,quadraticCurveTo:3,closePath:4},C={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},w=b.WARNINGS;function T(e){Number.isInteger(e)&&(w=e)}function E(){return w}function D(e){w>=b.INFOS&&console.info(`Info: ${e}`)}function O(e){w>=b.WARNINGS&&console.warn(`Warning: ${e}`)}function k(e){throw Error(e)}function A(e,t){e||k(t)}function j(e){switch(e?.protocol){case`http:`:case`https:`:case`ftp:`:case`mailto:`:case`tel:`:return!0;default:return!1}}function M(e,t=null,n=null){if(!e)return null;if(n&&typeof e==`string`&&(n.addDefaultProtocol&&e.startsWith(`www.`)&&e.match(/\./g)?.length>=2&&(e=`http://${e}`),n.tryConvertEncoding))try{e=ae(e)}catch{}let r=t?URL.parse(e,t):URL.parse(e);return j(r)?r:null}function N(e,t,n=!1){let r=URL.parse(e);return r?(r.hash=t,r.href):n&&M(e,`http://example.com`)?e.split(`#`,1)[0]+`${t?`#${t}`:``}`:``}function P(e){return e.substring(e.lastIndexOf(`/`)+1)}function F(e,t,n,r=!1){return Object.defineProperty(e,t,{value:n,enumerable:!r,configurable:!0,writable:!1}),n}var I=function(){function e(e,t){this.message=e,this.name=t}return e.prototype=Error(),e.constructor=e,e}(),L=class extends I{constructor(e,t){super(e,`PasswordException`),this.code=t}},R=class extends I{constructor(e,t){super(e,`UnknownErrorException`),this.details=t}},ee=class extends I{constructor(e){super(e,`InvalidPDFException`)}},te=class extends I{constructor(e,t,n){super(e,`ResponseException`),this.status=t,this.missing=n}},ne=class extends I{constructor(e){super(e,`FormatError`)}},z=class extends I{constructor(e){super(e,`AbortException`)}};function re(e){(typeof e!=`object`||e?.length===void 0)&&k(`Invalid argument for bytesToString`);let t=e.length,n=8192;if(t<n)return String.fromCharCode.apply(null,e);let r=[];for(let i=0;i<t;i+=n){let a=Math.min(i+n,t),o=e.subarray(i,a);r.push(String.fromCharCode.apply(null,o))}return r.join(``)}function ie(e){typeof e!=`string`&&k(`Invalid argument for stringToBytes`);let t=e.length,n=new Uint8Array(t);for(let r=0;r<t;++r)n[r]=e.charCodeAt(r)&255;return n}var B=class{static get isLittleEndian(){let e=new Uint8Array(4);e[0]=1;let t=new Uint32Array(e.buffer,0,1);return F(this,`isLittleEndian`,t[0]===1)}static get isOffscreenCanvasSupported(){return F(this,`isOffscreenCanvasSupported`,typeof OffscreenCanvas<`u`)}static get isImageDecoderSupported(){return F(this,`isImageDecoderSupported`,typeof ImageDecoder<`u`)}static get isFloat16ArraySupported(){return F(this,`isFloat16ArraySupported`,typeof Float16Array<`u`)}static get isSanitizerSupported(){return F(this,`isSanitizerSupported`,typeof Sanitizer<`u`)}static get platform(){let{platform:e,userAgent:t}=navigator;return F(this,`platform`,{isAndroid:t.includes(`Android`),isLinux:e.includes(`Linux`),isMac:e.includes(`Mac`),isWindows:e.includes(`Win`),isFirefox:t.includes(`Firefox`)})}static get isCanvasFilterSupported(){let e;return this.isOffscreenCanvasSupported?e=new OffscreenCanvas(1,1).getContext(`2d`):typeof document<`u`&&(e=document.createElement(`canvas`).getContext(`2d`)),F(this,`isCanvasFilterSupported`,e?.filter!==void 0)}static get isAlphaColorInputSupported(){if(typeof document>`u`)return F(this,`isAlphaColorInputSupported`,!1);let e=document.createElement(`input`);return e.type=`color`,e.setAttribute(`alpha`,``),e.value=`#ff000080`,F(this,`isAlphaColorInputSupported`,e.value!==`#ff0000`)}static get isBackdropFilterSupported(){return F(this,`isBackdropFilterSupported`,typeof CSS<`u`&&CSS.supports(`backdrop-filter`,`blur(1px)`))}},V=class{static get hexNums(){return F(this,`hexNums`,Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`)))}static makeHexColor(e,t,n){return`#${this.hexNums[e]}${this.hexNums[t]}${this.hexNums[n]}`}static transform(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]}static multiplyByDOMMatrix(e,t){return[e[0]*t.a+e[2]*t.b,e[1]*t.a+e[3]*t.b,e[0]*t.c+e[2]*t.d,e[1]*t.c+e[3]*t.d,e[0]*t.e+e[2]*t.f+e[4],e[1]*t.e+e[3]*t.f+e[5]]}static applyTransform(e,t,n=0){let r=e[n],i=e[n+1];e[n]=r*t[0]+i*t[2]+t[4],e[n+1]=r*t[1]+i*t[3]+t[5]}static applyTransformToBezier(e,t,n=0){let r=t[0],i=t[1],a=t[2],o=t[3],s=t[4],c=t[5];for(let t=0;t<6;t+=2){let l=e[n+t],u=e[n+t+1];e[n+t]=l*r+u*a+s,e[n+t+1]=l*i+u*o+c}}static applyInverseTransform(e,t){let n=e[0],r=e[1],i=t[0]*t[3]-t[1]*t[2];e[0]=(n*t[3]-r*t[2]+t[2]*t[5]-t[4]*t[3])/i,e[1]=(-n*t[1]+r*t[0]+t[4]*t[1]-t[5]*t[0])/i}static axialAlignedBoundingBox(e,t,n){let r=t[0],i=t[1],a=t[2],o=t[3],s=t[4],c=t[5],l=e[0],u=e[1],d=e[2],f=e[3],p=r*l+s,m=p,h=r*d+s,g=h,_=o*u+c,v=_,y=o*f+c,b=y;if(i!==0||a!==0){let e=i*l,t=i*d,n=a*u,r=a*f;p+=n,g+=n,h+=r,m+=r,_+=e,b+=e,y+=t,v+=t}n[0]=Math.min(n[0],p,h,m,g),n[1]=Math.min(n[1],_,y,v,b),n[2]=Math.max(n[2],p,h,m,g),n[3]=Math.max(n[3],_,y,v,b)}static inverseTransform(e){let t=e[0]*e[3]-e[1]*e[2];return[e[3]/t,-e[1]/t,-e[2]/t,e[0]/t,(e[2]*e[5]-e[4]*e[3])/t,(e[4]*e[1]-e[5]*e[0])/t]}static singularValueDecompose2dScale(e,t){let n=e[0],r=e[1],i=e[2],a=e[3],o=n**2+r**2,s=n*i+r*a,c=i**2+a**2,l=(o+c)/2,u=Math.sqrt(l**2-(o*c-s**2));t[0]=Math.sqrt(l+u||1),t[1]=Math.sqrt(l-u||1)}static normalizeRect(e){let t=e.slice(0);return e[0]>e[2]&&(t[0]=e[2],t[2]=e[0]),e[1]>e[3]&&(t[1]=e[3],t[3]=e[1]),t}static intersect(e,t){let n=Math.max(Math.min(e[0],e[2]),Math.min(t[0],t[2])),r=Math.min(Math.max(e[0],e[2]),Math.max(t[0],t[2]));if(n>r)return null;let i=Math.max(Math.min(e[1],e[3]),Math.min(t[1],t[3])),a=Math.min(Math.max(e[1],e[3]),Math.max(t[1],t[3]));return i>a?null:[n,i,r,a]}static pointBoundingBox(e,t,n){n[0]=Math.min(n[0],e),n[1]=Math.min(n[1],t),n[2]=Math.max(n[2],e),n[3]=Math.max(n[3],t)}static rectBoundingBox(e,t,n,r,i){i[0]=Math.min(i[0],e,n),i[1]=Math.min(i[1],t,r),i[2]=Math.max(i[2],e,n),i[3]=Math.max(i[3],t,r)}static#e(e,t,n,r,i,a,o,s,c,l){if(c<=0||c>=1)return;let u=1-c,d=c*c,f=d*c,p=u*(u*(u*e+3*c*t)+3*d*n)+f*r,m=u*(u*(u*i+3*c*a)+3*d*o)+f*s;l[0]=Math.min(l[0],p),l[1]=Math.min(l[1],m),l[2]=Math.max(l[2],p),l[3]=Math.max(l[3],m)}static#t(e,t,n,r,i,a,o,s,c,l,u,d){if(Math.abs(c)<1e-12){Math.abs(l)>=1e-12&&this.#e(e,t,n,r,i,a,o,s,-u/l,d);return}let f=l**2-4*u*c;if(f<0)return;let p=Math.sqrt(f),m=2*c;this.#e(e,t,n,r,i,a,o,s,(-l+p)/m,d),this.#e(e,t,n,r,i,a,o,s,(-l-p)/m,d)}static bezierBoundingBox(e,t,n,r,i,a,o,s,c){c[0]=Math.min(c[0],e,o),c[1]=Math.min(c[1],t,s),c[2]=Math.max(c[2],e,o),c[3]=Math.max(c[3],t,s),this.#t(e,n,i,o,t,r,a,s,3*(-e+3*(n-i)+o),6*(e-2*n+i),3*(n-e),c),this.#t(e,n,i,o,t,r,a,s,3*(-t+3*(r-a)+s),6*(t-2*r+a),3*(r-t),c)}};function ae(e){return decodeURIComponent(escape(e))}var oe=null,se=null;function ce(e){return oe||(oe=/([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu,se=new Map([[`ſt`,`ſt`]])),e.replaceAll(oe,(e,t,n)=>t?t.normalize(`NFKC`):se.get(n))}function le(){if(typeof crypto.randomUUID==`function`)return crypto.randomUUID();let e=new Uint8Array(32);return crypto.getRandomValues(e),re(e)}function ue(e,t,n){if(!Array.isArray(n)||n.length<2)return!1;let[r,i,...a]=n;if(!e(r)&&!Number.isInteger(r)||!t(i))return!1;let o=a.length,s=!0;switch(i.name){case`XYZ`:if(o<2||o>3)return!1;break;case`Fit`:case`FitB`:return o===0;case`FitH`:case`FitBH`:case`FitV`:case`FitBV`:if(o>1)return!1;break;case`FitR`:if(o!==4)return!1;s=!1;break;default:return!1}for(let e of a)if(!(typeof e==`number`||s&&e===null))return!1;return!0}var de=()=>[],fe=()=>new Map,pe=()=>Object.create(null),me=()=>new Set;typeof Blob.prototype.bytes!=`function`&&(Blob.prototype.bytes=async function(){return new Uint8Array(await this.arrayBuffer())}),typeof Response.prototype.bytes!=`function`&&(Response.prototype.bytes=async function(){return new Uint8Array(await this.arrayBuffer())}),typeof Iterator.prototype.join!=`function`&&(Iterator.prototype.join=function(e){return[...this].join(e)}),r(1701);function H(e,t,n){return Math.min(Math.max(e,t),n)}var he=class e{constructor({viewBox:e,userUnit:t,scale:n,rotation:r,offsetX:i=0,offsetY:a=0,dontFlip:o=!1}){this.viewBox=e,this.userUnit=t,this.scale=n,this.rotation=r,this.offsetX=i,this.offsetY=a,n*=t;let s=(e[2]+e[0])/2,c=(e[3]+e[1])/2,l,u,d,f;switch(r%=360,r<0&&(r+=360),r){case 180:l=-1,u=0,d=0,f=1;break;case 90:l=0,u=1,d=1,f=0;break;case 270:l=0,u=-1,d=-1,f=0;break;case 0:l=1,u=0,d=0,f=-1;break;default:throw Error(`PageViewport: Invalid rotation, must be a multiple of 90 degrees.`)}o&&(d=-d,f=-f);let p,m,h,g;l===0?(p=Math.abs(c-e[1])*n+i,m=Math.abs(s-e[0])*n+a,h=(e[3]-e[1])*n,g=(e[2]-e[0])*n):(p=Math.abs(s-e[0])*n+i,m=Math.abs(c-e[1])*n+a,h=(e[2]-e[0])*n,g=(e[3]-e[1])*n),this.transform=[l*n,u*n,d*n,f*n,p-l*n*s-d*n*c,m-u*n*s-f*n*c],this.width=h,this.height=g}get rawDims(){let e=this.viewBox;return F(this,`rawDims`,{pageWidth:e[2]-e[0],pageHeight:e[3]-e[1],pageX:e[0],pageY:e[1]})}clone({scale:t=this.scale,rotation:n=this.rotation,offsetX:r=this.offsetX,offsetY:i=this.offsetY,dontFlip:a=!1}={}){return new e({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:n,offsetX:r,offsetY:i,dontFlip:a})}convertToViewportPoint(e,t){let n=[e,t];return V.applyTransform(n,this.transform),n}convertToPdfPoint(e,t){let n=[e,t];return V.applyInverseTransform(n,this.transform),n}},ge=class e{static textContent(t){let n=[],r={items:n,styles:Object.create(null)};function i(t){if(!t)return;let r=null,a=t.name;if(a===`#text`)r=t.value;else if(e.shouldBuildText(a))t?.attributes?.textContent?r=t.attributes.textContent:t.value&&(r=t.value);else return;if(r!==null&&n.push({str:r}),t.children)for(let e of t.children)i(e)}return i(t),r}static shouldBuildText(e){return e!==`textarea`&&e!==`input`&&e!==`option`&&e!==`select`}},_e=/url\(|image-set\(/i,ve=/^on/i,ye=class{static get _allowedHtmlElements(){return F(this,`_allowedHtmlElements`,new Set([`a`,`b`,`br`,`button`,`div`,`i`,`img`,`input`,`label`,`li`,`ol`,`option`,`p`,`select`,`span`,`sub`,`sup`,`textarea`,`ul`]))}static get _allowedSvgElements(){return F(this,`_allowedSvgElements`,new Set([`ellipse`,`line`,`path`,`rect`,`svg`]))}static get _allowedRichTextElements(){return F(this,`_allowedRichTextElements`,new Set([`a`,`b`,`br`,`div`,`i`,`li`,`ol`,`p`,`span`,`sub`,`sup`,`ul`]))}static get _allowedRichTextAttributes(){return F(this,`_allowedRichTextAttributes`,new Set([`class`,`dir`,`style`]))}static get _allowedRichTextStyles(){return F(this,`_allowedRichTextStyles`,new Set(`color.font.fontFamily.fontSize.fontStretch.fontStyle.fontWeight.kerningMode.letterSpacing.lineHeight.margin.marginBottom.marginLeft.marginRight.marginTop.orphans.paddingLeft.paddingRight.breakAfter.breakBefore.breakInside.tabInterval.tabStop.textAlign.textDecoration.textIndent.transform.verticalAlign.widows`.split(`.`)))}static setupStorage(e,t,n,r,i){let a=r.getValue(t,{value:null});switch(n.name){case`textarea`:if(a.value!==null&&(e.textContent=a.value),i===`print`)break;e.addEventListener(`input`,e=>{r.setValue(t,{value:e.target.value})});break;case`input`:if(n.attributes.type===`radio`||n.attributes.type===`checkbox`){if(a.value===n.attributes.xfaOn?e.setAttribute(`checked`,!0):a.value===n.attributes.xfaOff&&e.removeAttribute(`checked`),i===`print`)break;e.addEventListener(`change`,e=>{r.setValue(t,{value:e.target.checked?e.target.getAttribute(`xfaOn`):e.target.getAttribute(`xfaOff`)})})}else{if(a.value!==null&&e.setAttribute(`value`,a.value),i===`print`)break;e.addEventListener(`input`,e=>{r.setValue(t,{value:e.target.value})})}break;case`select`:if(a.value!==null){e.setAttribute(`value`,a.value);for(let e of n.children)e.attributes.value===a.value?e.attributes.selected=!0:Object.hasOwn(e.attributes,`selected`)&&delete e.attributes.selected}e.addEventListener(`input`,e=>{let n=e.target.options,i=n.selectedIndex===-1?``:n[n.selectedIndex].value;r.setValue(t,{value:i})})}}static setAttributes({html:e,element:t,storage:n=null,intent:r,linkService:i}){let{attributes:a}=t,o=e instanceof HTMLAnchorElement;a.type===`radio`&&(a.name=`${a.name}-${r}`);for(let[t,n]of Object.entries(a))if(n!=null&&!ve.test(t)&&(r!==`richText`||this._allowedRichTextAttributes.has(t)))switch(t){case`class`:n.length&&e.setAttribute(t,n.join(` `));break;case`dataId`:break;case`id`:e.setAttribute(`data-element-id`,n);break;case`style`:if(r===`richText`){let t=this._allowedRichTextStyles;for(let[r,i]of Object.entries(n))t.has(r)&&!_e.test(i)&&(e.style[r]=i)}else Object.assign(e.style,n);break;case`textContent`:e.textContent=n;break;default:(!o||t!==`href`&&t!==`newWindow`)&&e.setAttribute(t,n)}o&&i?.addLinkAttributes(e,a.href,a.newWindow),n&&a.dataId&&this.setupStorage(e,a.dataId,t,n)}static#e(e,t,n){return n===`richText`?!t&&this._allowedRichTextElements.has(e)?document.createElement(e):null:t?t===c&&this._allowedSvgElements.has(e)?document.createElementNS(c,e):null:this._allowedHtmlElements.has(e)?document.createElement(e):null}static render(e){let t=e.annotationStorage,n=e.linkService,r=e.xfaHtml,i=e.intent||`display`,a=this.#e(r.name,r.attributes?.xmlns,i)??document.createElement(`div`);r.attributes&&this.setAttributes({html:a,element:r,intent:i,linkService:n});let o=i!==`richText`,s=e.div;if(s.append(a),e.viewport){let t=`matrix(${e.viewport.transform.join(`,`)})`;s.style.transform=t}o&&s.setAttribute(`class`,`xfaLayer xfaFont`);let c=[];if(r.children.length===0){if(r.value){let e=document.createTextNode(r.value);a.append(e),o&&ge.shouldBuildText(r.name)&&c.push(e)}return{textDivs:c}}let l=[[r,-1,a]];for(;l.length>0;){let[e,r,a]=l.at(-1);if(r+1===e.children.length){l.pop();continue}let s=e.children[++l.at(-1)[1]];if(s===null)continue;let{name:u}=s;if(u===`#text`){let e=document.createTextNode(s.value);c.push(e),a.append(e);continue}let d=this.#e(u,s.attributes?.xmlns,i);if(d){if(a.append(d),s.attributes&&this.setAttributes({html:d,element:s,storage:t,intent:i,linkService:n}),s.children?.length>0)l.push([s,-1,d]);else if(s.value){let e=document.createTextNode(s.value);o&&ge.shouldBuildText(u)&&c.push(e),d.append(e)}}}for(let e of s.querySelectorAll(`.xfaNonInteractive input, .xfaNonInteractive textarea`))e.setAttribute(`readOnly`,!0);return{textDivs:c}}static update(e){let t=`matrix(${e.viewport.transform.join(`,`)})`;e.div.style.transform=t,e.div.hidden=!1}static getPageViewport(e,{scale:t=1,rotation:n=0}){let{width:r,height:i}=e.attributes.style;return new he({viewBox:[0,0,parseInt(r,10),parseInt(i,10)],userUnit:1,scale:t,rotation:n})}},be=class{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF};async function xe(e,t=`text`){if(Oe(e,document.baseURI)){let n=await fetch(e);if(!n.ok)throw Error(n.statusText);switch(t){case`blob`:return n.blob();case`bytes`:return n.bytes();case`json`:return n.json()}return n.text()}return new Promise((n,r)=>{let i=new XMLHttpRequest;i.open(`GET`,e,!0),i.responseType=t===`bytes`?`arraybuffer`:t,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(i.status===200||i.status===0){switch(t){case`bytes`:n(new Uint8Array(i.response));return;case`blob`:case`json`:n(i.response);return}n(i.responseText);return}r(Error(i.statusText))}},i.send(null)})}var Se=class extends I{constructor(e,t=0){super(e,`RenderingCancelledException`),this.extraDelay=t}};function Ce(e){let t=e.length,n=0;for(;n<t&&e[n].trim()===``;)n++;return e.substring(n,n+5).toLowerCase()===`data:`}function we(e){return typeof e==`string`&&/\.pdf$/i.test(e)}function Te(e){return[e]=e.split(/[#?]/,1),P(e)}function Ee(e,t=`document.pdf`){if(typeof e!=`string`)return t;if(Ce(e))return O(`getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.`),t;let n=(e=>{try{return new URL(e)}catch{}try{return new URL(decodeURIComponent(e))}catch{}try{return new URL(e,`https://foo.bar`)}catch{}try{return new URL(decodeURIComponent(e),`https://foo.bar`)}catch{}return null})(e);if(!n)return t;let r=e=>{try{let t=decodeURIComponent(e);return t.includes(`/`)&&(t=P(t),t.length===4&&i.test(t))?e:t}catch{return e}},i=/\.pdf$/i,a=P(n.pathname);if(i.test(a))return r(a);if(n.searchParams.size>0){let e=e=>[...e].findLast(e=>i.test(e)),t=e(n.searchParams.values())??e(n.searchParams.keys());if(t)return r(t)}if(n.hash){let{hash:e}=n,t=-1;for(let{index:n}of e.matchAll(/\.pdf\b/gi))t=n;if(t>0){let n=t;for(;n>0&&!`/?#=`.includes(e[n-1]);)n--;if(n<t)return r(e.slice(n,t+4))}}return t}var De=class{#e=new Map;times=[];time(e){this.#e.has(e)&&O(`Timer is already running for ${e}`),this.#e.set(e,Date.now())}timeEnd(e){this.#e.has(e)||O(`Timer has not been started for ${e}`),this.times.push({name:e,start:this.#e.get(e),end:Date.now()}),this.#e.delete(e)}toString(){let e=Math.max(...this.times.map(e=>e.name.length));return this.times.map(t=>`${t.name.padEnd(e)} ${t.end-t.start}ms\n`).join(``)}};function Oe(e,t){let n=t?URL.parse(e,t):URL.parse(e);return/https?:/.test(n?.protocol??``)}function ke(e){e.preventDefault()}function U(e){e.preventDefault(),e.stopPropagation()}var Ae=class{static#e;static toDateObject(e){if(e instanceof Date)return e;if(!e||typeof e!=`string`)return null;this.#e||=RegExp(`^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+\\-])?(\\d{2})?'?(\\d{2})?'?`);let t=this.#e.exec(e);if(!t)return null;let n=parseInt(t[1],10),r=parseInt(t[2],10);r=r>=1&&r<=12?r-1:0;let i=parseInt(t[3],10);i=i>=1&&i<=31?i:1;let a=parseInt(t[4],10);a=a>=0&&a<=23?a:0;let o=parseInt(t[5],10);o=o>=0&&o<=59?o:0;let s=parseInt(t[6],10);s=s>=0&&s<=59?s:0;let c=t[7]||`Z`,l=parseInt(t[8],10);l=l>=0&&l<=23?l:0;let u=parseInt(t[9],10)||0;return u=u>=0&&u<=59?u:0,c===`-`?(a+=l,o+=u):c===`+`&&(a-=l,o-=u),new Date(Date.UTC(n,r,i,a,o,s))}};function je(e){if(e.startsWith(`#`)){let t=e.slice(1);return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16),t.length>=8?parseInt(t.slice(6,8),16)/255:1]}if(e.startsWith(`rgb(`)){let[t,n,r]=e.slice(4,-1).split(`,`).map(e=>parseInt(e,10));return[t,n,r,1]}if(e.startsWith(`rgba(`)){let t=e.slice(5,-1).split(`,`);return[parseInt(t[0],10),parseInt(t[1],10),parseInt(t[2],10),parseFloat(t[3])]}let t=e.match(/^color\(srgb\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)(?:\s*\/\s*([\d.]+|none))?\)$/);return t?[Math.round(parseFloat(t[1])*255),Math.round(parseFloat(t[2])*255),Math.round(parseFloat(t[3])*255),t[4]!==void 0&&t[4]!==`none`?parseFloat(t[4]):1]:null}function Me(e){let t=je(e);return t?t.slice(0,3):(O(`Not a valid color format: "${e}"`),[0,0,0])}function Ne(e){let t=document.createElement(`span`);t.style.visibility=`hidden`,t.style.colorScheme=`only light`,document.body.append(t);for(let n of e.keys()){t.style.color=n;let r=window.getComputedStyle(t).color;e.set(n,Me(r))}t.remove()}function W(e){let{a:t,b:n,c:r,d:i,e:a,f:o}=e.getTransform();return[t,n,r,i,a,o]}function Pe(e){let{a:t,b:n,c:r,d:i,e:a,f:o}=e.getTransform().invertSelf();return[t,n,r,i,a,o]}function Fe(e,t,n=!1,r=!0){if(t instanceof he){let{pageWidth:r,pageHeight:i}=t.rawDims,{style:a}=e,o=`round(down, var(--total-scale-factor) * ${r}px, var(--scale-round-x))`,s=`round(down, var(--total-scale-factor) * ${i}px, var(--scale-round-y))`;!n||t.rotation%180==0?(a.width=o,a.height=s):(a.width=s,a.height=o)}r&&e.setAttribute(`data-main-rotation`,t.rotation)}var Ie=class e{constructor(){let{pixelRatio:t}=e;this.sx=t,this.sy=t}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}limitCanvas(t,n,r,i,a=-1){let o=1/0,s=1/0,c=1/0;r=e.capPixels(r,a),r>0&&(o=Math.sqrt(r/(t*n))),i!==-1&&(s=i/t,c=i/n);let l=Math.min(o,s,c);return this.sx>l||this.sy>l?(this.sx=l,this.sy=l,!0):!1}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(e,t){if(t>=0){let n=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+t/100));return e>0?Math.min(e,n):n}return e}},Le=[`image/apng`,`image/avif`,`image/bmp`,`image/gif`,`image/jpeg`,`image/png`,`image/svg+xml`,`image/webp`,`image/x-icon`],Re=class{static get isDarkMode(){return F(this,`isDarkMode`,!!window?.matchMedia?.(`(prefers-color-scheme: dark)`).matches)}},ze=class{static get commentForegroundColor(){let e=document.createElement(`span`);e.classList.add(`comment`,`sidebar`);let{style:t}=e;t.width=t.height=`0`,t.display=`none`,t.color=`var(--comment-fg-color)`,document.body.append(e);let{color:n}=window.getComputedStyle(e);return e.remove(),F(this,`commentForegroundColor`,Me(n))}};function Be(e,t){t=H(t??1,0,1);let n=255*(1-t);return e.map(e=>Math.round(e*t+n))}function Ve(e,t){let n=e[0]/255,r=e[1]/255,i=e[2]/255,a=Math.max(n,r,i),o=Math.min(n,r,i),s=(a+o)/2;if(a===o)t[0]=t[1]=0;else{let e=a-o;switch(t[1]=s<.5?e/(a+o):e/(2-a-o),a){case n:t[0]=((r-i)/e+(r<i?6:0))*60;break;case r:t[0]=((i-n)/e+2)*60;break;case i:t[0]=((n-r)/e+4)*60}}t[2]=s}function He(e,t){let n=e[0],r=e[1],i=e[2],a=(1-Math.abs(2*i-1))*r,o=a*(1-Math.abs(n/60%2-1)),s=i-a/2;switch(Math.floor(n/60)){case 0:t[0]=a+s,t[1]=o+s,t[2]=s;break;case 1:t[0]=o+s,t[1]=a+s,t[2]=s;break;case 2:t[0]=s,t[1]=a+s,t[2]=o+s;break;case 3:t[0]=s,t[1]=o+s,t[2]=a+s;break;case 4:t[0]=o+s,t[1]=s,t[2]=a+s;break;case 5:case 6:t[0]=a+s,t[1]=s,t[2]=o+s}}function Ue(e){return e<=.03928?e/12.92:((e+.055)/1.055)**2.4}function We(e,t,n){He(e,n),n.map(Ue);let r=.2126*n[0]+.7152*n[1]+.0722*n[2];He(t,n),n.map(Ue);let i=.2126*n[0]+.7152*n[1]+.0722*n[2];return r>i?(r+.05)/(i+.05):(i+.05)/(r+.05)}var Ge=new Map;function Ke(e,t){let n=e[0]+e[1]*256+e[2]*65536+t[0]*16777216+t[1]*4294967296+t[2]*1099511627776,r=Ge.get(n);if(r)return r;let i=new Float32Array(9),a=i.subarray(0,3),o=i.subarray(3,6);Ve(e,o);let s=i.subarray(6,9);Ve(t,s);let c=s[2]<.5,l=c?12:4.5;if(o[2]=c?Math.sqrt(o[2]):1-Math.sqrt(1-o[2]),We(o,s,a)<l){let e,t;for(c?(e=o[2],t=1):(e=0,t=o[2]);t-e>.005;){let n=o[2]=(e+t)/2;c===We(o,s,a)<l?e=n:t=n}o[2]=c?t:e}return He(o,a),r=V.makeHexColor(Math.round(a[0]*255),Math.round(a[1]*255),Math.round(a[2]*255)),Ge.set(n,r),r}function qe({html:e,dir:t,className:n},r){let i=document.createDocumentFragment();if(typeof e==`string`){let n=document.createElement(`p`);n.dir=t||`auto`;let r=e.split(/\r\n?|\n/);for(let e=0,t=r.length;e<t;++e){let i=r[e];n.append(document.createTextNode(i)),e<t-1&&n.append(document.createElement(`br`))}i.append(n)}else ye.render({xfaHtml:e,div:i,intent:`richText`});i.firstElementChild.classList.add(`richText`,n),r.append(i)}function Je(e){let t=new Path2D;if(!e)return t;for(let n=0,r=e.length;n<r;)switch(e[n++]){case S.moveTo:t.moveTo(e[n++],e[n++]);break;case S.lineTo:t.lineTo(e[n++],e[n++]);break;case S.curveTo:t.bezierCurveTo(e[n++],e[n++],e[n++],e[n++],e[n++],e[n++]);break;case S.quadraticCurveTo:t.quadraticCurveTo(e[n++],e[n++],e[n++],e[n++]);break;case S.closePath:t.closePath();break;default:O(`Unrecognized drawing path operator: ${e[n-1]}`)}return t}r(4972),r(8454),r(9452),r(4979),r(3579),r(3110),r(9314),r(1148),r(116),r(9112);var Ye=class e{#e=null;#t=null;#n;#r=null;#i=null;#a=null;#o=null;#s=null;static#c=null;constructor(t){this.#n=t,e.#c||=Object.freeze({freetext:`pdfjs-editor-remove-freetext-button`,highlight:`pdfjs-editor-remove-highlight-button`,ink:`pdfjs-editor-remove-ink-button`,stamp:`pdfjs-editor-remove-stamp-button`,signature:`pdfjs-editor-remove-signature-button`})}render(){let t=this.#e=document.createElement(`div`);t.classList.add(`editToolbar`,`hidden`),t.setAttribute(`role`,`toolbar`);let n=this.#n._uiManager._signal;n instanceof AbortSignal&&!n.aborted&&(t.addEventListener(`contextmenu`,ke,{signal:n}),t.addEventListener(`pointerdown`,e.#l,{signal:n}));let r=this.#r=document.createElement(`div`);r.className=`buttons`,t.append(r);let i=this.#n.toolbarPosition;if(i){let{style:e}=t;e.insetInlineEnd=`${100*(this.#n._uiManager.direction===`ltr`?1-i[0]:i[0])}%`,e.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return t}get div(){return this.#e}static#l(e){e.stopPropagation()}#u(e){this.#n._focusEventsAllowed=!1,U(e)}#d(e){this.#n._focusEventsAllowed=!0,U(e)}#f(e){let t=this.#n._uiManager._signal;return!(t instanceof AbortSignal)||t.aborted?!1:(e.addEventListener(`focusin`,this.#u.bind(this),{capture:!0,signal:t}),e.addEventListener(`focusout`,this.#d.bind(this),{capture:!0,signal:t}),e.addEventListener(`contextmenu`,ke,{signal:t}),!0)}hide(){this.#e.classList.add(`hidden`),this.#t?.hideDropdown()}show(){this.#e.classList.remove(`hidden`),this.#i?.shown(),this.#a?.shown()}addDeleteButton(){let{editorType:t,_uiManager:n}=this.#n,r=document.createElement(`button`);r.classList.add(`basic`,`deleteButton`),r.tabIndex=0,r.setAttribute(`data-l10n-id`,e.#c[t]),this.#f(r)&&r.addEventListener(`click`,e=>{n.delete()},{signal:n._signal}),this.#r.append(r)}get#p(){let e=document.createElement(`div`);return e.className=`divider`,e}async addAltText(e){let t=await e.render();this.#f(t),this.#r.append(t,this.#p),this.#i=e}addComment(e,t=null){if(this.#a)return;let n=e.renderForToolbar();if(!n)return;this.#f(n);let r=this.#o=this.#p;t?(this.#r.insertBefore(n,t),this.#r.insertBefore(r,t)):this.#r.append(n,r),this.#a=e,e.toolbar=this}addColorPicker(e){if(this.#t)return;this.#t=e;let t=e.renderButton();this.#f(t),this.#r.append(t,this.#p)}async addEditSignatureButton(e){let t=this.#s=await e.renderEditButton(this.#n);this.#f(t),this.#r.append(t,this.#p)}removeButton(e){e===`comment`&&(this.#a?.removeToolbarCommentButton(),this.#a=null,this.#o?.remove(),this.#o=null)}async addButton(e,t){switch(e){case`colorPicker`:t&&this.addColorPicker(t);break;case`altText`:t&&await this.addAltText(t);break;case`editSignature`:t&&await this.addEditSignatureButton(t);break;case`delete`:this.addDeleteButton();break;case`comment`:t&&this.addComment(t)}}async addButtonBefore(e,t,n){if(!t&&e===`comment`)return;let r=this.#r.querySelector(n);r&&e===`comment`&&this.addComment(t,r)}updateEditSignatureButton(e){this.#s&&(this.#s.title=e)}remove(){this.#e.remove(),this.#t?.destroy(),this.#t=null}},Xe=class{#e=null;#t=null;#n;constructor(e){this.#n=e}#r(){let e=this.#t=document.createElement(`div`);e.className=`editToolbar`,e.setAttribute(`role`,`toolbar`),e.dir=this.#n.direction;let t=this.#n._signal;t instanceof AbortSignal&&!t.aborted&&e.addEventListener(`contextmenu`,ke,{signal:t});let n=this.#e=document.createElement(`div`);return n.className=`buttons`,e.append(n),this.#n.hasCommentManager()&&this.#a(`commentButton`,`pdfjs-comment-floating-button`,`pdfjs-comment-floating-button-label`,()=>{this.#n.commentSelection(`floating_button`)}),this.#a(`highlightButton`,`pdfjs-highlight-floating-button1`,`pdfjs-highlight-floating-button-label`,()=>{this.#n.highlightSelection(`floating_button`)}),e}#i(e,t){let n=0,r=0;for(let i of e){let e=i.y+i.height;if(e<n)continue;let a=i.x+(t?i.width:0);if(e>n){r=a,n=e;continue}t?a>r&&(r=a):a<r&&(r=a)}return[t?1-r:r,n]}show(e,t,n){let[r,i]=this.#i(t,n),{style:a}=this.#t||=this.#r();e.append(this.#t),a.insetInlineEnd=`${100*r}%`,a.top=`calc(${100*i}% + var(--editor-toolbar-vert-offset))`}hide(){this.#t.remove()}#a(e,t,n,r){let i=document.createElement(`button`);i.classList.add(`basic`,e),i.tabIndex=0,i.setAttribute(`data-l10n-id`,t);let a=document.createElement(`span`);i.append(a),a.className=`visuallyHidden`,a.setAttribute(`data-l10n-id`,n);let o=this.#n._signal;o instanceof AbortSignal&&!o.aborted&&(i.addEventListener(`contextmenu`,ke,{signal:o}),i.addEventListener(`click`,r,{signal:o})),this.#e.append(i)}},Ze=Object.freeze({internal:`59968104-cc61-4cf9-b570-014b35b3709c`});function Qe(e,t,n){for(let r of n)t.addEventListener(r,e[r].bind(e))}var G=class e{static#e=NaN;static#t=null;static#n=NaN;static#r=null;static initializeAndAddPointerId(t){(e.#t||=new Set).add(t)}static setPointer(t,n){e.#e||=n,e.#r??=t}static setTimeStamp(t){e.#n=t}static isSamePointerId(t){return e.#e===t}static isSamePointerIdOrRemove(t){return e.#e===t||(e.#t?.delete(t),!1)}static isSamePointerType(t){return e.#r===t}static isInitializedAndDifferentPointerType(t){return e.#r!==null&&!e.isSamePointerType(t)}static isSameTimeStamp(t){return e.#n===t}static isUsingMultiplePointers(){return e.#t?.size>=1}static clearPointerType(){e.#r=null}static clearPointerIds(){e.#e=NaN,e.#t=null}static clearTimeStamp(){e.#n=NaN}},$e=class{#e=0;get id(){return`${f}${this.#e++}`}},et=class e{#e=le();#t=0;#n=null;static get _isSVGFittingCanvas(){let e=`data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="${c}"><rect width="1" height="1" style="fill:red;"/></svg>`,t=new OffscreenCanvas(1,3).getContext(`2d`,{willReadFrequently:!0}),n=new Image;n.src=e;let r=n.decode().then(()=>(t.drawImage(n,0,0,1,1,0,0,1,3),new Uint32Array(t.getImageData(0,0,1,1).data.buffer)[0]===0));return F(this,`_isSVGFittingCanvas`,r)}async#r(t,n){this.#n||=new Map;let r=this.#n.get(t);if(r===null)return null;if(r?.bitmap)return r.refCounter+=1,r;try{r||={bitmap:null,id:`image_${this.#e}_${this.#t++}`,refCounter:0,isSvg:!1};let t;if(typeof n==`string`?(r.url=n,t=await xe(n,`blob`)):n instanceof File?t=r.file=n:n instanceof Blob&&(t=n),t.type===`image/svg+xml`){let n=e._isSVGFittingCanvas,i=new FileReader,a=new Image,o=new Promise((e,t)=>{a.onload=()=>{r.bitmap=a,r.isSvg=!0,e()},i.onload=async()=>{let e=r.svgUrl=i.result;a.src=await n?`${e}#svgView(preserveAspectRatio(none))`:e},a.onerror=i.onerror=t});i.readAsDataURL(t),await o}else r.bitmap=await createImageBitmap(t);r.refCounter=1}catch(e){O(e),r=null}return this.#n.set(t,r),r&&this.#n.set(r.id,r),r}async getFromFile(e){let{lastModified:t,name:n,size:r,type:i}=e;return this.#r(`${t}_${n}_${r}_${i}`,e)}async getFromUrl(e){return this.#r(e,e)}async getFromBlob(e,t){let n=await t;return this.#r(e,n)}async getFromId(e){this.#n||=new Map;let t=this.#n.get(e);if(!t)return null;if(t.bitmap)return t.refCounter+=1,t;if(t.file)return this.getFromFile(t.file);if(t.blobPromise){let{blobPromise:e}=t;return delete t.blobPromise,this.getFromBlob(t.id,e)}return this.getFromUrl(t.url)}getFromCanvas(e,t){this.#n||=new Map;let n=this.#n.get(e);if(n?.bitmap)return n.refCounter+=1,n;let r=new OffscreenCanvas(t.width,t.height);return r.getContext(`2d`).drawImage(t,0,0),n={bitmap:r.transferToImageBitmap(),id:`image_${this.#e}_${this.#t++}`,refCounter:1,isSvg:!1},this.#n.set(e,n),this.#n.set(n.id,n),n}getSvgUrl(e){let t=this.#n.get(e);return t?.isSvg?t.svgUrl:null}deleteId(e){this.#n||=new Map;let t=this.#n.get(e);if(!t||(--t.refCounter,t.refCounter!==0))return;let{bitmap:n}=t;if(!t.url&&!t.file){let e=new OffscreenCanvas(n.width,n.height);e.getContext(`bitmaprenderer`).transferFromImageBitmap(n),t.blobPromise=e.convertToBlob()}n.close?.(),t.bitmap=null}isValidId(e){return e.startsWith(`image_${this.#e}_`)}},tt=class{#e=[];#t=!1;#n;#r=-1;constructor(e=128){this.#n=e}add({cmd:e,undo:t,post:n,mustExec:r,type:i=NaN,overwriteIfSameType:a=!1,keepUndo:o=!1}){if(r&&e(),this.#t)return;let s={cmd:e,undo:t,post:n,type:i};if(this.#r===-1){this.#e.length>0&&(this.#e.length=0),this.#r=0,this.#e.push(s);return}if(a&&this.#e[this.#r].type===i){o&&(s.undo=this.#e[this.#r].undo),this.#e[this.#r]=s;return}let c=this.#r+1;c===this.#n?this.#e.splice(0,1):(this.#r=c,c<this.#e.length&&this.#e.splice(c)),this.#e.push(s)}undo(){if(this.#r===-1)return;this.#t=!0;let{undo:e,post:t}=this.#e[this.#r];e(),t?.(),this.#t=!1,--this.#r}redo(){if(this.#r<this.#e.length-1){this.#r+=1,this.#t=!0;let{cmd:e,post:t}=this.#e[this.#r];e(),t?.(),this.#t=!1}}hasSomethingToUndo(){return this.#r!==-1}hasSomethingToRedo(){return this.#r<this.#e.length-1}cleanType(e){if(this.#r!==-1){for(let t=this.#r;t>=0;t--)if(this.#e[t].type!==e){this.#e.splice(t+1,this.#r-t),this.#r=t;return}this.#e.length=0,this.#r=-1}}destroy(){this.#e=null}},nt=class e{static ALT=1;static CTRL=2;static META=4;static SHIFT=8;constructor(t){this.callbacks=new Map;let{isMac:n}=B.platform;for(let[r,i,a={}]of t){let t=r.some(e=>e.startsWith(`mac+`));for(let o of r){let r=o;if(t){let e=o.startsWith(`mac+`);if(n!==e)continue;e&&(r=o.slice(4))}let[s,c]=e.#e(r);s!==null&&this.callbacks.getOrInsertComputed(s,de).push({callback:i,options:a,modifiers:c})}}}static#e(t){let n=null,r=0;for(let i of t.split(`+`)){if(i=i.trim(),!i)continue;let a=i.toUpperCase(),o=e[a];if(o){r|=o;continue}if(n!==null){O(`KeyboardManager: multiple keys in shortcut "${t}"`);break}n=a===`SPACE`?` `:i}return n===null&&O(`KeyboardManager: no key found in shortcut "${t}"`),[n,r]}static#t(e){let t=/^(?:Key([A-Z])|(?:Digit|Numpad)(\d))$/.exec(e);return t?t[1]?.toLowerCase()??t[2]:null}exec(t,n){let r=this.callbacks.get(n.key);if(!r){if(/^[a-z]$/i.test(n.key))return;let t=e.#t(n.code);if(t===null||t===n.key||(r=this.callbacks.get(t),!r))return}let i=(n.altKey?e.ALT:0)|(n.ctrlKey?e.CTRL:0)|(n.metaKey?e.META:0)|(n.shiftKey?e.SHIFT:0),a=r.find(e=>e.modifiers===i);if(!a)return;let{callback:o,options:{bubbles:s=!1,args:c=[],checker:l=null}}=a;(!l||l(t,n))&&(o.bind(t,...c,n)(),s||U(n))}},rt=class e{static _colorsMapping=new Map([[`CanvasText`,[0,0,0]],[`Canvas`,[255,255,255]]]);get _colors(){let e=new Map([[`CanvasText`,null],[`Canvas`,null]]);return Ne(e),F(this,`_colors`,e)}convert(t){let n=Me(t);if(!window.matchMedia(`(forced-colors: active)`).matches)return n;for(let[t,r]of this._colors)if(r.every((e,t)=>e===n[t]))return e._colorsMapping.get(t);return n}getHexCode(e){let t=this._colors.get(e);return t?V.makeHexColor(...t):e}},it=class e{#e=new AbortController;#t=null;#n=null;#r=new Map;#i=new Map;#a=null;#o=null;#s=null;#c=null;#l=null;#u=new tt;#d=null;#f=null;#p=null;#m=0;#h=new Set;#g=null;#_=null;#v=new Set;_editorUndoBar=null;#y=!1;#b=!1;#x=!1;#S=null;#C=null;#w=null;#T=null;#E=!1;#D=null;#O=new $e;#k=!1;#A=!1;#j=!1;#M=null;#N=null;#P=null;#F=null;#I=null;#L=p.NONE;#R=new Set;#z=null;#B=null;#V=null;#H=null;#U=null;#W={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#G=[0,0];#K=null;#q=null;#J=null;#Y=null;#X=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){let t=e.prototype,n=e=>e.#q.contains(document.activeElement)&&document.activeElement.tagName!==`BUTTON`&&e.hasSomethingToControl(),r=(e,{target:t})=>{if(t instanceof HTMLInputElement){let{type:e}=t;return e!==`text`&&e!==`number`}return!0},i=this.TRANSLATE_SMALL,a=this.TRANSLATE_BIG;return F(this,`_keyboardManager`,new nt([[[`ctrl+a`,`mac+meta+a`],t.selectAll,{checker:r}],[[`ctrl+z`,`mac+meta+z`],t.undo,{checker:r}],[[`ctrl+y`,`ctrl+shift+z`,`mac+meta+shift+z`,`ctrl+shift+Z`,`mac+meta+shift+Z`],t.redo,{checker:r}],[[`Backspace`,`alt+Backspace`,`ctrl+Backspace`,`shift+Backspace`,`mac+Backspace`,`mac+alt+Backspace`,`mac+ctrl+Backspace`,`Delete`,`ctrl+Delete`,`shift+Delete`,`mac+Delete`],t.delete,{checker:r}],[[`Enter`],t.addNewEditorFromKeyboard,{checker:(e,{target:t})=>!(t instanceof HTMLButtonElement)&&e.#q.contains(t)&&!e.isEnterHandled}],[[`Space`],t.addNewEditorFromKeyboard,{checker:(e,{target:t})=>!(t instanceof HTMLButtonElement)&&e.#q.contains(document.activeElement)}],[[`Escape`],t.unselectAll],[[`ArrowLeft`],t.translateSelectedEditors,{args:[-i,0],checker:n}],[[`ctrl+ArrowLeft`,`mac+shift+ArrowLeft`],t.translateSelectedEditors,{args:[-a,0],checker:n}],[[`ArrowRight`],t.translateSelectedEditors,{args:[i,0],checker:n}],[[`ctrl+ArrowRight`,`mac+shift+ArrowRight`],t.translateSelectedEditors,{args:[a,0],checker:n}],[[`ArrowUp`],t.translateSelectedEditors,{args:[0,-i],checker:n}],[[`ctrl+ArrowUp`,`mac+shift+ArrowUp`],t.translateSelectedEditors,{args:[0,-a],checker:n}],[[`ArrowDown`],t.translateSelectedEditors,{args:[0,i],checker:n}],[[`ctrl+ArrowDown`,`mac+shift+ArrowDown`],t.translateSelectedEditors,{args:[0,a],checker:n}]]))}constructor(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=this._signal=this.#e.signal;this.#q=e,this.#J=t,this.#Y=n,this.#s=r,this.#d=i,this.#B=a,this.#U=s,this._eventBus=o;let _={signal:g,...Ze};o.on(`editingaction`,this.onEditingAction.bind(this),_),o.on(`pagechanging`,this.onPageChanging.bind(this),_),o.on(`scalechanging`,this.onScaleChanging.bind(this),_),o.on(`rotationchanging`,this.onRotationChanging.bind(this),_),o.on(`setpreference`,this.onSetPreference.bind(this),_),o.on(`switchannotationeditorparams`,e=>this.updateParams(e.type,e.value),_),window.addEventListener(`pointerdown`,()=>{this.#A=!0},{capture:!0,signal:g}),window.addEventListener(`pointerup`,()=>{this.#A=!1},{capture:!0,signal:g}),window.addEventListener(`beforeunload`,this.endCurrentEditing.bind(this),{capture:!0,signal:g}),this.#ne(),this.#le(),this.#ae(),this.#c=s.annotationStorage,this.#S=s.filterFactory,this.#V=c,this.#T=l||null,this.#y=u,this.#b=d,this.#x=f,this.#I=p||null,this.viewParameters={realScale:be.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=m||null,this._supportsPinchToZoom=h!==!1,i?.setSidebarUiManager(this)}destroy(){this.#X?.resolve(),this.#X=null,this.#e?.abort(),this.#e=null,this._signal=null;for(let e of this.#i.values())e.destroy();this.#i.clear(),this.#r.clear(),this.#v.clear(),this.#F?.clear(),this.#t=null,this.#R.clear(),this.#u.destroy(),this.#s?.destroy(),this.#d?.destroy(),this.#B?.destroy(),this.#D?.hide(),this.#D=null,this.#P?.destroy(),this.#P=null,this.#n=null,this.#C&&=(clearTimeout(this.#C),null),this.#K&&=(clearTimeout(this.#K),null),this._editorUndoBar?.destroy(),this.#U=null}combinedSignal(e){return AbortSignal.any([this._signal,e.signal])}get mlManager(){return this.#I}get useNewAltTextFlow(){return this.#b}get useNewAltTextWhenAddingImage(){return this.#x}get hcmFilter(){return F(this,`hcmFilter`,this.#V?this.#S.addHCMFilter(this.#V.foreground,this.#V.background):`none`)}get direction(){return F(this,`direction`,getComputedStyle(this.#q).direction)}get _highlightColors(){return F(this,`_highlightColors`,this.#T?new Map(this.#T.split(`,`).map(e=>(e=e.split(`=`).map(e=>e.trim()),e[1]=e[1].toUpperCase(),e))):null)}get highlightColors(){let{_highlightColors:e}=this;if(!e)return F(this,`highlightColors`,null);let t=new Map,n=!!this.#V;for(let[r,i]of e){let e=r.endsWith(`_HCM`);if(n&&e){t.set(r.replace(`_HCM`,``),i);continue}!n&&!e&&t.set(r,i)}return F(this,`highlightColors`,t)}get highlightColorNames(){return F(this,`highlightColorNames`,this.highlightColors?new Map(Array.from(this.highlightColors,e=>e.reverse())):null)}getNonHCMColor(e){if(!this._highlightColors)return e;let t=this.highlightColorNames.get(e);return this._highlightColors.get(t)||e}getNonHCMColorName(e){return this.highlightColorNames.get(e)||e}setCurrentDrawingSession(e){e?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#p=e}setMainHighlightColorPicker(e){this.#P=e}editAltText(e,t=!1){this.#s?.editAltText(this,e,t)}hasCommentManager(){return!!this.#d}editComment(e,t,n,r){this.#d?.showDialog(this,e,t,n,r)}selectComment(e,t){(this.#i.get(e)?.getEditorByUID(t))?.toggleComment(!0,!0)}updateComment(e){this.#d?.updateComment(e.getData())}updatePopupColor(e){this.#d?.updatePopupColor(e)}removeComment(e){this.#d?.removeComments([e.uid])}deleteComment(e,t){let n=()=>{e.comment=t};this.addCommands({cmd:()=>{this._editorUndoBar?.show(n,`comment`),this.toggleComment(null),e.comment=null},undo:n,mustExec:!0})}toggleComment(e,t,n=void 0){this.#d?.toggleCommentPopup(e,t,n)}makeCommentColor(e,t){return e&&this.#d?.makeCommentColor(e,t)||null}getCommentDialogElement(){return this.#d?.dialogElement||null}async waitForEditorsRendered(e){if(this.#i.has(e-1))return;let{resolve:t,promise:n}=Promise.withResolvers(),r=n=>{n.pageNumber===e&&(this._eventBus.off(`editorsrendered`,r),t())};this._eventBus.on(`editorsrendered`,r,Ze),await n}getSignature(e){this.#B?.getSignature({uiManager:this,editor:e})}get signatureManager(){return this.#B}switchToMode(e,t){this._eventBus.on(`annotationeditormodechanged`,t,{once:!0,signal:this._signal,...Ze}),this._eventBus.dispatch(`showannotationeditorui`,{source:this,mode:e})}setPreference(e,t){this._eventBus.dispatch(`setpreference`,{source:this,name:e,value:t})}onSetPreference({name:e,value:t}){e===`enableNewAltTextWhenAddingImage`&&(this.#x=t)}onPageChanging({pageNumber:e}){this.#m=e-1}deletePage(e){for(let t of this.getEditors(e))t.remove();this.#i.delete(e),this.#m===e&&(this.#m=0)}focusMainContainer(){this.#q.focus()}findParent(e,t){for(let n of this.#i.values()){let{x:r,y:i,width:a,height:o}=n.div.getBoundingClientRect();if(e>=r&&e<=r+a&&t>=i&&t<=i+o)return n}return null}disableUserSelect(e=!1){this.#J.classList.toggle(`noUserSelect`,e)}addShouldRescale(e){this.#v.add(e)}removeShouldRescale(e){this.#v.delete(e)}onScaleChanging({scale:e}){this.commitOrRemove(),this.viewParameters.realScale=e*be.PDF_TO_CSS_UNITS;for(let e of this.#v)e.onScaleChanging();this.#p?.onScaleChanging()}onRotationChanging({pagesRotation:e}){this.commitOrRemove(),this.viewParameters.rotation=e}#Z({anchorNode:e}){return e.nodeType===Node.TEXT_NODE?e.parentElement:e}#Q(e){let{currentLayer:t}=this;if(t.hasTextLayer(e))return t;for(let t of this.#i.values())if(t.hasTextLayer(e))return t;return null}highlightSelection(e=``,t=!1){let n=document.getSelection();if(!n||n.isCollapsed)return;let{anchorNode:r,anchorOffset:i,focusNode:a,focusOffset:o}=n,s=n.toString(),c=this.#Z(n).closest(`.textLayer`),l=this.getSelectionBoxes(c);if(!l)return;n.empty();let u=this.#Q(c),d=this.#L===p.NONE,f=()=>{let n=u?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:e,boxes:l,anchorNode:r,anchorOffset:i,focusNode:a,focusOffset:o,text:s});d&&this.showAllEditors(`highlight`,!0,!0),t&&n?.editComment()};if(d){this.switchToMode(p.HIGHLIGHT,f);return}f()}commentSelection(e=``){this.highlightSelection(e,!0)}endCurrentEditing(){this.commitOrRemove(),this.currentLayer?.endDrawingSession(!1)}#$(){let e=document.getSelection();if(!e||e.isCollapsed)return;let t=this.#Z(e).closest(`.textLayer`),n=this.getSelectionBoxes(t);n&&(this.#D||=new Xe(this),this.#D.show(t,n,this.direction===`ltr`))}getAndRemoveDataFromAnnotationStorage(e){if(!this.#c)return null;let t=`${f}${e}`,n=this.#c.getRawValue(t);return n&&this.#c.remove(t),n}addToAnnotationStorage(e){!e.isEmpty()&&this.#c&&!this.#c.has(e.id)&&this.#c.setValue(e.id,e)}a11yAlert(e,t=null){let n=this.#Y;n&&(n.setAttribute(`data-l10n-id`,e),t?n.setAttribute(`data-l10n-args`,JSON.stringify(t)):n.removeAttribute(`data-l10n-args`))}#ee(){let e=document.getSelection();if(!e||e.isCollapsed){this.#z&&(this.#D?.hide(),this.#z=null,this.#ue({hasSelectedText:!1}));return}let{anchorNode:t}=e;if(t===this.#z)return;let n=this.#Z(e).closest(`.textLayer`);if(!n){this.#z&&(this.#D?.hide(),this.#z=null,this.#ue({hasSelectedText:!1}));return}if(this.#D?.hide(),this.#z=t,this.#ue({hasSelectedText:!0}),(this.#L===p.HIGHLIGHT||this.#L===p.NONE)&&(this.#L===p.HIGHLIGHT&&this.showAllEditors(`highlight`,!0,!0),this.#E=this.isShiftKeyDown,!this.isShiftKeyDown)){let e=this.#L===p.HIGHLIGHT?this.#Q(n):null;if(e?.toggleDrawing(),this.#A){let t=new AbortController,n=this.combinedSignal(t),r=n=>{(n.type!==`pointerup`||n.button===0)&&(t.abort(),e?.toggleDrawing(!0),n.type===`pointerup`&&this.#te(`main_toolbar`))};window.addEventListener(`pointerup`,r,{signal:n}),window.addEventListener(`blur`,r,{signal:n})}else e?.toggleDrawing(!0),this.#te(`main_toolbar`)}}#te(e=``){this.#L===p.HIGHLIGHT?this.highlightSelection(e):this.#y&&this.#$()}#ne(){document.addEventListener(`selectionchange`,this.#ee.bind(this),{signal:this._signal})}#re(){if(this.#w)return;this.#w=new AbortController;let e=this.combinedSignal(this.#w);window.addEventListener(`focus`,this.focus.bind(this),{signal:e}),window.addEventListener(`blur`,this.blur.bind(this),{signal:e})}#ie(){this.#w?.abort(),this.#w=null}blur(){if(this.isShiftKeyDown=!1,this.#E&&(this.#E=!1,this.#te(`main_toolbar`)),!this.hasSelection)return;let{activeElement:e}=document;for(let t of this.#R)if(t.div.contains(e)){this.#N=[t,e],t._focusEventsAllowed=!1;break}}focus(){if(!this.#N)return;let[e,t]=this.#N;this.#N=null,t.addEventListener(`focusin`,()=>{e._focusEventsAllowed=!0},{once:!0,signal:this._signal}),t.focus()}#ae(){if(this.#M)return;this.#M=new AbortController;let e=this.combinedSignal(this.#M);window.addEventListener(`keydown`,this.keydown.bind(this),{signal:e}),window.addEventListener(`keyup`,this.keyup.bind(this),{signal:e})}#oe(){this.#M?.abort(),this.#M=null}#se(){if(this.#f)return;this.#f=new AbortController;let e=this.combinedSignal(this.#f);document.addEventListener(`copy`,this.copy.bind(this),{signal:e}),document.addEventListener(`cut`,this.cut.bind(this),{signal:e}),document.addEventListener(`paste`,this.paste.bind(this),{signal:e})}#ce(){this.#f?.abort(),this.#f=null}#le(){let e=this._signal;document.addEventListener(`dragover`,this.dragOver.bind(this),{signal:e}),document.addEventListener(`drop`,this.drop.bind(this),{signal:e})}addEditListeners(){this.#ae(),this.setEditingState(!0)}removeEditListeners(){this.#oe(),this.setEditingState(!1)}dragOver(e){for(let{type:t}of e.dataTransfer.items)for(let n of this.#_)if(n.isHandlingMimeForPasting(t)){e.dataTransfer.dropEffect=`copy`,e.preventDefault();return}}drop(e){for(let t of e.dataTransfer.items)for(let n of this.#_)if(n.isHandlingMimeForPasting(t.type)){n.paste(t,this.currentLayer),e.preventDefault();return}}copy(e){if(e.preventDefault(),this.#t?.commitOrRemove(),!this.hasSelection)return;let t=[];for(let e of this.#R){let n=e.serialize(!0);n&&t.push(n)}t.length!==0&&e.clipboardData.setData(`application/pdfjs`,JSON.stringify(t))}cut(e){this.copy(e),this.delete()}async paste(e){e.preventDefault();let{clipboardData:t}=e;for(let e of t.items)for(let t of this.#_)if(t.isHandlingMimeForPasting(e.type)){t.paste(e,this.currentLayer);return}let n=t.getData(`application/pdfjs`);if(!n)return;try{n=JSON.parse(n)}catch(e){O(`paste: "${e.message}".`);return}if(!Array.isArray(n))return;this.unselectAll();let r=this.currentLayer;try{let e=[];for(let t of n){let n=await r.deserialize(t);if(!n)return;e.push(n)}this.addCommands({cmd:()=>{for(let t of e)this.#me(t);this.#_e(e)},undo:()=>{for(let t of e)t.remove()},mustExec:!0})}catch(e){O(`paste: "${e.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key===`Shift`&&(this.isShiftKeyDown=!0),this.#L!==p.NONE&&!this.isEditorHandlingKeyboard&&e._keyboardManager.exec(this,t)}keyup(e){this.isShiftKeyDown&&e.key===`Shift`&&(this.isShiftKeyDown=!1,this.#E&&(this.#E=!1,this.#te(`main_toolbar`)))}onEditingAction({name:e}){switch(e){case`undo`:case`redo`:case`delete`:case`selectAll`:this[e]();break;case`highlightSelection`:this.highlightSelection(`context_menu`);break;case`commentSelection`:this.commentSelection(`context_menu`)}}updatePageIndex(e,t){for(let n of this.#o.get(e)||[])n.pageIndex=t;let n=this.#a.get(e);n&&(n.pageIndex=t,this.#i.set(t,n),this.#k?n.enable():n.disable())}startUpdatePages(){this.#a=new Map(this.#i),this.#i.clear();let e=this.#o=new Map,t=t=>{e.getOrInsertComputed(t.pageIndex,de).push(t)};for(let e of this.#r.values())t(e);for(let[e,n]of this.#c)e.startsWith(f)&&!this.#r.has(e)&&Number.isInteger(n?.pageIndex)&&t(n)}endUpdatePages(){this.#a=null,this.#o=null}clonePage(e,t){for(let n of this.getEditors(e)){let e=n.serialize(n.mode!==p.HIGHLIGHT);e&&(e.pageIndex=t,e.id=this.getId(),e.isClone=!0,delete e.popupRef,this.#c.setValue(e.id,e))}}findClonesForPage(e){let t=[],{pageIndex:n}=e;for(let[r,i]of this.#c)i.pageIndex===n&&i.isClone&&(this.#c.remove(r),t.push(e.deserialize(i).then(t=>{t&&(t.isClone=!0,e.addOrRebuild(t))})));return Promise.all(t)}#ue(e){Object.entries(e).some(([e,t])=>this.#W[e]!==t)&&(this._eventBus.dispatch(`editingstateschanged`,{source:this,details:Object.assign(this.#W,e)}),this.#L===p.HIGHLIGHT&&e.hasSelectedEditor===!1&&this.#de([[m.HIGHLIGHT_FREE,!0]]))}#de(e){this._eventBus.dispatch(`annotationeditorparamschanged`,{source:this,details:e})}setEditingState(e){e?(this.#re(),this.#se(),this.#ue({isEditing:this.#L!==p.NONE,isEmpty:this.#ge(),hasSomethingToUndo:this.#u.hasSomethingToUndo(),hasSomethingToRedo:this.#u.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#ie(),this.#ce(),this.#ue({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(e){if(!this.#_){this.#_=e;for(let e of this.#_)this.#de(e.defaultPropertiesToUpdate)}}getId(){return this.#O.id}get currentLayer(){return this.#i.get(this.#m)}getLayer(e){return this.#i.get(e)}get currentPageIndex(){return this.#m}addLayer(e){this.#i.set(e.pageIndex,e),this.#k?e.enable():e.disable()}removeLayer(e){this.#i.delete(e.pageIndex)}async updateMode(e,t=null,n=!1,r=!1,i=!1,a=!1){if(this.#L!==e&&!(this.#X&&(await this.#X.promise,!this.#X))){if(this.#X=Promise.withResolvers(),this.#p?.commitOrRemove(),this.#L===p.POPUP&&this.#d?.hideSidebar(),this.#d?.destroyPopup(),this.#L=e,e===p.NONE){this.setEditingState(!1),this.#pe();for(let e of this.#r.values())e.hideStandaloneCommentButton();this._editorUndoBar?.hide(),this.toggleComment(null),this.#X.resolve();return}for(let e of this.#r.values())e.addStandaloneCommentButton();e===p.SIGNATURE&&await this.#B?.loadSignatures(),n&&G.clearPointerType(),this.setEditingState(!0),await this.#fe(),this.unselectAll();for(let t of this.#i.values())t.updateMode(e);if(e===p.POPUP){this.#n||=await this.#U.getAnnotationsByType(new Set(this.#_.map(e=>e._editorType)));let e=new Set,t=[];for(let n of this.#r.values()){let{annotationElementId:r,hasComment:i,deleted:a}=n;r&&e.add(r),i&&!a&&t.push(n.getData())}for(let n of this.#n){let{id:r,popupRef:i,contentsObj:a}=n;i&&a?.str&&!e.has(r)&&!this.#h.has(r)&&t.push(n)}this.#d?.showSidebar(t)}if(!t){r&&this.addNewEditorFromKeyboard(),this.#X.resolve();return}for(let e of this.#r.values())e.uid===t?(this.setSelected(e),a?e.editComment():i?e.enterInEditMode():e.focus()):e.unselect();this.#X.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(e){e.mode!==this.#L&&this._eventBus.dispatch(`switchannotationeditormode`,{source:this,...e})}updateParams(e,t){if(this.#_){switch(e){case m.CREATE:this.currentLayer.addNewEditor(t);return;case m.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch(`reporttelemetry`,{source:this,details:{type:`editing`,data:{type:`highlight`,action:`toggle_visibility`}}}),(this.#H||=new Map).set(e,t),this.showAllEditors(`highlight`,t)}if(this.hasSelection)for(let n of this.#R)n.updateParams(e,t);else for(let n of this.#_)n.updateDefaultParams(e,t)}}showAllEditors(e,t,n=!1){for(let n of this.#r.values())n.editorType===e&&n.show(t);(this.#H?.get(m.HIGHLIGHT_SHOW_ALL)??!0)!==t&&this.#de([[m.HIGHLIGHT_SHOW_ALL,t]])}enableWaiting(e=!1){if(this.#j!==e){this.#j=e;for(let t of this.#i.values())e?t.disableClick():t.enableClick(),t.div.classList.toggle(`waiting`,e)}}async#fe(){if(!this.#k){this.#k=!0;let e=[];for(let t of this.#i.values())e.push(t.enable());await Promise.all(e);for(let e of this.#r.values())e.enable()}}#pe(){if(this.unselectAll(),this.#k){this.#k=!1;for(let e of this.#i.values())e.disable();for(let e of this.#r.values())e.disable()}}*getEditors(e){for(let t of this.#r.values())t.pageIndex===e&&(yield t)}getEditor(e){return this.#r.get(e)}addEditor(e){this.#r.set(e.id,e)}removeEditor(e){e.div.contains(document.activeElement)&&(this.#C&&clearTimeout(this.#C),this.#C=setTimeout(()=>{this.focusMainContainer(),this.#C=null},0)),this.#r.delete(e.id),e.annotationElementId&&this.#F?.delete(e.annotationElementId),this.unselect(e),(!e.annotationElementId||!this.#h.has(e.annotationElementId))&&this.#c?.remove(e.id)}addDeletedAnnotationElement(e){this.#h.add(e.annotationElementId),this.addChangedExistingAnnotation(e),e.deleted=!0}isDeletedAnnotationElement(e){return this.#h.has(e)}removeDeletedAnnotationElement(e){this.#h.delete(e.annotationElementId),this.removeChangedExistingAnnotation(e),e.deleted=!1}#me(e){let t=this.#i.get(e.pageIndex);t?t.addOrRebuild(e):(this.addEditor(e),this.addToAnnotationStorage(e))}setActiveEditor(e){this.#t!==e&&(this.#t=e,e&&this.#de(e.propertiesToUpdate))}get#he(){let e=null;for(e of this.#R);return e}updateUI(e){this.#he===e&&this.#de(e.propertiesToUpdate)}updateUIForDefaultProperties(e){this.#de(e.defaultPropertiesToUpdate)}toggleSelected(e){if(this.#R.has(e)){this.#R.delete(e),e.unselect(),this.#ue({hasSelectedEditor:this.hasSelection});return}this.#R.add(e),e.select(),this.#de(e.propertiesToUpdate),this.#ue({hasSelectedEditor:!0})}setSelected(e){this.updateToolbar({mode:e.mode,editId:e.uid}),this.#p?.commitOrRemove();for(let t of this.#R)t!==e&&t.unselect();this.#d?.destroyPopup(),this.#R.clear(),this.#R.add(e),e.select(),this.#de(e.propertiesToUpdate),this.#ue({hasSelectedEditor:!0})}get firstSelectedEditor(){return this.#R.values().next().value}unselect(e){e.unselect(),this.#R.delete(e),this.#ue({hasSelectedEditor:this.hasSelection})}get hasSelection(){return this.#R.size!==0}get isEnterHandled(){return this.#R.size===1&&this.firstSelectedEditor.isEnterHandled}undo(){this.#u.undo(),this.#ue({hasSomethingToUndo:this.#u.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#ge()}),this._editorUndoBar?.hide()}redo(){this.#u.redo(),this.#ue({hasSomethingToUndo:!0,hasSomethingToRedo:this.#u.hasSomethingToRedo(),isEmpty:this.#ge()})}addCommands(e){this.#u.add(e),this.#ue({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#ge()})}cleanUndoStack(e){this.#u.cleanType(e)}#ge(){if(this.#r.size===0)return!0;if(this.#r.size===1)for(let e of this.#r.values())return e.isEmpty();return!1}delete(){this.commitOrRemove();let e=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!e)return;let t=e?[e]:[...this.#R],n=()=>{this._editorUndoBar?.show(r,t.length===1?t[0].editorType:t.length);for(let e of t)e.remove()},r=()=>{for(let e of t)this.#me(e)};this.addCommands({cmd:n,undo:r,mustExec:!0})}commitOrRemove(){this.#t?.commitOrRemove()}hasSomethingToControl(){return this.#t||this.hasSelection}#_e(e){for(let e of this.#R)e.unselect();this.#R.clear();for(let t of e)t.isEmpty()||(this.#R.add(t),t.select());this.#ue({hasSelectedEditor:this.hasSelection})}selectAll(){for(let e of this.#R)e.commit();this.#_e(this.#r.values())}unselectAll(){if(!(this.#t&&(this.#t.commitOrRemove(),this.#L!==p.NONE))&&!this.#p?.commitOrRemove()&&(this.#d?.destroyPopup(),this.hasSelection)){for(let e of this.#R)e.unselect();this.#R.clear(),this.#ue({hasSelectedEditor:!1})}}translateSelectedEditors(e,t,n=!1){if(n||this.commitOrRemove(),!this.hasSelection)return;this.#G[0]+=e,this.#G[1]+=t;let[r,i]=this.#G,a=[...this.#R];this.#K&&clearTimeout(this.#K),this.#K=setTimeout(()=>{this.#K=null,this.#G[0]=this.#G[1]=0,this.addCommands({cmd:()=>{for(let e of a)this.#r.has(e.id)&&(e.translateInPage(r,i),e.translationDone())},undo:()=>{for(let e of a)this.#r.has(e.id)&&(e.translateInPage(-r,-i),e.translationDone())},mustExec:!1})},1e3);for(let n of a)n.translateInPage(e,t),n.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#g=new Map;for(let e of this.#R)this.#g.set(e,{savedX:e.x,savedY:e.y,savedPageIndex:e.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#g)return!1;this.disableUserSelect(!1);let e=this.#g;this.#g=null;let t=!1;for(let[{x:n,y:r,pageIndex:i},a]of e)a.newX=n,a.newY=r,a.newPageIndex=i,t||=n!==a.savedX||r!==a.savedY||i!==a.savedPageIndex;if(!t)return!1;let n=(e,t,n,r)=>{if(this.#r.has(e.id)){let i=this.#i.get(r);i?e._setParentAndPosition(i,t,n):(e.pageIndex=r,e.x=t,e.y=n)}};return this.addCommands({cmd:()=>{for(let[t,{newX:r,newY:i,newPageIndex:a}]of e)n(t,r,i,a)},undo:()=>{for(let[t,{savedX:r,savedY:i,savedPageIndex:a}]of e)n(t,r,i,a)},mustExec:!0}),!0}dragSelectedEditors(e,t){if(this.#g)for(let n of this.#g.keys())n.drag(e,t)}rebuild(e){if(e.parent===null){let t=this.getLayer(e.pageIndex);t?(t.changeParent(e),t.addOrRebuild(e)):(this.addEditor(e),this.addToAnnotationStorage(e),e.rebuild())}else e.parent.addOrRebuild(e)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||this.#R.size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(e){return this.#t===e}getActive(){return this.#t}getMode(){return this.#L}isEditingMode(){return this.#L!==p.NONE}get imageManager(){return F(this,`imageManager`,new et)}getSelectionBoxes(e){if(!e)return null;let t=document.getSelection();for(let n=0,r=t.rangeCount;n<r;n++)if(!e.contains(t.getRangeAt(n).commonAncestorContainer))return null;let{x:n,y:r,width:i,height:a}=e.getBoundingClientRect(),o;switch(e.getAttribute(`data-main-rotation`)){case`90`:o=(e,t,o,s)=>({x:(t-r)/a,y:1-(e+o-n)/i,width:s/a,height:o/i});break;case`180`:o=(e,t,o,s)=>({x:1-(e+o-n)/i,y:1-(t+s-r)/a,width:o/i,height:s/a});break;case`270`:o=(e,t,o,s)=>({x:1-(t+s-r)/a,y:(e-n)/i,width:s/a,height:o/i});break;default:o=(e,t,o,s)=>({x:(e-n)/i,y:(t-r)/a,width:o/i,height:s/a})}let s=[];for(let e=0,n=t.rangeCount;e<n;e++){let n=t.getRangeAt(e);if(!n.collapsed)for(let{x:e,y:t,width:r,height:i}of n.getClientRects())r!==0&&i!==0&&s.push(o(e,t,r,i))}return s.length===0?null:s}addChangedExistingAnnotation({annotationElementId:e,id:t}){(this.#l||=new Map).set(e,t)}removeChangedExistingAnnotation({annotationElementId:e}){this.#l?.delete(e)}renderAnnotationElement(e){let t=this.#l?.get(e.data.id);if(!t)return;let n=this.#c.getRawValue(t);n&&(this.#L!==p.NONE||n.hasBeenModified)&&n.renderAnnotationElement(e)}setMissingCanvas(e,t,n){let r=this.#F?.get(e);r&&(r.setCanvas(t,n),this.#F.delete(e))}addMissingCanvas(e,t){(this.#F||=new Map).set(e,t)}},at=class e{#e=null;#t=!1;#n=null;#r=null;#i=null;#a=null;#o=!1;#s=null;#c=null;#l=null;#u=null;#d=!1;static#f=null;static _l10n=null;constructor(t){this.#c=t,this.#d=t._uiManager.useNewAltTextFlow,e.#f||=Object.freeze({added:`pdfjs-editor-new-alt-text-added-button`,"added-label":`pdfjs-editor-new-alt-text-added-button-label`,missing:`pdfjs-editor-new-alt-text-missing-button`,"missing-label":`pdfjs-editor-new-alt-text-missing-button-label`,review:`pdfjs-editor-new-alt-text-to-review-button`,"review-label":`pdfjs-editor-new-alt-text-to-review-button-label`})}static initialize(t){e._l10n??=t}async render(){let t=this.#n=document.createElement(`button`);t.className=`altText`,t.tabIndex=`0`;let n=this.#r=document.createElement(`span`);t.append(n),this.#d?(t.classList.add(`new`),t.setAttribute(`data-l10n-id`,e.#f.missing),n.setAttribute(`data-l10n-id`,e.#f[`missing-label`])):(t.setAttribute(`data-l10n-id`,`pdfjs-editor-alt-text-button`),n.setAttribute(`data-l10n-id`,`pdfjs-editor-alt-text-button-label`));let r=this.#c._uiManager._signal;t.addEventListener(`contextmenu`,ke,{signal:r}),t.addEventListener(`pointerdown`,e=>e.stopPropagation(),{signal:r});let i=e=>{e.preventDefault(),this.#c._uiManager.editAltText(this.#c),this.#d&&this.#c._reportTelemetry({action:`pdfjs.image.alt_text.image_status_label_clicked`,data:{label:this.#p}})};return t.addEventListener(`click`,i,{capture:!0,signal:r}),t.addEventListener(`keydown`,e=>{e.target===t&&e.key===`Enter`&&(this.#o=!0,i(e))},{signal:r}),await this.#m(),t}get#p(){return this.#e&&`added`||this.#e===null&&this.guessedText&&`review`||`missing`}finish(){this.#n&&(this.#n.focus({focusVisible:this.#o}),this.#o=!1)}isEmpty(){return this.#d?this.#e===null:!this.#e&&!this.#t}hasData(){return this.#d?this.#e!==null||!!this.#l:this.isEmpty()}get guessedText(){return this.#l}async setGuessedText(t){this.#e===null&&(this.#l=t,this.#u=await e._l10n.get(`pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer`,{generatedAltText:t}),this.#m())}toggleAltTextBadge(e=!1){if(!this.#d||this.#e){this.#s?.remove(),this.#s=null;return}if(!this.#s){let e=this.#s=document.createElement(`div`);e.className=`noAltTextBadge`,this.#c.div.append(e)}this.#s.classList.toggle(`hidden`,!e)}serialize(e){let t=this.#e;return!e&&this.#l===t&&(t=this.#u),{altText:t,decorative:this.#t,guessedText:this.#l,textWithDisclaimer:this.#u}}get data(){return{altText:this.#e,decorative:this.#t}}set data({altText:e,decorative:t,guessedText:n,textWithDisclaimer:r,cancel:i=!1}){n&&(this.#l=n,this.#u=r),(this.#e!==e||this.#t!==t)&&(i||(this.#e=e,this.#t=t),this.#m())}toggle(e=!1){this.#n&&(!e&&this.#a&&(clearTimeout(this.#a),this.#a=null),this.#n.disabled=!e)}shown(){this.#c._reportTelemetry({action:`pdfjs.image.alt_text.image_status_label_displayed`,data:{label:this.#p}})}destroy(){this.#n?.remove(),this.#n=null,this.#r=null,this.#i=null,this.#s?.remove(),this.#s=null}async#m(){let t=this.#n;if(!t)return;if(this.#d){if(t.classList.toggle(`done`,!!this.#e),t.setAttribute(`data-l10n-id`,e.#f[this.#p]),this.#r?.setAttribute(`data-l10n-id`,e.#f[`${this.#p}-label`]),!this.#e){this.#i?.remove();return}}else{if(!this.#e&&!this.#t){t.classList.remove(`done`),this.#i?.remove();return}t.classList.add(`done`),t.setAttribute(`data-l10n-id`,`pdfjs-editor-alt-text-edit-button`)}let n=this.#i;if(!n){this.#i=n=document.createElement(`span`),n.className=`tooltip`,n.setAttribute(`role`,`tooltip`),n.id=`alt-text-tooltip-${this.#c.id}`;let e=this.#c._uiManager._signal;e.addEventListener(`abort`,()=>{clearTimeout(this.#a),this.#a=null},{once:!0}),t.addEventListener(`mouseenter`,()=>{this.#a=setTimeout(()=>{this.#a=null,this.#i.classList.add(`show`),this.#c._reportTelemetry({action:`alt_text_tooltip`})},100)},{signal:e}),t.addEventListener(`mouseleave`,()=>{this.#a&&=(clearTimeout(this.#a),null),this.#i?.classList.remove(`show`)},{signal:e})}this.#t?n.setAttribute(`data-l10n-id`,`pdfjs-editor-alt-text-decorative-tooltip`):(n.removeAttribute(`data-l10n-id`),n.textContent=this.#e),n.parentNode||t.append(n),this.#c.getElementForAltText()?.setAttribute(`aria-describedby`,n.id)}},ot=class{#e=null;#t=null;#n=!1;#r=null;#i=null;#a=null;#o=null;#s=null;#c=!1;#l=null;constructor(e){this.#r=e}renderForToolbar(){let e=this.#t=document.createElement(`button`);return e.className=`comment`,this.#u(e,!1)}renderForStandalone(){let e=this.#e=document.createElement(`button`);e.className=`annotationCommentButton`;let t=this.#r.commentButtonPosition;if(t){let{style:n}=e;n.insetInlineEnd=`calc(${100*(this.#r._uiManager.direction===`ltr`?1-t[0]:t[0])}% - var(--comment-button-dim))`,n.top=`calc(${100*t[1]}% - var(--comment-button-dim))`;let r=this.#r.commentButtonColor;r&&(n.backgroundColor=r)}return this.#u(e,!0)}focusButton(){setTimeout(()=>{(this.#e??this.#t)?.focus()},0)}onUpdatedColor(){if(!this.#e)return;let e=this.#r.commentButtonColor;e&&(this.#e.style.backgroundColor=e),this.#r._uiManager.updatePopupColor(this.#r)}get commentButtonWidth(){return(this.#e?.getBoundingClientRect().width??0)/this.#r.parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(this.#l)return this.#l;if(!this.#e)return null;let{x:e,y:t,height:n}=this.#e.getBoundingClientRect(),{x:r,y:i,width:a,height:o}=this.#r.parent.boundingClientRect;return[(e-r)/a,(t+n-i)/o]}set commentPopupPositionInLayer(e){this.#l=e}hasDefaultPopupPosition(){return this.#l===null}removeStandaloneCommentButton(){this.#e?.remove(),this.#e=null}removeToolbarCommentButton(){this.#t?.remove(),this.#t=null}setCommentButtonStates({selected:e,hasPopup:t}){this.#e&&(this.#e.classList.toggle(`selected`,e),this.#e.ariaExpanded=t)}#u(e,t){if(!this.#r._uiManager.hasCommentManager())return null;e.tabIndex=`0`,e.ariaHasPopup=`dialog`,t?(e.ariaControls=`commentPopup`,e.setAttribute(`data-l10n-id`,`pdfjs-show-comment-button`)):(e.ariaControlsElements=[this.#r._uiManager.getCommentDialogElement()],e.setAttribute(`data-l10n-id`,`pdfjs-editor-add-comment-button`));let n=this.#r._uiManager._signal;if(!(n instanceof AbortSignal)||n.aborted)return e;e.addEventListener(`contextmenu`,ke,{signal:n}),t&&(e.addEventListener(`focusin`,e=>{this.#r._focusEventsAllowed=!1,U(e)},{capture:!0,signal:n}),e.addEventListener(`focusout`,e=>{this.#r._focusEventsAllowed=!0,U(e)},{capture:!0,signal:n})),e.addEventListener(`pointerdown`,e=>e.stopPropagation(),{signal:n});let r=t=>{t.preventDefault(),e===this.#t?this.edit():this.#r.toggleComment(!0)};return e.addEventListener(`click`,r,{capture:!0,signal:n}),e.addEventListener(`keydown`,t=>{t.target===e&&t.key===`Enter`&&(this.#n=!0,r(t))},{signal:n}),e.addEventListener(`pointerenter`,()=>{this.#r.toggleComment(!1,!0)},{signal:n}),e.addEventListener(`pointerleave`,()=>{this.#r.toggleComment(!1,!1)},{signal:n}),e}edit(e){let t=this.commentPopupPositionInLayer,n,r;if(t)[n,r]=t;else{[n,r]=this.#r.commentButtonPosition;let{width:e,height:t,x:i,y:a}=this.#r;n=i+n*e,r=a+r*t}let i=this.#r.parent.boundingClientRect,{x:a,y:o,width:s,height:c}=i;this.#r._uiManager.editComment(this.#r,a+n*s,o+r*c,{...e,parentDimensions:i})}finish(){this.#t&&(this.#t.focus({focusVisible:this.#n}),this.#n=!1)}isDeleted(){return this.#c||this.#o===``}isEmpty(){return this.#o===null}hasBeenEdited(){return this.isDeleted()||this.#o!==this.#i}serialize(){return this.data}get data(){return{text:this.#o,richText:this.#a,date:this.#s,deleted:this.isDeleted()}}set data(e){if(e!==this.#o&&(this.#a=null),e===null){this.#o=``,this.#c=!0;return}this.#o=e,this.#s=new Date,this.#c=!1}restoreData({text:e,richText:t,date:n}){this.#o=e,this.#a=t,this.#s=n,this.#c=!1}setInitialText(e,t=null){this.#i=e,this.data=e,this.#s=null,this.#a=t}shown(){}destroy(){this.#t?.remove(),this.#t=null,this.#e?.remove(),this.#e=null,this.#o=``,this.#a=null,this.#s=null,this.#r=null,this.#n=!1,this.#c=!1}};function st(e){e.preventDefault()}var ct=1e-4;function lt(e){return e.cancelable?(U(e),!0):(e.stopPropagation(),!1)}var ut=class{#e;#t=!1;#n=null;#r;#i;#a;#o;#s;#c=!1;#l=null;#u;#d=new Set;#f=null;#p;#m=null;#h=0;constructor({container:e,isPinchingDisabled:t=null,isPinchingStopped:n=null,onPinchStart:r=null,onPinching:i=null,onPinchEnd:a=null,onPanning:o=null,signal:s}){this.#e=e,this.#n=n,this.#r=t,this.#i=r,this.#a=i,this.#o=a,this.#s=o,this.#p=new AbortController,this.#u=AbortSignal.any([s,this.#p.signal]),e.addEventListener(`touchstart`,this.#g.bind(this),{passive:!1,signal:this.#u})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/Ie.pixelRatio}get MIN_TOUCH_DISTANCE_TO_SCALE(){return 4/Ie.pixelRatio}#g(e){if(this.#r?.())return;this.#v(e);let t=this.#d;for(let{identifier:n}of e.changedTouches)t.add(n);if(t.size===1){this.#_();return}if(!this.#m){this.#m=new AbortController;let e=AbortSignal.any([this.#u,this.#m.signal]),t=this.#e,n={signal:e,capture:!1,passive:!1};t.addEventListener(`touchmove`,this.#x.bind(this),n);let r=this.#S.bind(this);t.addEventListener(`touchend`,r,n),t.addEventListener(`touchcancel`,r,n),n.capture=!0,t.addEventListener(`pointerdown`,U,n),t.addEventListener(`pointermove`,U,n),t.addEventListener(`pointercancel`,st,n),t.addEventListener(`pointerup`,st,n),this.#i?.()}this.#c=lt(e),this.#b(e)}#_(){if(this.#l)return;let e=this.#l=new AbortController,t=AbortSignal.any([this.#u,e.signal]),n=this.#e,r={capture:!0,signal:t,passive:!1},i=e=>{e.pointerType===`touch`&&(this.#l?.abort(),this.#l=null)};n.addEventListener(`pointerdown`,e=>{e.pointerType===`touch`&&(U(e),i(e))},r),n.addEventListener(`pointerup`,i,r),n.addEventListener(`pointercancel`,i,r)}#v(e){let t=this.#d;if(t.size===0)return;let n=this.#d=new Set;for(let{identifier:r}of e.touches)t.has(r)&&n.add(r)}#y(e){let t=this.#d,n=[];for(let r of e.touches)t.has(r.identifier)&&n.push(r);return n}#b(e){let t=this.#y(e);if(t.length!==2||this.#n?.()){this.#f=null;return}let[n,r]=t;this.#f={touch0X:n.screenX,touch0Y:n.screenY,touch1X:r.screenX,touch1Y:r.screenY,panX:(n.clientX+r.clientX)/2,panY:(n.clientY+r.clientY)/2,screenPanX:(n.screenX+r.screenX)/2,screenPanY:(n.screenY+r.screenY)/2}}#x(e){if(!this.#f)return;let t=this.#y(e);if(t.length!==2)return;let n=this.#c;if(this.#c=lt(e),!this.#c)return;if(!n){this.#b(e);return}let[r,i]=t,{screenX:a,screenY:o}=r,{screenX:s,screenY:c}=i,l=this.#f,{touch0X:u,touch0Y:d,touch1X:f,touch1Y:p,panX:m,panY:h}=l,g=f-u,_=p-d,v=s-a,y=c-o,b=(r.clientX+i.clientX)/2,x=(r.clientY+i.clientY)/2;l.panX=b,l.panY=x;let S=b-m,C=x-h,w=(a+s)/2,T=(o+c)/2,E=Math.hypot(w-l.screenPanX,T-l.screenPanY);l.screenPanX=w,l.screenPanY=T;let D=Math.hypot(v,y),O=Math.hypot(g,_),k=this.#t?this.MIN_TOUCH_DISTANCE_TO_SCALE:this.MIN_TOUCH_DISTANCE_TO_PINCH+2*E;if(D<ct||O<ct||Math.abs(O-D)<=k){(S||C)&&this.#s?.(S,C);return}l.touch0X=a,l.touch0Y=o,l.touch1X=s,l.touch1Y=c;let A=Math.sign(D-O);if(!this.#t){this.#t=!0,this.#h=A,(S||C)&&this.#s?.(S,C);return}if(this.#h){let e=this.#h;if(this.#h=0,A!==e&&Math.abs(D-O)<=2*E){this.#t=!1,(S||C)&&this.#s?.(S,C);return}}this.#a?.([m,h],O,D,S,C)}#S(e){if(this.#v(e),this.#d.size>=2){this.#b(e);return}let t=!!this.#f;this.#C(),this.#d.size===1&&this.#_(),t&<(e)}#C(){this.#f=null,this.#t=!1,this.#h=0,this.#c=!1,this.#m&&(this.#m.abort(),this.#m=null,this.#o?.())}destroy(){this.#C(),this.#d.clear(),this.#p?.abort(),this.#p=null,this.#l?.abort(),this.#l=null}},K=class e{#e=null;#t=null;#n=null;#r=null;#i=null;#a=!1;#o=null;#s=``;#c=null;#l=null;#u=null;#d=null;#f=null;#p=``;#m=!1;#h=null;#g=!1;#_=!1;#v=!1;#y=null;#b=0;#x=0;#S=null;#C=null;isSelected=!1;_isCopy=!1;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nAlert=null;static _l10nResizer=null;#w=!1;#T=e._zIndex++;static _borderLineWidth=-1;static _colorManager=new rt;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){let t=e.prototype._resizeWithKeyboard,n=it.TRANSLATE_SMALL,r=it.TRANSLATE_BIG;return F(this,`_resizerKeyboardManager`,new nt([[[`ArrowLeft`],t,{args:[-n,0]}],[[`ctrl+ArrowLeft`,`mac+shift+ArrowLeft`],t,{args:[-r,0]}],[[`ArrowRight`],t,{args:[n,0]}],[[`ctrl+ArrowRight`,`mac+shift+ArrowRight`],t,{args:[r,0]}],[[`ArrowUp`],t,{args:[0,-n]}],[[`ctrl+ArrowUp`,`mac+shift+ArrowUp`],t,{args:[0,-r]}],[[`ArrowDown`],t,{args:[0,n]}],[[`ctrl+ArrowDown`,`mac+shift+ArrowDown`],t,{args:[0,r]}],[[`Escape`],e.prototype._stopResizingWithKeyboard]]))}constructor(e){this.parent=e.parent,this.id=e.id,this.width=this.height=null,this.pageIndex=e.parent.pageIndex,this.name=e.name,this.div=null,this._uiManager=e.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=e.isCentered,this._structTreeParentId=null,this.annotationElementId=e.annotationElementId||null,this.creationDate=e.creationDate||new Date,this.modificationDate=e.modificationDate||null,this.canAddComment=!0;let{rotation:t,rawDims:{pageWidth:n,pageHeight:r,pageX:i,pageY:a}}=this.parent.viewport;this.rotation=t,this.pageRotation=(360+t-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[n,r],this.pageTranslation=[i,a];let[o,s]=this.parentDimensions;this.x=e.x/o,this.y=e.y/s,this.isAttachedToDOM=!1,this.deleted=!1}updatePageIndex(e){this.pageIndex=e}get editorType(){return Object.getPrototypeOf(this).constructor._type}get mode(){return Object.getPrototypeOf(this).constructor._editorType}static get isDrawer(){return!1}static get _defaultLineColor(){return F(this,`_defaultLineColor`,this._colorManager.getHexCode(`CanvasText`))}static deleteAnnotationElement(e){let t=new dt({id:e._uiManager.getId(),parent:e.parent,uiManager:e._uiManager});t.annotationElementId=e.annotationElementId,t.deleted=!0,t._uiManager.addToAnnotationStorage(t)}static initialize(t,n){if(e._l10n??=t,e._l10nAlert??=Object.freeze({highlight:`pdfjs-editor-highlight-added-alert`,freetext:`pdfjs-editor-freetext-added-alert`,ink:`pdfjs-editor-ink-added-alert`,stamp:`pdfjs-editor-stamp-added-alert`,signature:`pdfjs-editor-signature-added-alert`}),e._l10nResizer??=Object.freeze({topLeft:`pdfjs-editor-resizer-top-left`,topMiddle:`pdfjs-editor-resizer-top-middle`,topRight:`pdfjs-editor-resizer-top-right`,middleRight:`pdfjs-editor-resizer-middle-right`,bottomRight:`pdfjs-editor-resizer-bottom-right`,bottomMiddle:`pdfjs-editor-resizer-bottom-middle`,bottomLeft:`pdfjs-editor-resizer-bottom-left`,middleLeft:`pdfjs-editor-resizer-middle-left`}),e._borderLineWidth!==-1)return;let r=getComputedStyle(document.documentElement);e._borderLineWidth=parseFloat(r.getPropertyValue(`--outline-width`))||0}static updateDefaultParams(e,t){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(e){return!1}static paste(e,t){k(`Not implemented`)}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#w}set _isDraggable(e){this.#w=e,this.div?.classList.toggle(`draggable`,e)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return!0}center(){let[e,t]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*t/(e*2),this.y+=this.width*e/(t*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*t/(e*2),this.y-=this.width*e/(t*2);break;default:this.x-=this.width/2,this.y-=this.height/2}this.fixAndSetPosition()}addCommands(e){this._uiManager.addCommands(e)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#T}setParent(e){e===null?(this.#G(),this.#d?.remove(),this.#d=null):(this.pageIndex=e.pageIndex,this.pageDimensions=e.pageDimensions),this.parent=e}focusin(e){this._focusEventsAllowed&&(this.#m?this.#m=!1:this.parent.setSelected(this))}focusout(e){this._focusEventsAllowed&&this.isAttachedToDOM&&(e.relatedTarget?.closest(`#${this.id}`)||(e.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove()))}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.isInEditMode()&&this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(e,t,n,r){let[i,a]=this.parentDimensions;[n,r]=this.screenToPageTranslation(n,r),this.x=(e+n)/i,this.y=(t+r)/a,this.fixAndSetPosition()}_moveAfterPaste(e,t){if(this.isClone){delete this.isClone;return}let[n,r]=this.parentDimensions;this.setAt(e*n,t*r,this.width*n,this.height*r),this._onTranslated()}#E([e,t],n,r){[n,r]=this.screenToPageTranslation(n,r),this.x+=n/e,this.y+=r/t,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(e,t){this.#E(this.parentDimensions,e,t)}translateInPage(e,t){this.#h||=[this.x,this.y,this.width,this.height],this.#E(this.pageDimensions,e,t),this.div.scrollIntoView({block:`nearest`})}translationDone(){this._onTranslated(this.x,this.y)}drag(e,t){this.#h||=[this.x,this.y,this.width,this.height];let{div:n,parentDimensions:[r,i]}=this;if(this.x+=e/r,this.y+=t/i,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){let{x:e,y:t}=this.div.getBoundingClientRect();this.parent.findNewParent(this,e,t)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:a,y:o}=this,[s,c]=this.getBaseTranslation();a+=s,o+=c;let{style:l}=n;l.left=`${(100*a).toFixed(2)}%`,l.top=`${(100*o).toFixed(2)}%`,this._onTranslating(a,o)}_onTranslating(e,t){}_onTranslated(e,t){}get _hasBeenMoved(){return!!this.#h&&(this.#h[0]!==this.x||this.#h[1]!==this.y)}get _hasBeenResized(){return!!this.#h&&(this.#h[2]!==this.width||this.#h[3]!==this.height)}getBaseTranslation(){let[t,n]=this.parentDimensions,{_borderLineWidth:r}=e,i=r/t,a=r/n;switch(this.rotation){case 90:return[-i,a];case 180:return[i,a];case 270:return[i,-a];default:return[-i,-a]}}get _mustFixPosition(){return!0}fixAndSetPosition(e=this.rotation){let{div:{style:t},pageDimensions:[n,r]}=this,{x:i,y:a,width:o,height:s}=this;if(o*=n,s*=r,i*=n,a*=r,this._mustFixPosition)switch(e){case 0:i=H(i,0,n-o),a=H(a,0,r-s);break;case 90:i=H(i,0,n-s),a=H(a,o,r);break;case 180:i=H(i,o,n),a=H(a,s,r);break;case 270:i=H(i,s,n),a=H(a,0,r-o)}this.x=i/=n,this.y=a/=r;let[c,l]=this.getBaseTranslation();i+=c,a+=l,t.left=`${(100*i).toFixed(2)}%`,t.top=`${(100*a).toFixed(2)}%`,this.moveInDOM()}static#D(e,t,n){switch(n){case 90:return[t,-e];case 180:return[-e,-t];case 270:return[-t,e];default:return[e,t]}}screenToPageTranslation(t,n){return e.#D(t,n,this.parentRotation)}pageTranslationToScreen(t,n){return e.#D(t,n,360-this.parentRotation)}#O(e){switch(e){case 90:{let[e,t]=this.pageDimensions;return[0,-e/t,t/e,0]}case 180:return[-1,0,0,-1];case 270:{let[e,t]=this.pageDimensions;return[0,e/t,-t/e,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){let{parentScale:e,pageDimensions:[t,n]}=this;return[t*e,n*e]}setDims(){let{div:{style:e},width:t,height:n}=this;e.width=`${(100*t).toFixed(2)}%`,e.height=`${(100*n).toFixed(2)}%`}getInitialTranslation(){return[0,0]}#k(){if(this.#c)return;this.#c=document.createElement(`div`),this.#c.classList.add(`resizers`);let e=this._willKeepAspectRatio?[`topLeft`,`topRight`,`bottomRight`,`bottomLeft`]:[`topLeft`,`topMiddle`,`topRight`,`middleRight`,`bottomRight`,`bottomMiddle`,`bottomLeft`,`middleLeft`],t=this._uiManager._signal;for(let n of e){let e=document.createElement(`div`);this.#c.append(e),e.classList.add(`resizer`,n),e.setAttribute(`data-resizer-name`,n),e.addEventListener(`pointerdown`,this.#A.bind(this,n),{signal:t}),e.addEventListener(`contextmenu`,ke,{signal:t}),e.tabIndex=-1}this.div.prepend(this.#c)}#A(e,t){t.preventDefault();let{isMac:n}=B.platform;if(t.button!==0||t.ctrlKey&&n)return;this.#n?.toggle(!1);let r=this._isDraggable;this._isDraggable=!1,this.#l=[t.screenX,t.screenY];let i=new AbortController,a=this._uiManager.combinedSignal(i);this.parent.togglePointerEvents(!1),window.addEventListener(`pointermove`,this.#N.bind(this,e),{passive:!0,capture:!0,signal:a}),window.addEventListener(`touchmove`,U,{passive:!1,signal:a}),window.addEventListener(`contextmenu`,ke,{signal:a}),this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let o=this.parent.div.style.cursor,s=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(t.target).cursor;let c=()=>{i.abort(),this.parent.togglePointerEvents(!0),this.#n?.toggle(!0),this._isDraggable=r,this.parent.div.style.cursor=o,this.div.style.cursor=s,this.#M()};window.addEventListener(`pointerup`,c,{signal:a}),window.addEventListener(`blur`,c,{signal:a})}#j(e,t,n,r){this.width=n,this.height=r,this.x=e,this.y=t,this.setDims(),this.fixAndSetPosition(),this._onResized()}_onResized(){}#M(){if(!this.#u)return;let{savedX:e,savedY:t,savedWidth:n,savedHeight:r}=this.#u;this.#u=null;let i=this.x,a=this.y,o=this.width,s=this.height;(i!==e||a!==t||o!==n||s!==r)&&this.addCommands({cmd:this.#j.bind(this,i,a,o,s),undo:this.#j.bind(this,e,t,n,r),mustExec:!0})}static _round(e){return Math.round(e*1e4)/1e4}#N(t,n){let[r,i]=this.parentDimensions,a=this.x,o=this.y,s=this.width,c=this.height,l=e.MIN_SIZE/r,u=e.MIN_SIZE/i,d=this.#O(this.rotation),f=(e,t)=>[d[0]*e+d[2]*t,d[1]*e+d[3]*t],p=this.#O(360-this.rotation),m=(e,t)=>[p[0]*e+p[2]*t,p[1]*e+p[3]*t],h,g,_=!1,v=!1;switch(t){case`topLeft`:_=!0,h=(e,t)=>[0,0],g=(e,t)=>[e,t];break;case`topMiddle`:h=(e,t)=>[e/2,0],g=(e,t)=>[e/2,t];break;case`topRight`:_=!0,h=(e,t)=>[e,0],g=(e,t)=>[0,t];break;case`middleRight`:v=!0,h=(e,t)=>[e,t/2],g=(e,t)=>[0,t/2];break;case`bottomRight`:_=!0,h=(e,t)=>[e,t],g=(e,t)=>[0,0];break;case`bottomMiddle`:h=(e,t)=>[e/2,t],g=(e,t)=>[e/2,0];break;case`bottomLeft`:_=!0,h=(e,t)=>[0,t],g=(e,t)=>[e,0];break;case`middleLeft`:v=!0,h=(e,t)=>[0,t/2],g=(e,t)=>[e,t/2]}let y=h(s,c),b=g(s,c),x=f(...b),S=e._round(a+x[0]),C=e._round(o+x[1]),w=1,T=1,E,D;if(n.fromKeyboard)({deltaX:E,deltaY:D}=n);else{let{screenX:e,screenY:t}=n,[r,i]=this.#l;[E,D]=this.screenToPageTranslation(e-r,t-i),this.#l[0]=e,this.#l[1]=t}if([E,D]=m(E/r,D/i),_){let e=Math.hypot(s,c);w=T=Math.max(Math.min(Math.hypot(b[0]-y[0]-E,b[1]-y[1]-D)/e,1/s,1/c),l/s,u/c)}else v?w=H(Math.abs(b[0]-y[0]-E),l,1)/s:T=H(Math.abs(b[1]-y[1]-D),u,1)/c;let O=e._round(s*w),k=e._round(c*T);x=f(...g(O,k));let A=S-x[0],j=C-x[1];this.#h||=[this.x,this.y,this.width,this.height],this.width=O,this.height=k,this.x=A,this.y=j,this.setDims(),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#n?.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||this.#_)return this._editToolbar;this._editToolbar=new Ye(this),this.div.append(this._editToolbar.render());let{toolbarButtons:e}=this;if(e)for(let[t,n]of e)await this._editToolbar.addButton(t,n);return this.hasComment||this._editToolbar.addButton(`comment`,this.addCommentButton()),this._editToolbar.addButton(`delete`),this._editToolbar}addCommentButtonInToolbar(){this._editToolbar?.addButtonBefore(`comment`,this.addCommentButton(),`.deleteButton`)}removeCommentButtonFromToolbar(){this._editToolbar?.removeButton(`comment`)}removeEditToolbar(){this._editToolbar?.remove(),this._editToolbar=null,this.#n?.destroy()}addContainer(e){let t=this._editToolbar?.div;t?t.before(e):this.div.append(e)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return this.#n||(at.initialize(e._l10n),this.#n=new at(this),this.#e&&=(this.#n.data=this.#e,null)),this.#n}get altTextData(){return this.#n?.data}set altTextData(e){this.#n&&(this.#n.data=e)}get guessedAltText(){return this.#n?.guessedText}async setGuessedAltText(e){await this.#n?.setGuessedText(e)}serializeAltText(e){return this.#n?.serialize(e)}hasAltText(){return!!this.#n&&!this.#n.isEmpty()}hasAltTextData(){return this.#n?.hasData()??!1}focusCommentButton(){this.#r?.focusButton()}addCommentButton(){return this.canAddComment?this.#r||=new ot(this):null}addStandaloneCommentButton(){if(this._uiManager.hasCommentManager()){if(this.#i){this._uiManager.isEditingMode()&&this.#i.classList.remove(`hidden`);return}this.hasComment&&(this.#i=this.#r.renderForStandalone(),this.div.append(this.#i))}}removeStandaloneCommentButton(){this.#r.removeStandaloneCommentButton(),this.#i=null}hideStandaloneCommentButton(){this.#i?.classList.add(`hidden`)}get comment(){if(!this.#r)return null;let{data:{richText:e,text:t,date:n,deleted:r}}=this.#r;return{text:t,richText:e,date:n,deleted:r,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(e){this.#r||=new ot(this),typeof e==`object`&&e?this.#r.restoreData(e):this.#r.data=e,this.hasComment?(this.removeCommentButtonFromToolbar(),this.addStandaloneCommentButton(),this._uiManager.updateComment(this)):(this.addCommentButtonInToolbar(),this.removeStandaloneCommentButton(),this._uiManager.removeComment(this))}setCommentData({comment:e,popupRef:t,richText:n}){if(!t||(this.#r||=new ot(this),this.#r.setInitialText(e,n),!this.annotationElementId))return;let r=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);r&&this.updateFromAnnotationLayer(r)}get hasEditedComment(){return this.#r?.hasBeenEdited()}get hasDeletedComment(){return this.#r?.isDeleted()}get hasComment(){return!!this.#r&&!this.#r.isEmpty()&&!this.#r.isDeleted()}async editComment(e){this.#r||=new ot(this),this.#r.edit(e)}toggleComment(e,t=void 0){this.hasComment&&this._uiManager.toggleComment(this,e,t)}setSelectedCommentButton(e){this.#r.setSelectedButton(e)}addComment(e){if(this.hasEditedComment){let[,,,t]=e.rect,[n]=this.pageDimensions,[r]=this.pageTranslation,i=r+n+1,a=t-100,o=i+180;e.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[i,a,o,t]}}}updateFromAnnotationLayer({popup:{contents:e,deleted:t}}){this.#r.data=t?null:e}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){let e=this.div=document.createElement(`div`);e.setAttribute(`data-editor-rotation`,(360-this.rotation)%360),e.className=this.name,e.setAttribute(`id`,this.id),e.tabIndex=this.#a?-1:0,e.setAttribute(`role`,`application`),this.defaultL10nId&&e.setAttribute(`data-l10n-id`,this.defaultL10nId),this._isVisible||e.classList.add(`hidden`),this.setInForeground(),this.#z();let[t,n]=this.parentDimensions;this.parentRotation%180!=0&&(e.style.maxWidth=`${(100*n/t).toFixed(2)}%`,e.style.maxHeight=`${(100*t/n).toFixed(2)}%`);let[r,i]=this.getInitialTranslation();return this.translate(r,i),Qe(this,e,[`keydown`,`pointerdown`,`dblclick`]),this.#B(),this.addStandaloneCommentButton(),this._uiManager._editorUndoBar?.hide(),e}#P(){this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#n?.toggle(!1),this.parent.togglePointerEvents(!1)}#F(t,n,r){let i=.7,a=r/n*i+1-i;if(a===1)return;let o=this.#O(this.rotation),s=(e,t)=>[o[0]*e+o[2]*t,o[1]*e+o[3]*t],[c,l]=this.parentDimensions,u=this.x,d=this.y,f=this.width,p=this.height,m=e.MIN_SIZE/c,h=e.MIN_SIZE/l;a=Math.max(Math.min(a,1/f,1/p),m/f,h/p);let g=e._round(f*a),_=e._round(p*a);if(g===f&&_===p)return;this.#h||=[u,d,f,p];let v=s(f/2,p/2),y=e._round(u+v[0]),b=e._round(d+v[1]),x=s(g/2,_/2);this.x=y-x[0],this.y=b-x[1],this.width=g,this.height=_,this.setDims(),this.fixAndSetPosition(),this._onResizing()}#I(){this.#n?.toggle(!0),this.parent.togglePointerEvents(!0),this.#M()}pointerdown(e){let{isMac:t}=B.platform;if(e.button!==0||e.ctrlKey&&t){e.preventDefault();return}if(this.#m=!0,this._isDraggable){this.#R(e);return}this.#L(e)}#L(e){let{isMac:t}=B.platform;e.ctrlKey&&!t||e.shiftKey||e.metaKey&&t?this.parent.toggleSelected(this):this.parent.setSelected(this)}#R(e){let{isSelected:t}=this;this._uiManager.setUpDragSession();let n=!1,r=new AbortController,i=this._uiManager.combinedSignal(r),a={capture:!0,passive:!1,signal:i},o=e=>{r.abort(),this.#o=null,this.#m=!1,this._uiManager.endDragSession()||this.#L(e),n&&this._onStopDragging()};t&&(this.#b=e.clientX,this.#x=e.clientY,this.#o=e.pointerId,this.#s=e.pointerType,window.addEventListener(`pointermove`,e=>{n||(n=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());let{clientX:t,clientY:r,pointerId:i}=e;if(i!==this.#o){U(e);return}let[a,o]=this.screenToPageTranslation(t-this.#b,r-this.#x);this.#b=t,this.#x=r,this._uiManager.dragSelectedEditors(a,o),this.div.scrollIntoView({block:`nearest`})},a),window.addEventListener(`touchmove`,U,a),window.addEventListener(`pointerdown`,e=>{e.pointerType===this.#s&&(this.#C||e.isPrimary)&&o(e),U(e)},a));let s=e=>{if(!this.#o||this.#o===e.pointerId){o(e);return}U(e)};window.addEventListener(`pointerup`,s,{signal:i}),window.addEventListener(`blur`,s,{signal:i})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#y&&clearTimeout(this.#y),this.#y=setTimeout(()=>{this.#y=null,this.parent?.moveEditorInDOM(this)},0)}_setParentAndPosition(e,t,n){e.changeParent(this),this.x=t,this.y=n,this.fixAndSetPosition(),this._onTranslated()}getRect(e,t,n=this.rotation){let r=this.parentScale,[i,a]=this.pageDimensions,[o,s]=this.pageTranslation,c=e/r,l=t/r,u=this.x*i,d=this.y*a,f=this.width*i,p=this.height*a;switch(n){case 0:return[u+c+o,a-d-l-p+s,u+c+f+o,a-d-l+s];case 90:return[u+l+o,a-d+c+s,u+l+p+o,a-d+c+f+s];case 180:return[u-c-f+o,a-d+l+s,u-c+o,a-d+l+p+s];case 270:return[u-l-p+o,a-d-c-f+s,u-l+o,a-d-c+s];default:throw Error(`Invalid rotation`)}}getRectInCurrentCoords(e,t){let[n,r,i,a]=e,o=i-n,s=a-r;switch(this.rotation){case 0:return[n,t-a,o,s];case 90:return[n,t-r,s,o];case 180:return[i,t-r,o,s];case 270:return[i,t-a,s,o];default:throw Error(`Invalid rotation`)}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&e._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){this.#r?.onUpdatedColor()}getData(){let{comment:{text:e,color:t,date:n,opacity:r,deleted:i,richText:a},uid:o,pageIndex:s,creationDate:c,modificationDate:l}=this;return{id:o,pageIndex:s,rect:this.getPDFRect(),richText:a,contentsObj:{str:e},creationDate:c,modificationDate:n||l,popupRef:!i,color:t,opacity:r}}onceAdded(e){}isEmpty(){return!1}enableEditMode(){return!this.isInEditMode()&&(this.parent.setEditingState(!1),this.#_=!0,!0)}disableEditMode(){return this.isInEditMode()?(this.parent.setEditingState(!0),this.#_=!1,!0):!1}isInEditMode(){return this.#_}shouldGetKeyboardEvents(){return this.#v}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){let{top:e,left:t,bottom:n,right:r}=this.getClientDimensions(),{innerHeight:i,innerWidth:a}=window;return t<a&&r>0&&e<i&&n>0}#z(){if(this.#f||!this.div)return;this.#f=new AbortController;let e=this._uiManager.combinedSignal(this.#f);this.div.addEventListener(`focusin`,this.focusin.bind(this),{signal:e}),this.div.addEventListener(`focusout`,this.focusout.bind(this),{signal:e})}#B(){this.#C||!this.div||!this.isResizable||!this._uiManager._supportsPinchToZoom||(this.#C=new ut({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#P.bind(this),onPinching:this.#F.bind(this),onPinchEnd:this.#I.bind(this),signal:this._uiManager._signal}))}rebuild(){this.#z(),this.#B()}rotate(e){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||``}}serialize(e=!1,t=null){return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:this._initialData?.popupRef||``}}static async deserialize(e,t,n){let r=new this.prototype.constructor({parent:t,id:n.getId(),uiManager:n,annotationElementId:e.annotationElementId,creationDate:e.creationDate,modificationDate:e.modificationDate});r.rotation=e.rotation,r.#e=e.accessibilityData,r._isCopy=e.isCopy||!1;let[i,a]=r.pageDimensions,[o,s,c,l]=r.getRectInCurrentCoords(e.rect,a);return r.x=o/i,r.y=s/a,r.width=c/i,r.height=l/a,r}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){if(this.#f?.abort(),this.#f=null,this.isEmpty()||this.commit(),this.#C?.destroy(),this.#C=null,this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.hideCommentPopup(),this.#y&&=(clearTimeout(this.#y),null),this.#G(),this.removeEditToolbar(),this.#S){for(let e of this.#S.values())clearTimeout(e);this.#S=null}this.parent=null,this.#d?.remove(),this.#d=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#k(),this.#c.classList.remove(`hidden`))}get toolbarPosition(){return null}get commentButtonPosition(){return this._uiManager.direction===`ltr`?[1,0]:[0,0]}get commentButtonPositionInPage(){let{commentButtonPosition:[t,n]}=this,[r,i,a,o]=this.getPDFRect();return[e._round(r+(a-r)*t),e._round(i+(o-i)*(1-n))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return this.#r.commentPopupPositionInLayer}set commentPopupPosition(e){this.#r.commentPopupPositionInLayer=e}hasDefaultPopupPosition(){return this.#r.hasDefaultPopupPosition()}get commentButtonWidth(){return this.#r.commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(e){this.#r?.setCommentButtonStates(e)}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!==`Enter`)return;this._uiManager.setSelected(this),this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let n=this.#c.children;if(!this.#t){this.#t=Array.from(n);let t=this.#V.bind(this),r=this.#H.bind(this),i=this._uiManager._signal;for(let n of this.#t){let a=n.getAttribute(`data-resizer-name`);n.setAttribute(`role`,`spinbutton`),n.addEventListener(`keydown`,t,{signal:i}),n.addEventListener(`blur`,r,{signal:i}),n.addEventListener(`focus`,this.#U.bind(this,a),{signal:i}),n.setAttribute(`data-l10n-id`,e._l10nResizer[a])}}let r=this.#t[0],i=0;for(let e of n){if(e===r)break;i++}let a=(360-this.rotation+this.parentRotation)%360/90*(this.#t.length/4);if(a!==i){if(a<i)for(let e=0;e<i-a;e++)this.#c.append(this.#c.firstElementChild);else if(a>i)for(let e=0;e<a-i;e++)this.#c.firstElementChild.before(this.#c.lastElementChild);let t=0;for(let r of n){let n=this.#t[t++].getAttribute(`data-resizer-name`);r.setAttribute(`data-l10n-id`,e._l10nResizer[n])}}this.#W(0),this.#v=!0,this.#c.firstElementChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#V(t){e._resizerKeyboardManager.exec(this,t)}#H(e){this.#v&&e.relatedTarget?.parentNode!==this.#c&&this.#G()}#U(e){this.#p=this.#v?e:``}#W(e){if(this.#t)for(let t of this.#t)t.tabIndex=e}_resizeWithKeyboard(e,t){this.#v&&this.#N(this.#p,{deltaX:e,deltaY:t,fromKeyboard:!0})}#G(){this.#v=!1,this.#W(-1),this.#M()}_stopResizingWithKeyboard(){this.#G(),this.div.focus()}select(){if(this.isSelected&&this._editToolbar){this._editToolbar.show();return}if(this.isSelected=!0,this.makeResizable(),this.div?.classList.add(`selectedEditor`),!this._editToolbar){this.addEditToolbar().then(()=>{this.div?.classList.contains(`selectedEditor`)&&this._editToolbar?.show()});return}this._editToolbar?.show(),this.#n?.toggleAltTextBadge(!1)}focus(){this.div&&!this.div.contains(document.activeElement)&&setTimeout(()=>this.div?.focus({preventScroll:!0}),0)}unselect(){this.isSelected&&(this.isSelected=!1,this.#c?.classList.add(`hidden`),this.div?.classList.remove(`selectedEditor`),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#n?.toggleAltTextBadge(!0),this.hideCommentPopup())}hideCommentPopup(){this.hasComment&&this._uiManager.toggleComment(null)}updateParams(e,t){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(e){e.target.nodeName!==`BUTTON`&&(this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.uid}))}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return this.#g}set isEditing(e){this.#g=e,this.parent&&(e?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:`added`}}get telemetryFinalData(){return null}_reportTelemetry(t,n=!1){if(n){this.#S||=new Map;let{action:n}=t,r=this.#S.get(n);r&&clearTimeout(r),r=setTimeout(()=>{this._reportTelemetry(t),this.#S.delete(n),this.#S.size===0&&(this.#S=null)},e._telemetryTimeout),this.#S.set(n,r);return}t.type||=this.editorType,this._uiManager._eventBus.dispatch(`reporttelemetry`,{source:this,details:{type:`editing`,data:t}})}show(e=this._isVisible){this.div.classList.toggle(`hidden`,!e),this._isVisible=e}enable(){this.div&&(this.div.tabIndex=0),this.#a=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#a=!0}updateFakeAnnotationElement(e){if(!this.#d&&!this.deleted){this.#d=e.addFakeAnnotation(this);return}if(this.deleted){this.#d.remove(),this.#d=null;return}(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&this.#d.updateEdited({rect:this.getPDFRect(),popup:this.comment})}renderAnnotationElement(e){if(this.deleted)return e.hide(),null;let t=e.container.querySelector(`.annotationContent`);if(!t)t=document.createElement(`div`),t.classList.add(`annotationContent`,this.editorType),e.container.prepend(t);else if(t.nodeName===`CANVAS`){let e=t;t=document.createElement(`div`),t.classList.add(`annotationContent`,this.editorType),e.before(t)}return t}resetAnnotationElement(e){let{firstElementChild:t}=e.container;t?.nodeName===`DIV`&&t.classList.contains(`annotationContent`)&&t.remove()}},dt=class extends K{constructor(e){super(e),this.annotationElementId=e.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}},ft=3285377520,pt=4294901760,mt=65535,ht=class{constructor(e){this.h1=e?e&4294967295:ft,this.h2=e?e&4294967295:ft}update(e){let t,n;if(typeof e==`string`){t=new Uint8Array(e.length*2),n=0;for(let r=0,i=e.length;r<i;r++){let i=e.charCodeAt(r);i<=255?t[n++]=i:(t[n++]=i>>>8,t[n++]=i&255)}}else if(ArrayBuffer.isView(e))t=e.slice(),n=t.byteLength;else throw Error(`Invalid data format, must be a string or TypedArray.`);let r=n>>2,i=n-r*4,a=new Uint32Array(t.buffer,0,r),o=0,s=0,c=this.h1,l=this.h2,u=3432918353,d=461845907,f=11601,p=13715;for(let e=0;e<r;e++)e&1?(o=a[e],o=o*u&pt|o*f&mt,o=o<<15|o>>>17,o=o*d&pt|o*p&mt,c^=o,c=c<<13|c>>>19,c=c*5+3864292196):(s=a[e],s=s*u&pt|s*f&mt,s=s<<15|s>>>17,s=s*d&pt|s*p&mt,l^=s,l=l<<13|l>>>19,l=l*5+3864292196);switch(o=0,i){case 3:o^=t[r*4+2]<<16;case 2:o^=t[r*4+1]<<8;case 1:o^=t[r*4],o=o*u&pt|o*f&mt,o=o<<15|o>>>17,o=o*d&pt|o*p&mt,r&1?c^=o:l^=o}this.h1=c,this.h2=l}hexdigest(){let e=this.h1,t=this.h2;return e^=t>>>1,e=e*3981806797&pt|e*36045&mt,t=t*4283543511&pt|((t<<16|e>>>16)*2950163797&pt)>>>16,e^=t>>>1,e=e*444984403&pt|e*60499&mt,t=t*3301882366&pt|((t<<16|e>>>16)*3120437893&pt)>>>16,e^=t>>>1,(e>>>0).toString(16).padStart(8,`0`)+(t>>>0).toString(16).padStart(8,`0`)}},gt=Object.freeze({map:null,hash:``,transfer:void 0}),_t=class{#e=!1;#t=null;#n=null;#r=new Map;onSetModified=null;onResetModified=null;onAnnotationEditor=null;getValue(e,t){let n=this.#r.get(e);return n===void 0?t:Object.assign(t,n)}getRawValue(e){return this.#r.get(e)}remove(e){let t=this.#r.get(e);t!==void 0&&(t instanceof K&&this.#n.delete(t.annotationElementId),this.#r.delete(e),this.#r.size===0&&this.resetModified(),!this.#r.values().some(e=>e instanceof K)&&this.onAnnotationEditor?.(null))}setValue(e,t){let n=this.#r.get(e),r=!1;if(n!==void 0)for(let[e,i]of Object.entries(t))n[e]!==i&&(r=!0,n[e]=i);else r=!0,this.#r.set(e,t);r&&this.#i(),t instanceof K&&((this.#n||=new Map).set(t.annotationElementId,t),this.onAnnotationEditor?.(t.constructor._type))}has(e){return this.#r.has(e)}get size(){return this.#r.size}#i(){this.#e||(this.#e=!0,this.onSetModified?.())}resetModified(){this.#e&&(this.#e=!1,this.onResetModified?.())}get print(){return new vt(this)}get serializable(){if(this.#r.size===0)return gt;let e=new Map,t=new ht,n=[],r=Object.create(null),i=!1;for(let[n,a]of this.#r){let o=a instanceof K?a.serialize(!1,r):a;a.page&&(a.pageIndex=a.page._pageIndex,delete a.page),o&&(e.set(n,o),t.update(`${n}:${JSON.stringify(o)}`),i||=!!o.bitmap)}if(i)for(let t of e.values())t.bitmap&&n.push(t.bitmap);return e.size>0?{map:e,hash:t.hexdigest(),transfer:n}:gt}get editorStats(){let e=null,t=new Map,n=0,r=0;for(let i of this.#r.values()){if(!(i instanceof K)){i.popup&&(i.popup.deleted?r+=1:n+=1);continue}i.isCommentDeleted?r+=1:i.hasEditedComment&&(n+=1);let a=i.telemetryFinalData;if(!a)continue;let{type:o}=a;t.getOrInsertComputed(o,()=>Object.getPrototypeOf(i).constructor),e||=Object.create(null);let s=e[o]||=new Map;for(let[e,t]of Object.entries(a)){if(e===`type`)continue;let n=s.getOrInsertComputed(e,fe);n.set(t,(n.get(t)??0)+1)}}if((r>0||n>0)&&(e||=Object.create(null),e.comments={deleted:r,edited:n}),!e)return null;for(let[n,r]of t)e[n]=r.computeTelemetryFinalData(e[n]);return e}resetModifiedIds(){this.#t=null}updateEditor(e,t){let n=this.#n?.get(e);return n?(n.updateFromAnnotationLayer(t),!0):!1}getEditor(e){return this.#n?.get(e)||null}get modifiedIds(){if(this.#t)return this.#t;let e=[];if(this.#n)for(let t of this.#n.values())t.serialize()&&e.push(t.annotationElementId);let t=``;if(e.length){let n=new ht;n.update(e.join(`,`)),t=n.hexdigest()}return this.#t={ids:new Set(e),hash:t}}[Symbol.iterator](){return this.#r.entries()}},vt=class extends _t{#e=gt;constructor(e){super();let{serializable:t}=e;if(t===gt)return;let{map:n,hash:r,transfer:i}=t,a=structuredClone(n,i?{transfer:i}:null);this.#e={map:a,hash:r,transfer:[]}}get print(){k(`Should not call PrintAnnotationStorage.print`)}get serializable(){return this.#e}get modifiedIds(){return F(this,`modifiedIds`,{ids:new Set,hash:``})}};r(7588);var yt=`__forcedDependency`,{floor:bt,ceil:xt}=Math;function St(e,t,n,r,i,a){e[t*4+0]=Math.min(e[t*4+0],n),e[t*4+1]=Math.min(e[t*4+1],r),e[t*4+2]=Math.max(e[t*4+2],i),e[t*4+3]=Math.max(e[t*4+3],a)}function Ct(e,t,n,r,i){let a;e?(e<0&&(a=i[0],i[0]=i[2],i[2]=a),i[0]*=e,i[2]*=e,t<0&&(a=i[1],i[1]=i[3],i[3]=a),i[1]*=t,i[3]*=t):i.fill(0),i[0]+=n,i[1]+=r,i[2]+=n,i[3]+=r}var wt=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0],Tt=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get length(){return this.#e.length}isEmpty(e){return this.#e[e]===wt}minX(e){return this.#t[e*4+0]/256}minY(e){return this.#t[e*4+1]/256}maxX(e){return(this.#t[e*4+2]+1)/256}maxY(e){return(this.#t[e*4+3]+1)/256}},Et=(e,t)=>e?.getOrInsertComputed(t,()=>({dependencies:new Set,isRenderingOperation:!1})),Dt=class{#e=[[1,0,0,1,0,0]];#t=[-1/0,-1/0,1/0,1/0];#n=new Float64Array(a);_pendingBBoxIdx=-1;#r;#i;#a;#o;_savesStack=[];_markedContentStack=[];constructor(e,t){this.#r=e.width,this.#i=e.height,this.#s(t)}growOperationsCount(e){e>=this.#o.length&&this.#s(e,this.#o)}#s(e,t){let n=new ArrayBuffer(e*4);this.#a=new Uint8ClampedArray(n),this.#o=new Uint32Array(n),t&&t.length>0?(this.#o.set(t),this.#o.fill(wt,t.length)):this.#o.fill(wt)}get clipBox(){return this.#t}save(e){return this.#t={__proto__:this.#t},this._savesStack.push(e),this}restore(e,t){let n=Object.getPrototypeOf(this.#t);if(n===null)return this;this.#t=n;let r=this._savesStack.pop();return r!==void 0&&(t?.(r,e),this.#o[e]=this.#o[r]),this}recordOpenMarker(e){return this._savesStack.push(e),this}getOpenMarker(){return this._savesStack.length===0?null:this._savesStack.at(-1)}recordCloseMarker(e,t){let n=this._savesStack.pop();return n!==void 0&&(t?.(n,e),this.#o[e]=this.#o[n]),this}beginMarkedContent(e){return this._markedContentStack.push(e),this}endMarkedContent(e,t){let n=this._markedContentStack.pop();return n!==void 0&&(t?.(n,e),this.#o[e]=this.#o[n]),this}pushBaseTransform(e){return this.#e.push(V.multiplyByDOMMatrix(this.#e.at(-1),e.getTransform())),this}popBaseTransform(){return this.#e.length>1&&this.#e.pop(),this}resetBBox(e){return this._pendingBBoxIdx!==e&&(this._pendingBBoxIdx=e,this.#n.set(a,0)),this}recordClipBox(e,t,n,r,i,o){let s=V.multiplyByDOMMatrix(this.#e.at(-1),t.getTransform()),c=a.slice();V.axialAlignedBoundingBox([n,i,r,o],s,c);let l=V.intersect(this.#t,c);return l?(this.#t[0]=l[0],this.#t[1]=l[1],this.#t[2]=l[2],this.#t[3]=l[3]):(this.#t[0]=this.#t[1]=1/0,this.#t[2]=this.#t[3]=-1/0),this}recordBBox(e,t,n,r,i,o){let s=this.#t;if(s[0]===1/0)return this;let c=V.multiplyByDOMMatrix(this.#e.at(-1),t.getTransform());if(s[0]===-1/0)return V.axialAlignedBoundingBox([n,i,r,o],c,this.#n),this;let l=a.slice();return V.axialAlignedBoundingBox([n,i,r,o],c,l),this.#n[0]=H(l[0],s[0],this.#n[0]),this.#n[1]=H(l[1],s[1],this.#n[1]),this.#n[2]=H(l[2],this.#n[2],s[2]),this.#n[3]=H(l[3],this.#n[3],s[3]),this}recordFullPageBBox(e){return this.#n[0]=Math.max(0,this.#t[0]),this.#n[1]=Math.max(0,this.#t[1]),this.#n[2]=Math.min(this.#r,this.#t[2]),this.#n[3]=Math.min(this.#i,this.#t[3]),this}recordOperation(e,t=!1,n){if(this._pendingBBoxIdx!==e)return this;let r=bt(this.#n[0]*256/this.#r),i=bt(this.#n[1]*256/this.#i),a=xt(this.#n[2]*256/this.#r),o=xt(this.#n[3]*256/this.#i);if(St(this.#a,e,r,i,a,o),n)for(let t of n)for(let n of t)n!==e&&St(this.#a,n,r,i,a,o);return t||(this._pendingBBoxIdx=-1),this}bboxToClipBoxDropOperation(e){return this._pendingBBoxIdx===e&&(this._pendingBBoxIdx=-1,this.#t[0]=Math.max(this.#t[0],this.#n[0]),this.#t[1]=Math.max(this.#t[1],this.#n[1]),this.#t[2]=Math.min(this.#t[2],this.#n[2]),this.#t[3]=Math.min(this.#t[3],this.#n[3])),this}take(){return new Tt(this.#o,this.#a)}takeDebugMetadata(){throw Error(`Unreachable`)}recordSimpleData(e,t){return this}recordIncrementalData(e,t){return this}resetIncrementalData(e,t){return this}recordNamedData(e,t){return this}recordSimpleDataFromNamed(e,t,n){return this}recordFutureForcedDependency(e,t){return this}inheritSimpleDataAsFutureForcedDependencies(e){return this}inheritPendingDependenciesAsFutureForcedDependencies(){return this}recordCharacterBBox(e,t,n,r=1,i=0,a=0,o){return this}getSimpleIndex(e){}recordDependencies(e,t){return this}recordNamedDependency(e,t){return this}recordShowTextOperation(e,t=!1){return this}},Ot=class{#e={__proto__:null};#t={__proto__:null,transform:[],moveText:[],sameLineText:[],[yt]:[]};#n=new Map;#r=new Set;#i=new Map;#a;#o;#s;constructor(e,t=!1){this.#s=e,t&&(this.#a=new Map,this.#o=(e,t)=>{Et(this.#a,t).dependencies.add(e)})}get clipBox(){return this.#s.clipBox}growOperationsCount(e){this.#s.growOperationsCount(e)}save(e){return this.#e={__proto__:this.#e},this.#t={__proto__:this.#t,transform:{__proto__:this.#t.transform},moveText:{__proto__:this.#t.moveText},sameLineText:{__proto__:this.#t.sameLineText},[yt]:{__proto__:this.#t[yt]}},this.#s.save(e),this}restore(e){this.#s.restore(e,this.#o);let t=Object.getPrototypeOf(this.#e);return t===null?this:(this.#e=t,this.#t=Object.getPrototypeOf(this.#t),this)}recordOpenMarker(e){return this.#s.recordOpenMarker(e,this.#o),this}getOpenMarker(){return this.#s.getOpenMarker()}recordCloseMarker(e){return this.#s.recordCloseMarker(e,this.#o),this}beginMarkedContent(e){return this.#s.beginMarkedContent(e),this}endMarkedContent(e){return this.#s.endMarkedContent(e,this.#o),this}pushBaseTransform(e){return this.#s.pushBaseTransform(e),this}popBaseTransform(){return this.#s.popBaseTransform(),this}recordSimpleData(e,t){return this.#e[e]=t,this}recordIncrementalData(e,t){return this.#t[e].push(t),this}resetIncrementalData(e,t){return this.#t[e].length=0,this}recordNamedData(e,t){return this.#n.set(e,t),this}recordSimpleDataFromNamed(e,t,n){this.#e[e]=this.#n.get(t)??n}recordFutureForcedDependency(e,t){return this.recordIncrementalData(yt,t),this}inheritSimpleDataAsFutureForcedDependencies(e){for(let t of e)t in this.#e&&this.recordFutureForcedDependency(t,this.#e[t]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(let e of this.#r)this.recordFutureForcedDependency(yt,e);return this}resetBBox(e){return this.#s.resetBBox(e),this}recordClipBox(e,t,n,r,i,a){return this.#s.recordClipBox(e,t,n,r,i,a),this}recordBBox(e,t,n,r,i,a){return this.#s.recordBBox(e,t,n,r,i,a),this}recordCharacterBBox(e,t,n,r=1,i=0,a=0,o){let s=n.bbox,c,l;if(s&&(c=s[2]!==s[0]&&s[3]!==s[1]&&this.#i.get(n),c!==!1&&(l=[0,0,0,0],V.axialAlignedBoundingBox(s,n.fontMatrix,l),(r!==1||i!==0||a!==0)&&Ct(r,-r,i,a,l),c)))return this.recordBBox(e,t,l[0],l[2],l[1],l[3]);if(!o)return this.recordFullPageBBox(e);let u=o();return s&&l&&c===void 0&&(c=l[0]<=i-u.actualBoundingBoxLeft&&l[2]>=i+u.actualBoundingBoxRight&&l[1]<=a-u.actualBoundingBoxAscent&&l[3]>=a+u.actualBoundingBoxDescent,this.#i.set(n,c),c)?this.recordBBox(e,t,l[0],l[2],l[1],l[3]):this.recordBBox(e,t,i-u.actualBoundingBoxLeft,i+u.actualBoundingBoxRight,a-u.actualBoundingBoxAscent,a+u.actualBoundingBoxDescent)}recordFullPageBBox(e){return this.#s.recordFullPageBBox(e),this}getSimpleIndex(e){return this.#e[e]}recordDependencies(e,t){let n=this.#r,r=this.#e,i=this.#t;for(let e of t)e in this.#e?n.add(r[e]):e in i&&i[e].forEach(n.add,n);return this}recordNamedDependency(e,t){return this.#n.has(t)&&this.#r.add(this.#n.get(t)),this}recordOperation(e,t=!1){if(this.recordDependencies(e,[yt]),this.#a){let t=Et(this.#a,e),{dependencies:n}=t;this.#r.forEach(n.add,n),this.#s._savesStack.forEach(n.add,n),this.#s._markedContentStack.forEach(n.add,n),n.delete(e),t.isRenderingOperation=!0}let n=!t&&e===this.#s._pendingBBoxIdx;return this.#s.recordOperation(e,t,[this.#r,this.#s._savesStack,this.#s._markedContentStack]),n&&this.#r.clear(),this}recordShowTextOperation(e,t=!1){let n=Array.from(this.#r);this.recordOperation(e,t),this.recordIncrementalData(`sameLineText`,e);for(let e of n)this.recordIncrementalData(`sameLineText`,e);return this}bboxToClipBoxDropOperation(e,t=!1){let n=!t&&e===this.#s._pendingBBoxIdx;return this.#s.bboxToClipBoxDropOperation(e),n&&this.#r.clear(),this}take(){return this.#i.clear(),this.#s.take()}takeDebugMetadata(){return this.#a}},kt=class e{#e;#t;#n;#r=0;#i=0;constructor(t,n,r){if(t instanceof e&&t.#n===!!r)return t;this.#e=t,this.#t=n,this.#n=!!r}get clipBox(){return this.#e.clipBox}growOperationsCount(){throw Error(`Unreachable`)}save(e){return this.#i++,this.#e.save(this.#t),this}restore(e){return this.#i>0&&(this.#e.restore(this.#t),this.#i--),this}recordOpenMarker(e){return this.#r++,this}getOpenMarker(){return this.#r>0?this.#t:this.#e.getOpenMarker()}recordCloseMarker(e){return this.#r--,this}beginMarkedContent(e){return this}endMarkedContent(e){return this}pushBaseTransform(e){return this.#e.pushBaseTransform(e),this}popBaseTransform(){return this.#e.popBaseTransform(),this}recordSimpleData(e,t){return this.#e.recordSimpleData(e,this.#t),this}recordIncrementalData(e,t){return this.#e.recordIncrementalData(e,this.#t),this}resetIncrementalData(e,t){return this.#e.resetIncrementalData(e,this.#t),this}recordNamedData(e,t){return this}recordSimpleDataFromNamed(e,t,n){return this.#e.recordSimpleDataFromNamed(e,t,this.#t),this}recordFutureForcedDependency(e,t){return this.#e.recordFutureForcedDependency(e,this.#t),this}inheritSimpleDataAsFutureForcedDependencies(e){return this.#e.inheritSimpleDataAsFutureForcedDependencies(e),this}inheritPendingDependenciesAsFutureForcedDependencies(){return this.#e.inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(e){return this.#n||this.#e.resetBBox(this.#t),this}recordClipBox(e,t,n,r,i,a){return this.#n||this.#e.recordClipBox(this.#t,t,n,r,i,a),this}recordBBox(e,t,n,r,i,a){return this.#n||this.#e.recordBBox(this.#t,t,n,r,i,a),this}recordCharacterBBox(e,t,n,r,i,a,o){return this.#n||this.#e.recordCharacterBBox(this.#t,t,n,r,i,a,o),this}recordFullPageBBox(e){return this.#n||this.#e.recordFullPageBBox(this.#t),this}getSimpleIndex(e){return this.#e.getSimpleIndex(e)}recordDependencies(e,t){return this.#e.recordDependencies(this.#t,t),this}recordNamedDependency(e,t){return this.#e.recordNamedDependency(this.#t,t),this}recordOperation(e){return this.#e.recordOperation(this.#t,!0),this}recordShowTextOperation(e){return this.#e.recordShowTextOperation(this.#t,!0),this}bboxToClipBoxDropOperation(e){return this.#n||this.#e.bboxToClipBoxDropOperation(this.#t,!0),this}take(){throw Error(`Unreachable`)}takeDebugMetadata(){throw Error(`Unreachable`)}},At={stroke:[`path`,`transform`,`filter`,`strokeColor`,`strokeAlpha`,`lineWidth`,`lineCap`,`lineJoin`,`miterLimit`,`dash`],fill:[`path`,`transform`,`filter`,`fillColor`,`fillAlpha`,`globalCompositeOperation`,`SMask`],imageXObject:[`transform`,`SMask`,`filter`,`fillAlpha`,`strokeAlpha`,`globalCompositeOperation`],rawFillPath:[`filter`,`fillColor`,`fillAlpha`],showText:[`transform`,`leading`,`charSpacing`,`wordSpacing`,`hScale`,`textRise`,`moveText`,`textMatrix`,`font`,`fontObj`,`filter`,`fillColor`,`textRenderingMode`,`SMask`,`fillAlpha`,`strokeAlpha`,`globalCompositeOperation`,`sameLineText`],transform:[`transform`],transformAndFill:[`transform`,`fillColor`]},jt=class e{#e;#t;#n=4;#r=0;#i=new e.#a(this.#n*6);static#a=B.isFloat16ArraySupported?Float16Array:Float32Array;constructor(e){this.#e=e.width,this.#t=e.height}record(t,n,r,i){if(this.#r===this.#n){this.#n*=2;let t=new e.#a(this.#n*6);t.set(this.#i),this.#i=t}let o=W(t),s;if(i[0]!==1/0){let e=a.slice();V.axialAlignedBoundingBox([0,-r,n,0],o,e);let t=V.intersect(i,e);if(!t)return;let[c,l,u,d]=t;if(c!==e[0]||l!==e[1]||u!==e[2]||d!==e[3]){let e=Math.atan2(o[1],o[0]),t=Math.abs(Math.sin(e)),n=Math.abs(Math.cos(e));if(t<1e-6||n<1e-6||Math.abs(t-n)<1e-6)s=[c,l,c,d,u,l];else{let e=u-c,r=d-l,i=t*t,a=n*n,o=n*t,f=a-i,p=(r*a-e*o)/f;s=[c+(r*o-e*i)/f,l,c,l+p,u,d-p]}}}s||(s=[0,-r,0,0,n,-r],V.applyTransform(s,o,0),V.applyTransform(s,o,2),V.applyTransform(s,o,4)),s[0]/=this.#e,s[1]/=this.#t,s[2]/=this.#e,s[3]/=this.#t,s[4]/=this.#e,s[5]/=this.#t,this.#i.set(s,this.#r*6),this.#r++}take(){return this.#i.subarray(0,this.#r*6)}},Mt=/\p{Cc}/u;function Nt(e){let t=e[0];if(e.length<2||t!==`"`&&t!==`'`||e.at(-1)!==t)return!1;let n=e.length-1;for(let r=1;r<n;r++){let i=e[r];if(i===t||Mt.test(i)||i===`\\`&&(++r>=n||Mt.test(e[r])))return!1}return!0}function Pt(e){return Nt(e)?e:`"${e.replaceAll(/["\\\p{Cc}]/gu,e=>e===`"`||e===`\\`?`\\${e}`:`\\${e.codePointAt(0).toString(16)} `)}"`}var Ft=class{#e=new Set;#t=null;constructor({ownerDocument:e=globalThis.document,styleElement:t=null}){this._document=e,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(e){this.nativeFontFaces.add(e),this._document.fonts.add(e)}removeNativeFontFace(e){this.nativeFontFaces.delete(e),this._document.fonts.delete(e)}insertRule(e){let t=this.#n();t.insertRule(e,t.cssRules.length)}#n(){if(this.#t)return this.#t;let e=this._document.defaultView?.CSSStyleSheet||globalThis.CSSStyleSheet;if(!this.styleElement&&e){let{adoptedStyleSheets:t}=this._document;if(t){let n=new e;return t.push(n),this.#t=n}}return this.styleElement||(this.styleElement=this._document.createElement(`style`),this._document.documentElement.getElementsByTagName(`head`)[0].append(this.styleElement)),this.#t=this.styleElement.sheet}clear(){for(let e of this.nativeFontFaces)this._document.fonts.delete(e);if(this.nativeFontFaces.clear(),this.#e.clear(),this.#t){let{adoptedStyleSheets:e}=this._document;e?.includes(this.#t)&&(this._document.adoptedStyleSheets=e.filter(e=>e!==this.#t)),this.#t=null}this.styleElement&&=(this.styleElement.remove(),null)}async loadSystemFont({systemFontInfo:e,disableFontFace:t,_inspectFont:n}){if(e&&!this.#e.has(e.loadedName)){if(A(!t,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){let{loadedName:t,src:r,style:i}=e,a=new FontFace(t,r,i);this.addNativeFontFace(a);try{await a.load(),this.#e.add(t),n?.(e)}catch{O(`Cannot load system font: ${e.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(a)}return}k(`Not implemented: loadSystemFont without the Font Loading API.`)}}async bind(e){if(e.attached||e.missingFile&&!e.systemFontInfo)return;if(e.attached=!0,e.systemFontInfo){await this.loadSystemFont(e);return}if(this.isFontLoadingAPISupported){let t=e.createNativeFontFace();if(t){this.addNativeFontFace(t);try{await t.loaded}catch(n){throw O(`Failed to load font '${t.family}': '${n}'.`),e.disableFontFace=!0,n}}return}let t=e.createFontFaceRule();if(t){if(this.insertRule(t),this.isSyncFontLoadingSupported)return;await new Promise(t=>{let n=this._queueLoadingCallback(t);this._prepareFontLoadEvent(e,n)})}}get isFontLoadingAPISupported(){let e=!!this._document?.fonts;return F(this,`isFontLoadingAPISupported`,e)}get isSyncFontLoadingSupported(){return F(this,`isSyncFontLoadingSupported`,i||B.platform.isFirefox)}_queueLoadingCallback(e){function t(){for(A(!r.done,`completeRequest() cannot be called twice.`),r.done=!0;n.length>0&&n[0].done;){let e=n.shift();setTimeout(e.callback,0)}}let{loadingRequests:n}=this,r={done:!1,complete:t,callback:e};return n.push(r),r}get _loadTestFont(){let e=atob(`T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==`);return F(this,`_loadTestFont`,e)}_prepareFontLoadEvent(e,t){function n(e,t){return e.charCodeAt(t)<<24|e.charCodeAt(t+1)<<16|e.charCodeAt(t+2)<<8|e.charCodeAt(t+3)&255}function r(e){return String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,e&255)}function i(e,t,n,r){let i=e.substring(0,t),a=e.substring(t+n);return i+r+a}let a,o,s=this._document.createElement(`canvas`);s.width=1,s.height=1;let c=s.getContext(`2d`),l=0;function u(e,t){if(++l>30){O(`Load test font never loaded.`),t();return}if(c.font=`30px `+e,c.fillText(`.`,0,20),c.getImageData(0,0,1,1).data[3]>0){t();return}setTimeout(u.bind(null,e,t))}let d=`lt${Date.now()}${this.loadTestFontId++}`,f=this._loadTestFont;f=i(f,976,d.length,d);let p=1482184792,m=n(f,16);for(a=0,o=d.length-3;a<o;a+=4)m=m-p+n(d,a)|0;a<d.length&&(m=m-p+n(d+`XXX`,a)|0),f=i(f,16,4,r(m));let h=`@font-face {font-family:"${d}";src:${`url(data:font/opentype;base64,${btoa(f)});`}}`;this.insertRule(h);let g=this._document.createElement(`div`);g.style.visibility=`hidden`,g.style.width=g.style.height=`10px`,g.style.position=`absolute`,g.style.top=g.style.left=`0px`;for(let t of[e.loadedName,d]){let e=this._document.createElement(`span`);e.textContent=`Hi`,e.style.fontFamily=t,g.append(e)}this._document.body.append(g),u(d,()=>{g.remove(),t.complete()})}},It=class{compiledGlyphs=Object.create(null);#e;constructor(e,t=null,n,r){this.#e=e,this._inspectFont=t,n&&(this.charProcOperatorList=n),r&&Object.assign(this,r)}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let e;if(!this.cssFontInfo)e=new FontFace(this.loadedName,this.data,{});else{let t={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(t.style=`oblique ${this.cssFontInfo.italicAngle}deg`),e=new FontFace(Pt(this.cssFontInfo.fontFamily),this.data,t)}return this._inspectFont?.(this),e}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;let e=`url(data:${this.mimetype};base64,${this.data.toBase64()});`,t;if(!this.cssFontInfo)t=`@font-face {font-family:"${this.loadedName}";src:${e}}`;else{let n=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(n+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),t=`@font-face {font-family:${Pt(this.cssFontInfo.fontFamily)};${n}src:${e}}`}return this._inspectFont?.(this,e),t}getPathGenerator(e,t){if(this.compiledGlyphs[t]!==void 0)return this.compiledGlyphs[t];let n=this.loadedName+`_path_`+t,r;try{r=e.get(n)}catch(e){O(`getPathGenerator - ignoring character: "${e}".`)}let i=Je(r?.path);return this.fontExtraProperties||e.delete(n),this.compiledGlyphs[t]=i}get black(){return this.#e.black}get bold(){return this.#e.bold}get disableFontFace(){return this.#e.disableFontFace}set disableFontFace(e){F(this,`disableFontFace`,!!e)}get fontExtraProperties(){return this.#e.fontExtraProperties}get isInvalidPDFjsFont(){return this.#e.isInvalidPDFjsFont}get isType3Font(){return this.#e.isType3Font}get italic(){return this.#e.italic}get missingFile(){return this.#e.missingFile}get remeasure(){return this.#e.remeasure}get vertical(){return this.#e.vertical}get ascent(){return this.#e.ascent}get defaultWidth(){return this.#e.defaultWidth}get descent(){return this.#e.descent}get bbox(){return this.#e.bbox}get fontMatrix(){return this.#e.fontMatrix}get fallbackName(){return this.#e.fallbackName}get loadedName(){return this.#e.loadedName}get mimetype(){return this.#e.mimetype}get name(){return this.#e.name}get data(){return this.#e.data}clearData(){this.#e.clearData()}get cssFontInfo(){return this.#e.cssFontInfo}get systemFontInfo(){return this.#e.systemFontInfo}get defaultVMetrics(){return this.#e.defaultVMetrics}},Lt=class{static strings=[`fontFamily`,`fontWeight`,`italicAngle`]},Rt=class{static strings=[`css`,`loadedName`,`baseFontName`,`src`]},zt=class{static bools=[`black`,`bold`,`disableFontFace`,`fontExtraProperties`,`isInvalidPDFjsFont`,`isType3Font`,`italic`,`missingFile`,`remeasure`,`vertical`];static numbers=[`ascent`,`defaultWidth`,`descent`];static strings=[`fallbackName`,`loadedName`,`mimetype`,`name`];static OFFSET_NUMBERS=Math.ceil(this.bools.length*2/8);static OFFSET_BBOX=this.OFFSET_NUMBERS+this.numbers.length*8;static OFFSET_FONT_MATRIX=this.OFFSET_BBOX+1+8;static OFFSET_DEFAULT_VMETRICS=this.OFFSET_FONT_MATRIX+1+48;static OFFSET_STRINGS=this.OFFSET_DEFAULT_VMETRICS+1+6},Bt=class{static KIND=0;static HAS_BBOX=1;static HAS_BACKGROUND=2;static SHADING_TYPE=3;static N_COORD=4;static N_COLOR=8;static N_STOP=12;static N_FIGURES=16},Vt=class{static get decoder(){return F(this,`decoder`,new TextDecoder)}static get encoder(){return F(this,`encoder`,new TextEncoder)}},Ht=class{#e;#t;constructor(e){this.#e=e,this.#t=new DataView(e)}#n(e){A(e<Lt.strings.length,`Invalid string index`);let{decoder:t}=Vt,n=0;for(let t=0;t<e;t++)n+=this.#t.getUint32(n)+4;let r=this.#t.getUint32(n);return t.decode(new Uint8Array(this.#e,n+4,r))}get fontFamily(){return this.#n(0)}get fontWeight(){return this.#n(1)}get italicAngle(){return this.#n(2)}},Ut=class{#e;#t;constructor(e){this.#e=e,this.#t=new DataView(e)}get guessFallback(){return this.#t.getUint8(0)!==0}#n(e){A(e<Rt.strings.length,`Invalid string index`);let{decoder:t}=Vt,n=5;for(let t=0;t<e;t++)n+=this.#t.getUint32(n)+4;let r=this.#t.getUint32(n);return t.decode(new Uint8Array(this.#e,n+4,r))}get css(){return this.#n(0)}get loadedName(){return this.#n(1)}get baseFontName(){return this.#n(2)}get src(){return this.#n(3)}get style(){let{decoder:e}=Vt,t=1;t+=4+this.#t.getUint32(t);let n=this.#t.getUint32(t),r=e.decode(new Uint8Array(this.#e,t+4,n));t+=4+n;let i=this.#t.getUint32(t);return{style:r,weight:e.decode(new Uint8Array(this.#e,t+4,i))}}},Wt=class{#e;#t;constructor({buffer:e,extra:t}){this.#e=e,this.#t=new DataView(e),t&&Object.assign(this,t)}#n(e){A(e<zt.bools.length,`Invalid boolean index`);let t=Math.floor(e/4),n=e*2%8,r=this.#t.getUint8(t)>>n&3;return r===0?void 0:r===2}get black(){return this.#n(0)}get bold(){return this.#n(1)}get disableFontFace(){return this.#n(2)}get fontExtraProperties(){return this.#n(3)}get isInvalidPDFjsFont(){return this.#n(4)}get isType3Font(){return this.#n(5)}get italic(){return this.#n(6)}get missingFile(){return this.#n(7)}get remeasure(){return this.#n(8)}get vertical(){return this.#n(9)}#r(e){return A(e<zt.numbers.length,`Invalid number index`),this.#t.getFloat64(zt.OFFSET_NUMBERS+e*8)}get ascent(){return this.#r(0)}get defaultWidth(){return this.#r(1)}get descent(){return this.#r(2)}#i(e,t,n,r){let i=this.#t.getUint8(e);if(i===0)return;A(i===t,`Invalid array length.`),e+=1;let a=Array(i);for(let t=0;t<i;t++)a[t]=this.#t[n](e,!0),e+=r;return a}get bbox(){return this.#i(zt.OFFSET_BBOX,4,`getInt16`,2)}get fontMatrix(){return this.#i(zt.OFFSET_FONT_MATRIX,6,`getFloat64`,8)}get defaultVMetrics(){return this.#i(zt.OFFSET_DEFAULT_VMETRICS,3,`getInt16`,2)}#a(e){A(e<zt.strings.length,`Invalid string index`);let{decoder:t}=Vt,n=zt.OFFSET_STRINGS+4;for(let t=0;t<e;t++)n+=this.#t.getUint32(n)+4;let r=this.#t.getUint32(n);return t.decode(new Uint8Array(this.#e,n+4,r))}get fallbackName(){return this.#a(0)}get loadedName(){return this.#a(1)}get mimetype(){return this.#a(2)}get name(){return this.#a(3)}#o(){let e=zt.OFFSET_STRINGS,t=this.#t.getUint32(e);e+=4+t;let n=this.#t.getUint32(e);e+=4+n;let r=this.#t.getUint32(e);e+=4+r;let i=this.#t.getUint32(e);return{offset:e,length:i}}get data(){let{offset:e,length:t}=this.#o();return t===0?void 0:new Uint8Array(this.#e,e+4,t)}clearData(){let{offset:e,length:t}=this.#o();t!==0&&(this.#t.setUint32(e,0),this.#e=new Uint8Array(this.#e,0,e+4).slice().buffer,this.#t=new DataView(this.#e))}get cssFontInfo(){let e=zt.OFFSET_STRINGS,t=this.#t.getUint32(e);e+=4+t;let n=this.#t.getUint32(e);e+=4+n;let r=this.#t.getUint32(e);if(r===0)return null;let i=new Uint8Array(r);return i.set(new Uint8Array(this.#e,e+4,r)),new Ht(i.buffer)}get systemFontInfo(){let e=zt.OFFSET_STRINGS,t=this.#t.getUint32(e);e+=4+t;let n=this.#t.getUint32(e);if(n===0)return null;let r=new Uint8Array(n);return r.set(new Uint8Array(this.#e,e+4,n)),new Ut(r.buffer)}},Gt=class{constructor(e){this.buffer=e,this.view=new DataView(e),this.data=new Uint8Array(e)}getIR(){let e=this.view,t=this.data[Bt.KIND],n=!!this.data[Bt.HAS_BBOX],r=!!this.data[Bt.HAS_BACKGROUND],i=e.getUint32(Bt.N_COORD,!0),o=e.getUint32(Bt.N_COLOR,!0),s=e.getUint32(Bt.N_STOP,!0),c=20,l=new Float32Array(this.buffer,c,i*2);c+=i*8;let u=new Uint8Array(this.buffer,c,o*4);c+=o*4;let d=[];for(let t=0;t<s;++t){let t=e.getFloat32(c,!0);c+=4;let n=e.getUint32(c,!0);c+=4,d.push([t,`#${n.toString(16).padStart(6,`0`)}`])}let f=null;if(n){f=[];for(let t=0;t<4;++t)f.push(e.getFloat32(c,!0)),c+=4}let p=null;if(r&&(p=new Uint8Array(this.buffer,c,3),c+=3),t===1)return[`RadialAxial`,`axial`,f,d,Array.from(l.slice(0,2)),Array.from(l.slice(2,4)),null,null];if(t===2)return[`RadialAxial`,`radial`,f,d,[l[0],l[1]],[l[3],l[4]],l[2],l[5]];if(t===3){let e=this.data[Bt.SHADING_TYPE],t=null;if(l.length>0){t=a.slice();for(let e=0,n=l.length;e<n;e+=2)V.pointBoundingBox(l[e],l[e+1],t)}return[`Mesh`,e,l,u,i,t,f,p]}throw Error(`Unsupported pattern kind: ${t}`)}},Kt=class{#e;constructor(e){this.#e=e}get path(){return B.isFloat16ArraySupported?new Float16Array(this.#e):new Float32Array(this.#e)}};function qt(e){if(e instanceof URL)return e;if(typeof e==`string`){if(i){if(/^[a-z][a-z0-9\-+.]+:/i.test(e))return new URL(e);let t=process.getBuiltinModule(`url`);return new URL(t.pathToFileURL(e))}let t=URL.parse(e,window.location);if(t)return t}throw Error(`Invalid PDF url data: either string or URL-object is expected in the url property.`)}function Jt(e){if(i&&typeof Buffer<`u`&&e instanceof Buffer)throw Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength)return e;if(typeof e==`string`)return ie(e);if(e instanceof ArrayBuffer||ArrayBuffer.isView(e)||typeof e==`object`&&!isNaN(e?.length))return new Uint8Array(e);throw Error(`Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.`)}function Yt(e){if(typeof e!=`string`)return null;if(e.endsWith(`/`))return e;throw Error(`Invalid factory url: "${e}" must include trailing slash.`)}var Xt=e=>typeof e==`object`&&Number.isInteger(e?.num)&&e.num>=0&&Number.isInteger(e?.gen)&&e.gen>=0,Zt=ue.bind(null,Xt,e=>typeof e==`object`&&typeof e?.name==`string`),Qt=class{#e=new Map;#t=Promise.resolve();postMessage(e,t){let n={data:structuredClone(e,t?{transfer:t}:null)};this.#t.then(()=>{for(let[e]of this.#e)e.call(this,n)})}addEventListener(e,t,n=null){let r=null;if(n?.signal instanceof AbortSignal){let{signal:i}=n;if(i.aborted){O("LoopbackPort - cannot use an `aborted` signal.");return}let a=()=>this.removeEventListener(e,t);r=()=>i.removeEventListener(`abort`,a),i.addEventListener(`abort`,a)}this.#e.set(t,r)}removeEventListener(e,t){this.#e.get(t)?.(),this.#e.delete(t)}terminate(){for(let[,e]of this.#e)e?.();this.#e.clear()}};r(1689);var $t={DATA:1,ERROR:2},q={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function en(){}function J(e){if(e instanceof z||e instanceof ee||e instanceof L||e instanceof te||e instanceof R)return e;switch(e instanceof Error||typeof e==`object`&&e||k(`wrapReason: Expected "reason" to be a (possibly cloned) Error.`),e.name){case`AbortException`:return new z(e.message);case`InvalidPDFException`:return new ee(e.message);case`PasswordException`:return new L(e.message,e.code);case`ResponseException`:return new te(e.message,e.status,e.missing);case`UnknownErrorException`:return new R(e.message,e.details)}return new R(e.message,e.toString())}var tn=class{#e=new AbortController;constructor(e,t,n){this.sourceName=e,this.targetName=t,this.comObj=n,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),n.addEventListener(`message`,this.#t.bind(this),{signal:this.#e.signal})}#t({data:e}){if(e.targetName!==this.sourceName)return;if(e.stream){this.#r(e);return}if(e.callback){let t=e.callbackId,n=this.callbackCapabilities[t];if(!n)throw Error(`Cannot resolve callback ${t}`);if(delete this.callbackCapabilities[t],e.callback===$t.DATA)n.resolve(e.data);else if(e.callback===$t.ERROR)n.reject(J(e.reason));else throw Error(`Unexpected callback case`);return}let t=this.actionHandler[e.action];if(!t)throw Error(`Unknown action from worker: ${e.action}`);if(e.callbackId){let n=this.sourceName,r=e.sourceName,i=this.comObj;Promise.try(t,e.data).then(function(t){i.postMessage({sourceName:n,targetName:r,callback:$t.DATA,callbackId:e.callbackId,data:t})},function(t){i.postMessage({sourceName:n,targetName:r,callback:$t.ERROR,callbackId:e.callbackId,reason:J(t)})});return}if(e.streamId){this.#n(e);return}t(e.data)}on(e,t){let n=this.actionHandler;if(n[e])throw Error(`There is already an actionName called "${e}"`);n[e]=t}send(e,t,n){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,data:t},n)}sendWithPromise(e,t,n){let r=this.callbackId++,i=Promise.withResolvers();this.callbackCapabilities[r]=i;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,callbackId:r,data:t},n)}catch(e){i.reject(e)}return i.promise}sendWithStream(e,t,n,r){let i=this.streamId++,a=this.sourceName,o=this.targetName,s=this.comObj;return new ReadableStream({start:n=>{let c=Promise.withResolvers();return this.streamControllers[i]={controller:n,startCall:c,pullCall:null,cancelCall:null,isClosed:!1},s.postMessage({sourceName:a,targetName:o,action:e,streamId:i,data:t,desiredSize:n.desiredSize},r),c.promise},pull:e=>{let t=Promise.withResolvers();return this.streamControllers[i].pullCall=t,s.postMessage({sourceName:a,targetName:o,stream:q.PULL,streamId:i,desiredSize:e.desiredSize}),t.promise},cancel:e=>{A(e instanceof Error,`cancel must have a valid reason`);let t=Promise.withResolvers();return this.streamControllers[i].cancelCall=t,this.streamControllers[i].isClosed=!0,s.postMessage({sourceName:a,targetName:o,stream:q.CANCEL,streamId:i,reason:J(e)}),t.promise}},n)}#n(e){let t=e.streamId,n=this.sourceName,r=e.sourceName,i=this.comObj,a=this,o=this.actionHandler[e.action],s={enqueue(e,a=1,o){if(this.isCancelled)return;let s=this.desiredSize;this.desiredSize-=a,s>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),i.postMessage({sourceName:n,targetName:r,stream:q.ENQUEUE,streamId:t,chunk:e},o)},close(){this.isCancelled||(this.isCancelled=!0,i.postMessage({sourceName:n,targetName:r,stream:q.CLOSE,streamId:t}),delete a.streamSinks[t])},error(e){A(e instanceof Error,`error must have a valid reason`),!this.isCancelled&&(this.isCancelled=!0,i.postMessage({sourceName:n,targetName:r,stream:q.ERROR,streamId:t,reason:J(e)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:e.desiredSize,ready:null};s.sinkCapability.resolve(),s.ready=s.sinkCapability.promise,this.streamSinks[t]=s,Promise.try(o,e.data,s).then(function(){i.postMessage({sourceName:n,targetName:r,stream:q.START_COMPLETE,streamId:t,success:!0})},function(e){i.postMessage({sourceName:n,targetName:r,stream:q.START_COMPLETE,streamId:t,reason:J(e)})})}#r(e){let t=e.streamId,n=this.sourceName,r=e.sourceName,i=this.comObj,a=this.streamControllers[t],o=this.streamSinks[t];switch(e.stream){case q.START_COMPLETE:e.success?a.startCall.resolve():a.startCall.reject(J(e.reason));break;case q.PULL_COMPLETE:e.success?a.pullCall.resolve():a.pullCall.reject(J(e.reason));break;case q.PULL:if(!o){i.postMessage({sourceName:n,targetName:r,stream:q.PULL_COMPLETE,streamId:t,success:!0});break}o.desiredSize<=0&&e.desiredSize>0&&o.sinkCapability.resolve(),o.desiredSize=e.desiredSize,Promise.try(o.onPull||en).then(function(){i.postMessage({sourceName:n,targetName:r,stream:q.PULL_COMPLETE,streamId:t,success:!0})},function(e){i.postMessage({sourceName:n,targetName:r,stream:q.PULL_COMPLETE,streamId:t,reason:J(e)})});break;case q.ENQUEUE:if(A(a,`enqueue should have stream controller`),a.isClosed)break;a.controller.enqueue(e.chunk);break;case q.CLOSE:if(A(a,`close should have stream controller`),a.isClosed)break;a.isClosed=!0,a.controller.close(),this.#i(a,t);break;case q.ERROR:A(a,`error should have stream controller`),a.controller.error(J(e.reason)),this.#i(a,t);break;case q.CANCEL_COMPLETE:e.success?a.cancelCall.resolve():a.cancelCall.reject(J(e.reason)),this.#i(a,t);break;case q.CANCEL:if(!o)break;let s=J(e.reason);Promise.try(o.onCancel||en,s).then(function(){i.postMessage({sourceName:n,targetName:r,stream:q.CANCEL_COMPLETE,streamId:t,success:!0})},function(e){i.postMessage({sourceName:n,targetName:r,stream:q.CANCEL_COMPLETE,streamId:t,reason:J(e)})}),o.sinkCapability.reject(s),o.isCancelled=!0,delete this.streamSinks[t];break;default:throw Error(`Unexpected stream case`)}}async#i(e,t){await Promise.allSettled([e.startCall?.promise,e.pullCall?.promise,e.cancelCall?.promise]),delete this.streamControllers[t]}destroy(){this.#e?.abort(),this.#e=null}},nn=class{#e=Object.freeze({cMapUrl:`CMap`,standardFontDataUrl:`font`,wasmUrl:`wasm`});constructor({cMapUrl:e=null,standardFontDataUrl:t=null,wasmUrl:n=null}){this.cMapUrl=e,this.standardFontDataUrl=t,this.wasmUrl=n}async fetch({kind:e,filename:t}){switch(e){case`cMapUrl`:case`standardFontDataUrl`:case`wasmUrl`:break;default:k(`Not implemented: ${e}`)}let n=this[e];if(!n)throw Error(`Ensure that the \`${e}\` API parameter is provided.`);let r=`${n}${t}`;return this._fetch(r,e).catch(t=>{throw Error(`Unable to load ${this.#e[e]} data at: ${r}`)})}async _fetch(e,t){k("Abstract method `_fetch` called.")}},rn=class extends nn{async _fetch(e,t){let n=await xe(e,t===`cMapUrl`&&!e.endsWith(`.bcmap`)?`text`:`bytes`);return n instanceof Uint8Array?n:ie(n)}},an=class{#e=!1;constructor({enableHWA:e=!1}){this.#e=e}create(e,t){if(e<=0||t<=0)throw Error(`Invalid canvas size`);let n=this._createCanvas(e,t);return{canvas:n,context:n.getContext(`2d`,{willReadFrequently:!this.#e})}}reset({canvas:e},t,n){if(!e)throw Error(`Canvas is not specified`);if(t<=0||n<=0)throw Error(`Invalid canvas size`);e.width=t,e.height=n}destroy(e){let{canvas:t}=e;if(!t)throw Error(`Canvas is not specified`);t.width=t.height=0,e.canvas=null,e.context=null}_createCanvas(e,t){k("Abstract method `_createCanvas` called.")}},on=class extends an{constructor({ownerDocument:e=globalThis.document,enableHWA:t=!1}){super({enableHWA:t}),this._document=e}_createCanvas(e,t){let n=this._document.createElement(`canvas`);return n.width=e,n.height=t,n}},sn=class{addFilter(e){return`none`}addHCMFilter(e,t){return`none`}addAlphaFilter(e){return`none`}addLuminosityFilter(e){return`none`}addKnockoutFilter(e=0){return`none`}addHighlightHCMFilter(e,t,n,r,i){return`none`}addSelectionHCMFilter(e,t){return`none`}addSelectionFilter(){return`none`}createSelectionStyle(e=null){return null}destroy(e=!1){}},cn=class extends sn{#e;#t;#n;#r;#i;#a;#o=0;constructor({docId:e,ownerDocument:t=globalThis.document}){super(),this.#r=e,this.#i=t}get#s(){return this.#t||=new Map}get#c(){return this.#a||=new Map}get#l(){if(!this.#n){let e=this.#i.createElement(`div`),{style:t}=e;t.colorScheme=`only light`,t.visibility=`hidden`,t.contain=`strict`,t.width=t.height=0,t.position=`absolute`,t.top=t.left=0,t.zIndex=-1;let n=this.#i.createElementNS(c,`svg`);n.setAttribute(`width`,0),n.setAttribute(`height`,0),this.#n=this.#i.createElementNS(c,`defs`),e.append(n),n.append(this.#n),this.#i.body.append(e)}return this.#n}#u(e){if(e.length===1){let t=e[0],n=Array(256);for(let e=0;e<256;e++)n[e]=t[e]/255;let r=n.join(`,`);return[r,r,r]}let[t,n,r]=e,i=Array(256),a=Array(256),o=Array(256);for(let e=0;e<256;e++)i[e]=t[e]/255,a[e]=n[e]/255,o[e]=r[e]/255;return[i.join(`,`),a.join(`,`),o.join(`,`)]}#d(e){if(this.#e===void 0){this.#e=``;let e=this.#i.URL;e!==this.#i.baseURI&&(Ce(e)?O(`#createUrl: ignore "data:"-URL for performance reasons.`):this.#e=N(e,``))}return`url(${this.#e}#${e})`}addFilter(e){if(!e)return`none`;let t=this.#s.get(e);if(t)return t;let[n,r,i]=this.#u(e),a=e.length===1?n:`${n}${r}${i}`;if(t=this.#s.get(a),t)return this.#s.set(e,t),t;let o=`g_${this.#r}_transfer_map_${this.#o++}`,s=this.#d(o);this.#s.set(e,s),this.#s.set(a,s);let c=this.#m(o);return this.#g(n,r,i,c),s}addHCMFilter(e,t){let n=`${e}-${t}`,r=`base`,i=this.#c.get(r);if(i?.key===n||(i?(i.filter?.remove(),i.key=n,i.url=`none`,i.filter=null):(i={key:n,url:`none`,filter:null},this.#c.set(r,i)),!e||!t))return i.url;let a=this.#v(e);e=V.makeHexColor(...a);let o=this.#v(t);if(t=V.makeHexColor(...o),this.#b(),e===`#000000`&&t===`#ffffff`||e===t)return i.url;let s=Array.from({length:256},(e,t)=>Ue(t/255)).join(`,`),c=`g_${this.#r}_hcm_filter`,l=i.filter=this.#m(c);this.#g(s,s,s,l),this.#p(l);let u=(e,t)=>{let n=a[e]/255,r=o[e]/255,i=Array(t+1);for(let e=0;e<=t;e++)i[e]=n+e/t*(r-n);return i.join(`,`)};return this.#g(u(0,5),u(1,5),u(2,5),l),i.url=this.#d(c),i.url}addSelectionHCMFilter(e,t){return this.addHighlightHCMFilter(`selection`,e,t,`HighlightText`,`Highlight`)}addSelectionFilter(){return this.addHighlightHCMFilter(`selection_default`,`black`,`white`,`HighlightText`,`Highlight`)}createSelectionStyle(e=null){let t=e?this.addSelectionHCMFilter(e.foreground,e.background):this.addSelectionFilter();return t===`none`||!B.platform.isFirefox?null:{"backdrop-filter":t,"background-color":`transparent`}}addAlphaFilter(e){let t=this.#s.get(e);if(t)return t;let[n]=this.#u([e]),r=`alpha_${n}`;if(t=this.#s.get(r),t)return this.#s.set(e,t),t;let i=`g_${this.#r}_alpha_map_${this.#o++}`,a=this.#d(i);this.#s.set(e,a),this.#s.set(r,a);let o=this.#m(i);return this.#_(n,o),a}addLuminosityFilter(e){let t=this.#s.get(e||`luminosity`);if(t)return t;let n,r;if(e?([n]=this.#u([e]),r=`luminosity_${n}`):r=`luminosity`,t=this.#s.get(r),t)return this.#s.set(e,t),t;let i=`g_${this.#r}_luminosity_map_${this.#o++}`,a=this.#d(i);this.#s.set(e,a),this.#s.set(r,a);let o=this.#m(i);return this.#f(o),e&&this.#_(n,o),a}addKnockoutFilter(e=0){let t=e>0?Math.min(1/e,1e6):1e6,n=`knockout_${t}`,r=this.#s.get(n);if(r)return r;let i=`g_${this.#r}_knockout_filter_${this.#o++}`,a=this.#d(i);this.#s.set(n,a);let o=this.#m(i),s=this.#i.createElementNS(c,`feComponentTransfer`);o.append(s);let l=this.#i.createElementNS(c,`feFuncA`);return l.setAttribute(`type`,`linear`),l.setAttribute(`slope`,`${t}`),l.setAttribute(`intercept`,`0`),s.append(l),a}addHighlightHCMFilter(e,t,n,r,i){let a=`${t}-${n}-${r}-${i}`,o=this.#c.get(e);if(o?.key===a||(o?(o.filter?.remove(),o.key=a,o.url=`none`,o.filter=null):(o={key:a,url:`none`,filter:null},this.#c.set(e,o)),!t||!n))return o.url;let[s,c]=[t,n].map(this.#v.bind(this)),l=Math.round(.2126*s[0]+.7152*s[1]+.0722*s[2]),u=Math.round(.2126*c[0]+.7152*c[1]+.0722*c[2]),[d,f]=[r,i].map(this.#x.bind(this));u<l&&([l,u,d,f]=[u,l,f,d]),this.#b();let p=(e,t,n)=>{let r=Array(256),i=(u-l)/n,a=e/255,o=(t-e)/(255*n),s=0;for(let e=0;e<=n;e++){let t=Math.round(l+e*i),n=a+e*o;for(let e=s;e<=t;e++)r[e]=n;s=t+1}for(let e=s;e<256;e++)r[e]=r[s-1];return r.join(`,`)},m=`g_${this.#r}_hcm_${e}_filter`,h=o.filter=this.#m(m);return this.#p(h),this.#g(p(d[0],f[0],5),p(d[1],f[1],5),p(d[2],f[2],5),h),o.url=this.#d(m),o.url}destroy(e=!1){e&&this.#a?.size||(this.#n?.parentNode.parentNode.remove(),this.#n=null,this.#t?.clear(),this.#t=null,this.#a?.clear(),this.#a=null,this.#o=0)}#f(e){let t=this.#i.createElementNS(c,`feColorMatrix`);t.setAttribute(`type`,`matrix`),t.setAttribute(`values`,`0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0`),e.append(t)}#p(e){let t=this.#i.createElementNS(c,`feColorMatrix`);t.setAttribute(`type`,`matrix`),t.setAttribute(`values`,`0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0`),e.append(t)}#m(e){let t=this.#i.createElementNS(c,`filter`);return t.setAttribute(`color-interpolation-filters`,`sRGB`),t.setAttribute(`id`,e),this.#l.append(t),t}#h(e,t,n){let r=this.#i.createElementNS(c,t);r.setAttribute(`type`,`discrete`),r.setAttribute(`tableValues`,n),e.append(r)}#g(e,t,n,r){let i=this.#i.createElementNS(c,`feComponentTransfer`);r.append(i),this.#h(i,`feFuncR`,e),this.#h(i,`feFuncG`,t),this.#h(i,`feFuncB`,n)}#_(e,t){let n=this.#i.createElementNS(c,`feComponentTransfer`);t.append(n),this.#h(n,`feFuncA`,e)}#v(e){return this.#l.style.color=`CanvasText`,this.#l.style.backgroundColor=e,Me(getComputedStyle(this.#l).getPropertyValue(`background-color`))}#y(e){return this.#l.style.color=`CanvasText`,this.#l.style.backgroundColor=e,je(getComputedStyle(this.#l).getPropertyValue(`background-color`))}#b(){this.#l.style.color=``,this.#l.style.backgroundColor=``}#x(e){let[t,n,r,i]=this.#y(e);if(i===1)return[t,n,r];let[a,o,s]=this.#v(`Canvas`);return[ln(t,a,i),ln(n,o,i),ln(r,s,i)]}};function ln(e,t,n){return Math.round(n*e+(1-n)*t)}if(i){let e;try{let t=process.getBuiltinModule(`module`).createRequire(import.meta.url);try{e=t("@napi-rs/canvas")}catch(e){O(`Cannot load "@napi-rs/canvas" package: "${e}".`)}}catch(e){O(`Cannot access the \`require\` function: "${e}".`)}globalThis.DOMMatrix||(e?.DOMMatrix?globalThis.DOMMatrix=e.DOMMatrix:O("Cannot polyfill `DOMMatrix`, rendering may be broken.")),globalThis.Path2D||(e?.Path2D?globalThis.Path2D=e.Path2D:O("Cannot polyfill `Path2D`, rendering may be broken.")),globalThis.navigator?.language||(globalThis.navigator={language:`en-US`,platform:``,userAgent:``})}async function un(e){let t=await process.getBuiltinModule(`fs/promises`).readFile(e);return new Uint8Array(t)}var dn=class extends sn{},fn=class extends an{_createCanvas(e,t){return process.getBuiltinModule(`module`).createRequire(import.meta.url)(`@napi-rs/canvas`).createCanvas(e,t)}},pn=class extends nn{async _fetch(e,t){return un(e)}};function mn({src:e,srcPos:t=0,dest:n,width:r,height:i,nonBlackColor:a=4294967295,inverseDecode:o=!1}){let s=B.isLittleEndian?4278190080:255,[c,l]=o?[a,s]:[s,a],u=r>>3,d=r&7,f=c^l,p=e.length;n=new Uint32Array(n.buffer);let m=0;for(let r=0;r<i;++r){for(let r=t+u;t<r;++t,m+=8){let r=e[t];n[m]=c^-(r>>7&1)&f,n[m+1]=c^-(r>>6&1)&f,n[m+2]=c^-(r>>5&1)&f,n[m+3]=c^-(r>>4&1)&f,n[m+4]=c^-(r>>3&1)&f,n[m+5]=c^-(r>>2&1)&f,n[m+6]=c^-(r>>1&1)&f,n[m+7]=c^-(r&1)&f}if(d===0)continue;let r=t<p?e[t++]:255;for(let e=0;e<d;++e,++m)n[m]=c^-(r>>7-e&1)&f}return{srcPos:t,destPos:m}}function hn({src:e,srcPos:t=0,dest:n,destPos:r=0,width:i,height:a}){let o=0,s=i*a*3,c=s>>2,l=new Uint32Array(e.buffer,t,c),u=B.isLittleEndian?4278190080:255;if(B.isLittleEndian){for(;o<c-2;o+=3,r+=4){let e=l[o],t=l[o+1],i=l[o+2];n[r]=e|u,n[r+1]=e>>>24|t<<8|u,n[r+2]=t>>>16|i<<16|u,n[r+3]=i>>>8|u}for(let i=o*4,a=t+s;i<a;i+=3)n[r++]=e[i]|e[i+1]<<8|e[i+2]<<16|u}else{for(;o<c-2;o+=3,r+=4){let e=l[o],t=l[o+1],i=l[o+2];n[r]=e|u,n[r+1]=e<<24|t>>>8|u,n[r+2]=t<<16|i>>>16|u,n[r+3]=i<<8|u}for(let i=o*4,a=t+s;i<a;i+=3)n[r++]=e[i]<<24|e[i+1]<<16|e[i+2]<<8|u}return{srcPos:t+s,destPos:r}}var gn=`
|
|
4
4
|
struct Uniforms {
|
package/dist/ui/index.html
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
19
19
|
<link rel="icon" type="image/x-icon" href="/favicon.ico" sizes="any" />
|
|
20
20
|
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
|
|
21
|
-
<script type="module" crossorigin src="/assets/index-
|
|
21
|
+
<script type="module" crossorigin src="/assets/index-fZYNgtd-.js"></script>
|
|
22
22
|
<link rel="stylesheet" crossorigin href="/assets/index-x1XGuNl0.css">
|
|
23
23
|
</head>
|
|
24
24
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opencraw/studio",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.38",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.esm.js",
|
|
6
6
|
"module": "./dist/index.esm.js",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"!**/*.js.map"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@opencraw/core": "^0.1.
|
|
28
|
-
"@opencraw/probe": "^0.0.
|
|
27
|
+
"@opencraw/core": "^0.1.43",
|
|
28
|
+
"@opencraw/probe": "^0.0.26",
|
|
29
29
|
"cheerio": "^1.2.0",
|
|
30
30
|
"playwright": "^1.63.0",
|
|
31
31
|
"zod": "^4.6.5",
|