@triiiceratops/plugin-image-export 1.0.0-rc.3 → 1.0.0-rc.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/iife.js CHANGED
@@ -2,7 +2,7 @@
2
2
  \r\f \v\uFEFF`];function vs(r,s,e){var t=r==null?"":""+r;if(s&&(t=t?t+" "+s:s),e){for(var i in e)if(e[i])t=t?t+" "+i:i;else if(t.length)for(var n=i.length,o=0;(o=t.indexOf(i,o))>=0;){var u=o+n;(o===0||rr.includes(t[o-1]))&&(u===t.length||rr.includes(t[u]))?t=(o===0?"":t.substring(0,o))+t.substring(u+1):o=u}}return t===""?null:t}function or(r,s=!1){var e=s?" !important;":";",t="";for(var i in r){var n=r[i];n!=null&&n!==""&&(t+=" "+i+": "+n+e)}return t}function Vi(r){return r[0]!=="-"||r[1]!=="-"?r.toLowerCase():r}function ms(r,s){if(s){var e="",t,i;if(Array.isArray(s)?(t=s[0],i=s[1]):t=s,r){r=String(r).replaceAll(/\s*\/\*.*?\*\/\s*/g,"").trim();var n=!1,o=0,u=!1,l=[];t&&l.push(...Object.keys(t).map(Vi)),i&&l.push(...Object.keys(i).map(Vi));var a=0,h=-1;const _=r.length;for(var c=0;c<_;c++){var d=r[c];if(u?d==="/"&&r[c-1]==="*"&&(u=!1):n?n===d&&(n=!1):d==="/"&&r[c+1]==="*"?u=!0:d==='"'||d==="'"?n=d:d==="("?o++:d===")"&&o--,!u&&n===!1&&o===0){if(d===":"&&h===-1)h=c;else if(d===";"||c===_-1){if(h!==-1){var v=Vi(r.substring(a,h).trim());if(!l.includes(v)){d!==";"&&c++;var m=r.substring(a,c).trim();e+=" "+m+";"}}a=c+1,h=-1}}}}return t&&(e+=or(t)),i&&(e+=or(i,!0)),e=e.trim(),e===""?null:e}return r==null?null:String(r)}function ei(r,s,e,t,i,n){var o=r.__className;if(o!==e||o===void 0){var u=vs(e,t,n);u==null?r.removeAttribute("class"):s?r.className=u:r.setAttribute("class",u),r.__className=e}else if(n&&i!==n)for(var l in n){var a=!!n[l];(i==null||a!==!!i[l])&&r.classList.toggle(l,a)}return n}function Gi(r,s={},e,t){for(var i in e){var n=e[i];s[i]!==n&&(e[i]==null?r.style.removeProperty(i):r.style.setProperty(i,n,t))}}function qi(r,s,e,t){var i=r.__style;if(i!==s){var n=ms(s,t);n==null?r.removeAttribute("style"):r.style.cssText=n,r.__style=s}else t&&(Array.isArray(t)?(Gi(r,e?.[0],t[0]),Gi(r,e?.[1],t[1],"important")):Gi(r,e,t));return t}function mi(r,s,e=!1){if(r.multiple){if(s==null)return;if(!Pi(s))return wo();for(var t of r.options)t.selected=s.includes(ti(t));return}for(t of r.options){var i=ti(t);if(Mo(i,s)){t.selected=!0;return}}(!e||s!==void 0)&&(r.selectedIndex=-1)}function sr(r){var s=new MutationObserver(()=>{mi(r,r.__value)});s.observe(r,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),An(()=>{s.disconnect()})}function ws(r,s,e=s){var t=new WeakSet,i=!0;Uo(r,"change",n=>{var o=n?"[selected]":":checked",u;if(r.multiple)u=[].map.call(r.querySelectorAll(o),ti);else{var l=r.querySelector(o)??r.querySelector("option:not([disabled])");u=l&&ti(l)}e(u),se!==null&&t.add(se)}),Xt(()=>{var n=s();if(r===document.activeElement){var o=ai??se;if(t.has(o))return}if(mi(r,n,i),i&&n===void 0){var u=r.querySelector(":checked");u!==null&&(n=ti(u),e(n))}r.__value=n,i=!1}),sr(r)}function ti(r){return"__value"in r?r.__value:r.value}const Ft=Symbol("class"),ii=Symbol("style"),ar=Symbol("is custom element"),lr=Symbol("is html");function ys(r,s){s?r.hasAttribute("selected")||r.setAttribute("selected",""):r.removeAttribute("selected")}function Ze(r,s,e,t){var i=hr(r);i[s]!==(i[s]=e)&&(s==="loading"&&(r[Zr]=e),e==null?r.removeAttribute(s):typeof e!="string"&&dr(r).includes(s)?r[s]=e:r.setAttribute(s,e))}function _s(r,s,e,t,i=!1,n=!1){var o=hr(r),u=o[ar],l=!o[lr],a=s||{},h=r.tagName==="OPTION";for(var c in s)c in e||(e[c]=null);e.class?e.class=gs(e.class):(t||e[Ft])&&(e.class=null),e[ii]&&(e.style??=null);var d=dr(r);for(const P in e){let B=e[P];if(h&&P==="value"&&B==null){r.value=r.__value="",a[P]=B;continue}if(P==="class"){var v=r.namespaceURI==="http://www.w3.org/1999/xhtml";ei(r,v,B,t,s?.[Ft],e[Ft]),a[P]=B,a[Ft]=e[Ft];continue}if(P==="style"){qi(r,B,s?.[ii],e[ii]),a[P]=B,a[ii]=e[ii];continue}var m=a[P];if(!(B===m&&!(B===void 0&&r.hasAttribute(P)))){a[P]=B;var _=P[0]+P[1];if(_!=="$$")if(_==="on"){const O={},M="$$"+P;let L=P.slice(2);var y=Jo(L);if(Ko(L)&&(L=L.slice(0,-7),O.capture=!0),!y&&m){if(B!=null)continue;r.removeEventListener(L,a[M],O),a[M]=null}if(B!=null)if(y)r[`__${L}`]=B,Kn([L]);else{let W=function(Y){a[P].call(this,Y)};a[M]=rs(L,r,W,O)}else y&&(r[`__${L}`]=void 0)}else if(P==="style")Ze(r,P,B);else if(P==="autofocus")Ho(r,!!B);else if(!u&&(P==="__value"||P==="value"&&B!=null))r.value=r.__value=B;else if(P==="selected"&&h)ys(r,B);else{var E=P;l||(E=ts(E));var S=E==="defaultValue"||E==="defaultChecked";if(B==null&&!u&&!S)if(o[P]=null,E==="value"||E==="checked"){let O=r;const M=s===void 0;if(E==="value"){let L=O.defaultValue;O.removeAttribute(E),O.defaultValue=L,O.value=O.__value=M?L:null}else{let L=O.defaultChecked;O.removeAttribute(E),O.defaultChecked=L,O.checked=M?L:!1}}else r.removeAttribute(P);else S||d.includes(E)&&(u||typeof B!="string")?(r[E]=B,E in o&&(o[E]=Ee)):typeof B!="function"&&Ze(r,E,B)}}}return a}function ur(r,s,e=[],t=[],i=[],n,o=!1,u=!1){mn(i,e,t,l=>{var a=void 0,h={},c=r.nodeName==="SELECT",d=!1;if(Bn(()=>{var m=s(...l.map(b)),_=_s(r,a,m,n,o,u);d&&c&&"value"in m&&mi(r,m.value);for(let E of Object.getOwnPropertySymbols(h))m[E]||Se(h[E]);for(let E of Object.getOwnPropertySymbols(m)){var y=m[E];E.description===mo&&(!a||y!==a[E])&&(h[E]&&Se(h[E]),h[E]=Ae(()=>ps(r,()=>y))),_[E]=y}a=_}),c){var v=r;Xt(()=>{mi(v,a.value,!0),sr(v)})}d=!0})}function hr(r){return r.__attributes??={[ar]:r.nodeName.includes("-"),[lr]:r.namespaceURI===vo}}var cr=new Map;function dr(r){var s=r.getAttribute("is")||r.nodeName,e=cr.get(s);if(e)return e;cr.set(s,e=[]);for(var t,i=r,n=Element.prototype;n!==i;){t=Ur(i);for(var o in t)t[o].set&&e.push(o);i=tn(i)}return e}function pr(r,s){return r===s||r?.[vt]===s}function wi(r={},s,e,t){return Xt(()=>{var i,n;return On(()=>{i=n,n=[],gi(()=>{r!==e(...n)&&(s(r,...n),i&&pr(e(...i),r)&&s(null,...i))})}),()=>{mt(()=>{n&&pr(e(...n),r)&&s(null,...n)})}}),r}let yi=!1;function xs(r){var s=yi;try{return yi=!1,[r(),yi]}finally{yi=s}}const Ts={get(r,s){if(!r.exclude.includes(s))return r.props[s]},set(r,s){return!1},getOwnPropertyDescriptor(r,s){if(!r.exclude.includes(s)&&s in r.props)return{enumerable:!0,configurable:!0,value:r.props[s]}},has(r,s){return r.exclude.includes(s)?!1:s in r.props},ownKeys(r){return Reflect.ownKeys(r.props).filter(s=>!r.exclude.includes(s))}};function fr(r,s,e){return new Proxy({props:r,exclude:s},Ts)}function Oe(r,s,e,t){var i=(e&co)!==0,n=(e&po)!==0,o=t,u=!0,l=()=>(u&&(u=!1,o=n?gi(t):t),o),a;if(i){var h=vt in r||qr in r;a=Ct(r,s)?.set??(h&&s in r?S=>r[s]=S:void 0)}var c,d=!1;i?[c,d]=xs(()=>r[s]):c=r[s],c===void 0&&t!==void 0&&(c=l(),a&&(eo(),a(c)));var v;if(v=()=>{var S=r[s];return S===void 0?l():(u=!0,S)},(e&ho)===0)return v;if(a){var m=r.$$legacy;return(function(S,P){return arguments.length>0?((!P||m||d)&&a(P?v():S),S):v()})}var _=!1,y=((e&uo)!==0?ui:wn)(()=>(_=!1,v()));i&&b(y);var E=ne;return(function(S,P){if(arguments.length>0){const B=P?b(y):i?lt(S):S;return G(y,B),_=!0,o!==void 0&&(o=B),S}return Tt&&_||(E.f&tt)!==0?y.v:b(y)})}const Es=/^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z-.]+))?(?:\+[0-9A-Za-z-.]+)?$/;function _i(r){const s=Es.exec(r.trim());if(!s)return null;const[,e,t,i,n]=s,o=n?n.split(".").map(u=>/^\d+$/.test(u)?Number(u):u):[];return{major:Number(e),minor:Number(t),patch:Number(i),prerelease:o}}function bs(r,s){return r.major-s.major||r.minor-s.minor||r.patch-s.patch}function Ss(r,s){if(r.prerelease.length===0&&s.prerelease.length===0)return 0;if(r.prerelease.length===0)return 1;if(s.prerelease.length===0)return-1;const e=Math.max(r.prerelease.length,s.prerelease.length);for(let t=0;t<e;t++){const i=r.prerelease[t],n=s.prerelease[t];if(i===void 0)return-1;if(n===void 0)return 1;if(i===n)continue;const o=typeof i=="number",u=typeof n=="number";return o&&u?i<n?-1:1:o?-1:u?1:String(i)<String(n)?-1:1}return 0}function Ps(r,s){return bs(r,s)||Ss(r,s)}function Cs(r){return r.major>0?{major:r.major+1,minor:0,patch:0,prerelease:[]}:r.minor>0?{major:0,minor:r.minor+1,patch:0,prerelease:[]}:{major:0,minor:0,patch:r.patch+1,prerelease:[]}}function Rs(r){if(r===""||r==="*"||r==="x"||r==="X")return[];let s;if(s=/^\^\s*(.+)$/.exec(r)){const e=_i(s[1]??"");return e?[{op:">=",ver:e},{op:"<",ver:Cs(e)}]:null}if(s=/^~\s*(.+)$/.exec(r)){const e=_i(s[1]??"");return e?[{op:">=",ver:e},{op:"<",ver:{major:e.major,minor:e.minor+1,patch:0,prerelease:[]}}]:null}if(s=/^(>=|<=|>|<|=)?\s*(.+)$/.exec(r)){const e=_i(s[2]??"");return e?[{op:s[1]??"=",ver:e}]:null}return null}function Ds(r,s){const e=Ps(r,s.ver);switch(s.op){case"<":return e<0;case"<=":return e<=0;case">":return e>0;case">=":return e>=0;case"=":return e===0}}function Is(r,s){const e=s.trim();if(e===""||e==="*"||e==="x")return!0;const t=e.split(/\s+/).filter(Boolean);for(const i of t){const n=Rs(i);if(n===null||!n.every(o=>Ds(r,o)))return!1}return!0}function gr(r,s){const e=_i(r);if(!e)return!1;const t=s.split("||").map(i=>i.trim()).filter(i=>i.length>0);return t.length===0?!0:t.some(i=>Is(e,i))}class Zi extends Error{code="PLUGIN_INCOMPATIBLE";pluginName;pluginVersion;reasons;constructor(s,e,t){super(As(s,e,t)),this.name="PluginCompatibilityError",this.pluginName=s,this.pluginVersion=e,this.reasons=t,Object.setPrototypeOf(this,Zi.prototype)}}function As(r,s,e){const t=e.map(i=>` - ${i.message}`).join(`
3
3
  `);return`Plugin "${r}"@${s} cannot activate — incompatible with this viewer:
4
4
  ${t}
5
- Update the plugin or the core viewer so their declared ranges and capabilities overlap.`}function ks(r,s){const e=[];gr(s.coreVersion,r.coreRange)||e.push({kind:"core",required:r.coreRange,actual:s.coreVersion,message:`requires core ${r.coreRange} but this viewer is core ${s.coreVersion}`}),gr(s.pluginApiVersion,r.pluginApiRange)||e.push({kind:"pluginApi",required:r.pluginApiRange,actual:s.pluginApiVersion,message:`requires plugin API ${r.pluginApiRange} but this viewer provides plugin API ${s.pluginApiVersion}`});const t=new Set(s.capabilities);for(const i of r.requiredCapabilities)t.has(i)||e.push({kind:"capability",required:i,actual:s.capabilities.join(", ")||"(none)",message:`requires capability "${i}" which this viewer does not provide (has: ${s.capabilities.join(", ")||"none"})`});return e}function Os(r,s){const e=ks(r,s);if(e.length>0)throw new Zi(r.name,r.version,e)}function Bs(r,s={}){let e=0,t=!1;const i=new Set,n=r.subscribe(()=>{e++;for(const u of[...i])u()},s.onListenerError);return{selectors:{select(u,l=Object.is){let a=-1,h;const c=()=>(a!==e&&(h=u(r),a=e),h);return{get:c,subscribe(d){if(t)return()=>{};let v=c();const m=()=>{let _;try{_=c()}catch(y){s.onProjectionError?.(y);return}l(v,_)||(v=_,d(_))};return i.add(m),()=>{i.delete(m)}}}}},dispose(){t||(t=!0,i.clear(),n())}}}const Mt=()=>{};function Fs(){return{install(r,s){return Mt}}}function Ms(){return{current:"en",t(r,s){return r},subscribe(r){return Mt}}}function Ls(){return{renderIcon(r,s){return Mt}}}function zs(r){return{id:r??"",isOpen:!0,target:"panel",open:Mt,close:Mt,toggle:Mt}}function Hs(r){const s=new Set;return{service:{install(e,t){const i=r.install(e,t);let n=!1;const o=()=>{n||(n=!0,s.delete(o),i())};return s.add(o),o}},releaseAll(){for(const e of[...s])e();s.clear()}}}function Ns(r){const s=new Set;return{service:{get current(){return r.current},t(e,t){return r.t(e,t)},subscribe(e){const t=r.subscribe(e);let i=!1;const n=()=>{i||(i=!0,s.delete(n),t())};return s.add(n),n}},releaseAll(){for(const e of[...s])e();s.clear()}}}const Us={deactivate(){}};function Ws(r,s){const e=s.reportError;let t,i,n,o;try{Os(r,s),t=Bs(s.viewerState,{onProjectionError:e?d=>e({phase:"command",error:d}):void 0,onListenerError:e?d=>e({phase:"subscription",error:d}):void 0}),i=Hs(s.styles??Fs()),n=Ns(s.locale??Ms()),o={viewerState:s.viewerState,selectors:t.selectors,surface:s.surface??zs(r.uiId??r.name),styles:i.service,locale:n.service,ui:s.ui??Ls()}}catch(d){if(t?.dispose(),i?.releaseAll(),n?.releaseAll(),e)return e({phase:"setup",error:d}),Us;throw d}const u=[],l=i,a=n,h=t;try{const d=r.view.mount(s.container,o);typeof d=="function"&&u.push(d)}catch(d){if(!e)throw l.releaseAll(),a.releaseAll(),h.dispose(),d;e({phase:"mount",error:d})}u.push(()=>l.releaseAll()),u.push(()=>a.releaseAll()),u.push(()=>h.dispose());let c=!1;return{deactivate(){if(!c){c=!0;for(let d=u.length-1;d>=0;d--)try{u[d]?.()}catch(v){e?e({phase:"cleanup",error:v}):console.error(`[triiiceratops] Plugin "${r.name}" cleanup threw during deactivation; teardown continues.`,v)}u.length=0}}}}const js="triiiceratops-plugin";function Vs(r){const s={name:r.name,uiId:r.uiId,version:r.version,coreRange:r.coreRange,pluginApiRange:r.pluginApiRange,requiredCapabilities:r.requiredCapabilities??[],icon:r.icon,target:r.target??"panel",dismiss:r.dismiss,catalog:r.catalog,view:r.view};return{kind:js,...s,activate(e){return Ws(s,e)}}}class Gs extends Error{name="SvgIconError";constructor(s){super(`svgIcon: ${s}`)}}const qs="0 0 24 24";function bt(r,s){if(!r)throw new Gs(s)}const Zs=/<svg\b[^>]*>/i;function Xs(r){bt(typeof r=="string","expected an SVG string.");const s=r.trim();bt(s.length>0,"received an empty string.");const e=Zs.exec(s);bt(e!==null,"the markup must contain an <svg> root element."),bt(!/<script[\s/>]/i.test(s),"<script> elements are not allowed in plugin icons."),bt(!/<foreignObject[\s/>]/i.test(s),"<foreignObject> is not allowed in plugin icons."),bt(!/\son[a-z]+\s*=/i.test(s),"on* event-handler attributes (e.g. onload, onclick) are not allowed in plugin icons.");for(const u of s.matchAll(/(?:xlink:)?href\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+))/gi)){const l=(u[1]??u[2]??u[3]??"").trim();bt(l.startsWith("#"),`external href/xlink:href URLs are not allowed in plugin icons (found "${l}"); only internal "#id" references are.`)}const t=e[0],i=/\bviewBox\s*=\s*(?:"([^"]*)"|'([^']*)')/i.exec(t);let n=(i?.[1]??i?.[2])?.trim();if(!n){const u=/\bwidth\s*=\s*(?:"([^"]*)"|'([^']*)')/i.exec(t),l=/\bheight\s*=\s*(?:"([^"]*)"|'([^']*)')/i.exec(t),a=parseFloat(u?.[1]??u?.[2]??""),h=parseFloat(l?.[1]??l?.[2]??"");n=Number.isFinite(a)&&Number.isFinite(h)?`0 0 ${a} ${h}`:qs}let o="";if(!/\/\s*>$/.test(t)){const u=e.index+t.length,l=s.lastIndexOf("</svg>");o=(l>=u?s.slice(u,l):s.slice(u)).trim()}return{kind:"svg",inner:o,viewBox:n}}function $s(r,s){return{STYLES:r,STYLE_ID:s}}function Ys(r,s,e,t,i){const n={pluginName:s,pluginVersion:e,phase:"command",error:t,retry:i};r.dispatchEvent(new CustomEvent("pluginerror",{detail:n,bubbles:!0,composed:!0}))}const Ks=".btn.svelte-sgoebi{display:inline-flex;flex-wrap:nowrap;flex-shrink:0;justify-content:center;align-items:center;gap:.375rem;cursor:pointer;text-align:center;vertical-align:middle;user-select:none;-webkit-user-select:none;touch-action:manipulation;font-weight:600;height:var(--size);padding-inline:var(--btn-p);font-size:var(--fontsize, .875rem);color:var(--btn-fg);background-color:var(--btn-bg);border-width:var(--tri-border);border-style:solid;border-color:var(--btn-border);border-start-start-radius:var(--join-ss, var(--tri-radius-buttons));border-start-end-radius:var(--join-se, var(--tri-radius-buttons));border-end-end-radius:var(--join-ee, var(--tri-radius-buttons));border-end-start-radius:var(--join-es, var(--tri-radius-buttons));outline-offset:2px;outline-color:var(--btn-color, var(--tri-content));text-shadow:0 .5px oklch(100% 0 0 / calc(var(--tri-depth) * .15));box-shadow:0 .5px 0 .5px oklch(100% 0 0 / calc(var(--tri-depth) * 6%)) inset,var(--btn-shadow);transition-property:color,background-color,border-color,box-shadow;transition-duration:.2s;transition-timing-function:cubic-bezier(0,0,.2,1);--size: calc(var(--tri-size-field, .25rem) * 10);--btn-bg: var(--btn-color, var(--tri-toolbar-bg));--btn-fg: var(--tri-content);--btn-p: 1rem;--btn-border: color-mix( in oklab, var(--btn-bg), #000 calc(var(--tri-depth) * 5%) );--btn-shadow: 0 3px 2px -2px color-mix( in oklab, var(--btn-bg) calc(var(--tri-depth) * 30%), #0000 ), 0 4px 3px -2px color-mix( in oklab, var(--btn-bg) calc(var(--tri-depth) * 30%), #0000 )}@media(hover:hover){.btn.svelte-sgoebi:hover{--btn-bg: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 7% )}}.btn.svelte-sgoebi:focus-visible{isolation:isolate;outline-width:2px;outline-style:solid}.btn.svelte-sgoebi:active:not(.active){--btn-bg: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 5% );--btn-border: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 7% );--btn-shadow: 0 0 0 0 oklch(0% 0 0 / 0), 0 0 0 0 oklch(0% 0 0 / 0);translate:0 .5px}.btn.active.svelte-sgoebi{--btn-bg: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 7% )}.btn.svelte-sgoebi:disabled,.btn[disabled].svelte-sgoebi{pointer-events:none;--btn-border: #0000;--btn-fg: color-mix(in oklch, var(--tri-content) 20%, #0000)}.btn.svelte-sgoebi:disabled:not(.ghost):not(.outline),.btn[disabled].svelte-sgoebi:not(.ghost):not(.outline){background-color:color-mix(in oklab,var(--tri-content) 10%,transparent);box-shadow:none}.circle.svelte-sgoebi{width:var(--size);height:var(--size);border-radius:3.40282e38px;padding-inline:0}.square.svelte-sgoebi{width:var(--size);height:var(--size);padding-inline:0}.ghost.svelte-sgoebi{--btn-bg: transparent;--btn-border: transparent;--btn-fg: var(--btn-color-text, var(--btn-color, var(--tri-content)));box-shadow:none;text-shadow:none}@media(hover:hover){.ghost.svelte-sgoebi:hover{--btn-bg: color-mix(in oklab, var(--tri-content) 10%, transparent)}}.ghost.svelte-sgoebi:active:not(.active),.ghost.active.svelte-sgoebi{--btn-bg: color-mix(in oklab, var(--tri-content) 10%, transparent);--btn-border: transparent}.outline.svelte-sgoebi:not(:hover):not(:active):not(:focus-visible):not(.active):not(:disabled):not([disabled]){--btn-bg: transparent;--btn-fg: var(--btn-color-text, var(--btn-color, var(--tri-content)));--btn-border: var(--btn-color, var(--tri-content));box-shadow:none;text-shadow:none}.select-wrapper.svelte-1hwvamm{display:inline-flex;width:clamp(3rem,20rem,100%);max-width:100%}.native-select.svelte-1hwvamm{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0;pointer-events:none}.select.svelte-1hwvamm{border:var(--tri-border) solid var(--input-color);appearance:none;background-color:var(--tri-input-bg);vertical-align:middle;width:100%;height:var(--size);touch-action:manipulation;white-space:nowrap;box-shadow:0 1px color-mix(in oklab,var(--input-color) calc(var(--tri-depth) * 10%),#0000) inset,0 -1px oklch(100% 0 0 / calc(var(--tri-depth) * .1)) inset;--input-color: color-mix(in oklab, var(--tri-content) 20%, #0000);--size: calc(var(--tri-size-field, .25rem) * 10);background-image:linear-gradient(45deg,#0000 50%,currentColor 50%),linear-gradient(135deg,currentColor 50%,#0000 50%);background-position:calc(100% - 20px) calc(1px + 50%),calc(100% - 16.1px) calc(1px + 50%);background-repeat:no-repeat;background-size:4px 4px,4px 4px;border-start-start-radius:var(--join-ss, var(--tri-radius-buttons));border-start-end-radius:var(--join-se, var(--tri-radius-buttons));border-end-end-radius:var(--join-ee, var(--tri-radius-buttons));border-end-start-radius:var(--join-es, var(--tri-radius-buttons));align-items:center;gap:.375rem;padding-inline:.75rem 1.75rem;font-size:.875rem;display:inline-flex;position:relative;cursor:pointer;color:inherit;text-align:start}.select-label.svelte-1hwvamm{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.select-label.placeholder.svelte-1hwvamm{color:color-mix(in oklab,var(--tri-content) 55%,transparent)}.select.svelte-1hwvamm:hover:not(:disabled){--input-color: color-mix(in oklab, var(--tri-content) 40%, #0000)}.select.svelte-1hwvamm:focus-visible,.select.open.svelte-1hwvamm{--input-color: var(--tri-content);box-shadow:0 1px color-mix(in oklab,var(--input-color) calc(var(--tri-depth) * 10%),#0000);outline:2px solid var(--input-color);outline-offset:2px;isolation:isolate;z-index:1}.select.svelte-1hwvamm:is(:where(.svelte-1hwvamm):disabled,[disabled]:where(.svelte-1hwvamm)){cursor:not-allowed;border-color:var(--tri-panel-bg);background-color:var(--tri-panel-bg);color:color-mix(in oklab,var(--tri-content) 40%,transparent)}.ghost.svelte-1hwvamm{box-shadow:none;background-color:#0000;border-color:#0000;transition:background-color .2s}.ghost.svelte-1hwvamm:hover:not(:disabled){background-color:color-mix(in oklab,var(--tri-content) 8%,transparent)}.ghost.svelte-1hwvamm:focus-visible,.ghost.open.svelte-1hwvamm{background-color:var(--tri-input-bg);color:var(--tri-content)}.listbox.svelte-1hwvamm{position:fixed;inset:auto;margin:0;padding:.1875rem;border:var(--tri-border) solid color-mix(in oklab,var(--tri-content) 20%,#0000);background-color:var(--tri-input-bg);color:var(--tri-content);border-radius:var(--tri-radius-buttons);box-shadow:0 8px 24px oklch(0 0 0 / calc(.12 + var(--tri-depth) * .06));max-height:16rem;overflow-y:auto;min-width:8rem;z-index:1}.listbox.svelte-1hwvamm:not(:popover-open){display:none}.option.svelte-1hwvamm{padding:.25rem .5rem;border-radius:calc(var(--tri-radius-buttons) * .6);cursor:pointer;font-size:.8125rem;line-height:1.3;white-space:nowrap;color:inherit}.option.active.svelte-1hwvamm{background-color:color-mix(in oklab,var(--tri-content) 12%,#0000)}.option.selected.svelte-1hwvamm{background-color:color-mix(in oklab,var(--tri-color-primary) 90%,#0000);color:var(--tri-color-primary-content)}.option.selected.active.svelte-1hwvamm{background-color:var(--tri-color-primary)}.option[aria-disabled=true].svelte-1hwvamm{opacity:.5;cursor:not-allowed;color:color-mix(in oklab,var(--tri-content) 55%,transparent)}\n",Qs={en:{image_download_title:"Download Image",image_download_close:"Close Download Image",image_download_description:"Download the current canvas as an image.",image_download_mode:"What to download",image_download_mode_composite:"Composite canvas",image_download_mode_composite_hint:"Every image on the current canvas, composited together.",image_download_mode_single:"Single image",image_download_mode_single_hint:"One image from the current canvas.",image_download_mode_world:"Current view",image_download_mode_world_hint:"Everything currently laid out together in the viewer.",image_download_canvas:"Canvas",image_download_image:"Image",image_download_resolution:"Resolution",image_download_resolution_placeholder:"Select a resolution",image_download_downloading:"Downloading...",image_download_download:"Download",image_download_disabled_no_canvas:"Load a manifest to download an image.",image_download_disabled_no_resolution:"Select a resolution to download.",image_download_result_downloaded:"Downloaded {filename}.",image_download_error_failed:"Unable to download image. Check the browser console for details."},de:{image_download_title:"Bild herunterladen",image_download_close:"Bild-Download schließen",image_download_description:"Die aktuelle Leinwand als Bild herunterladen.",image_download_mode:"Was heruntergeladen werden soll",image_download_mode_composite:"Zusammengesetzte Leinwand",image_download_mode_composite_hint:"Alle Bilder der aktuellen Leinwand, zusammengesetzt.",image_download_mode_single:"Einzelbild",image_download_mode_single_hint:"Ein Bild von der aktuellen Leinwand.",image_download_mode_world:"Aktuelle Ansicht",image_download_mode_world_hint:"Alles, was aktuell zusammen im Viewer angezeigt wird.",image_download_canvas:"Leinwand",image_download_image:"Bild",image_download_resolution:"Auflösung",image_download_resolution_placeholder:"Auflösung auswählen",image_download_downloading:"Wird heruntergeladen...",image_download_download:"Herunterladen",image_download_disabled_no_canvas:"Laden Sie ein Manifest, um ein Bild herunterzuladen.",image_download_disabled_no_resolution:"Wählen Sie eine Auflösung zum Herunterladen aus.",image_download_result_downloaded:"{filename} heruntergeladen.",image_download_error_failed:"Bild kann nicht heruntergeladen werden. Details in der Browserkonsole."}},vr=Symbol("triiiceratops:plugin-image-download"),mr=Xs('<svg viewBox="0 0 256 256"><path d="M224,144v64a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V144a8,8,0,0,1,16,0v56H208V144a8,8,0,0,1,16,0Zm-101.66,5.66a8,8,0,0,0,11.32,0l40-40a8,8,0,0,0-11.32-11.32L136,124.69V32a8,8,0,0,0-16,0v92.69L93.66,98.34a8,8,0,0,0-11.32,11.32Z"/></svg>'),Js="5";typeof window<"u"&&((window.__svelte??={}).v??=new Set).add(Js);var ea=ve("<button><!></button>");function ta(r,s){let e=Oe(s,"variant",3,"default"),t=Oe(s,"size",3,"md"),i=Oe(s,"circle",3,!1),n=Oe(s,"square",3,!1),o=Oe(s,"ghost",3,!1),u=Oe(s,"outline",3,!1),l=Oe(s,"active",3,!1),a=Oe(s,"class",3,""),h=Oe(s,"style",3,""),c=fr(s,["$$slots","$$events","$$legacy","variant","size","circle","square","ghost","outline","active","class","style","children"]);const d={default:"",primary:"--btn-color:var(--tri-color-primary);--btn-color-text:var(--tri-color-primary-text);--btn-fg:var(--tri-color-primary-content);",neutral:"--btn-color:var(--tri-color-neutral);--btn-fg:var(--tri-color-neutral-content);",success:"--btn-color:var(--tri-color-success);--btn-fg:var(--tri-color-success-content);",warning:"--btn-color:var(--tri-color-warning);--btn-fg:var(--tri-color-warning-content);",error:"--btn-color:var(--tri-color-error);--btn-fg:var(--tri-color-error-content);"},v={xs:"--fontsize:0.6875rem;--btn-p:0.5rem;--size:calc(var(--tri-size-field,0.25rem)*6);",sm:"--fontsize:0.75rem;--btn-p:0.75rem;--size:calc(var(--tri-size-field,0.25rem)*8);",md:"--fontsize:0.875rem;--btn-p:1rem;--size:calc(var(--tri-size-field,0.25rem)*10);",lg:"--fontsize:1.125rem;--btn-p:1.25rem;--size:calc(var(--tri-size-field,0.25rem)*12);"};let m=ae(()=>`${v[t()]}${d[e()]}${h()}`);var _=ea();ur(_,()=>({class:`btn ${a()??""}`,style:b(m),...c,[Ft]:{circle:i(),square:n(),ghost:o(),outline:u(),active:l()}}),void 0,void 0,void 0,"svelte-sgoebi");var y=J(_);ir(y,()=>s.children??rn),fe(r,_)}let ia=0;var na=ve('<div role="option"> </div>'),ra=ve('<div><select><!></select> <button type="button" role="combobox" aria-haspopup="listbox"><span> </span></button> <div role="listbox" class="listbox svelte-1hwvamm" popover="manual" tabindex="-1"></div></div>');function xi(r,s){ki(s,!0);let e=Oe(s,"value",15),t=Oe(s,"size",3,"md"),i=Oe(s,"ghost",3,!1),n=Oe(s,"class",3,""),o=Oe(s,"style",3,""),u=fr(s,["$$slots","$$events","$$legacy","value","size","ghost","class","style","children"]);const l={xs:"calc(var(--tri-size-field,0.25rem)*6)",sm:"calc(var(--tri-size-field,0.25rem)*8)",md:"calc(var(--tri-size-field,0.25rem)*10)",lg:"calc(var(--tri-size-field,0.25rem)*12)"};let a=ae(()=>`--size:${l[t()]};${o()}`);const h=`tri-listbox-${ia++}`;let c=le(null),d=le(null),v=le(null),m=le(lt([])),_=le(!1),y=le(-1),E=ae(()=>!!s.disabled),S=ae(()=>e()==null?"":String(e())),P=ae(()=>b(m).find(z=>z.value===b(S))??b(m)[0]);function B(){b(c)&&G(m,Array.from(b(c).querySelectorAll("option")).map(z=>({value:z.value,label:(z.textContent??"").trim(),disabled:z.disabled})),!0)}Zt(()=>{if(!b(c))return;B();const z=new MutationObserver(()=>B());return z.observe(b(c),{childList:!0,subtree:!0,characterData:!0,attributes:!0}),()=>z.disconnect()});function O(z){const ie=b(m)[z];!b(c)||!ie||ie.disabled||(b(c).value=ie.value,b(c).dispatchEvent(new Event("input",{bubbles:!0})),b(c).dispatchEvent(new Event("change",{bubbles:!0})),Q())}function M(){if(!b(d)||!b(v))return;const z=b(d).getBoundingClientRect();b(v).style.minWidth=`${z.width}px`,b(v).style.left=`${z.left}px`;const ie=b(v).offsetHeight,ce=window.innerHeight-z.bottom;ce<ie&&z.top>ce?b(v).style.top=`${Math.max(4,z.top-ie-4)}px`:b(v).style.top=`${z.bottom+4}px`}function L(){b(v)?.children[b(y)]?.scrollIntoView({block:"nearest"})}function W(z){const ie=z.composedPath();b(d)&&ie.includes(b(d))||b(v)&&ie.includes(b(v))||Q()}function Y(){b(E)||b(_)||!b(v)||(G(_,!0),b(v).showPopover(),M(),G(y,b(m).findIndex(z=>z.value===b(S)),!0),b(y)<0&&G(y,b(m).findIndex(z=>!z.disabled),!0),L(),window.addEventListener("scroll",M,!0),window.addEventListener("resize",M),document.addEventListener("pointerdown",W,!0))}function Q(){b(_)&&(G(_,!1),b(v)?.hidePopover(),window.removeEventListener("scroll",M,!0),window.removeEventListener("resize",M),document.removeEventListener("pointerdown",W,!0),b(d)?.focus())}function ee(){b(_)?Q():Y()}function X(z){if(!b(m).length)return;let ie=b(y);for(let ce=0;ce<b(m).length;ce++)if(ie=(ie+z+b(m).length)%b(m).length,!b(m)[ie]?.disabled){G(y,ie,!0),L();return}}function ue(z){const ie=z==="start"?b(m).map((ce,we)=>we):b(m).map((ce,we)=>b(m).length-1-we);for(const ce of ie)if(!b(m)[ce]?.disabled){G(y,ce,!0),L();return}}let he="",de;function pe(z){he+=z.toLowerCase(),clearTimeout(de),de=setTimeout(()=>he="",600);const ie=b(m).findIndex(ce=>!ce.disabled&&ce.label.toLowerCase().startsWith(he));ie>=0&&(G(y,ie,!0),L())}function ge(z){if(!b(E)){if(!b(_)){["ArrowDown","ArrowUp","Enter"," "].includes(z.key)&&(z.preventDefault(),Y());return}switch(z.key){case"ArrowDown":z.preventDefault(),X(1);break;case"ArrowUp":z.preventDefault(),X(-1);break;case"Home":z.preventDefault(),ue("start");break;case"End":z.preventDefault(),ue("end");break;case"Enter":case" ":z.preventDefault(),b(y)>=0&&O(b(y));break;case"Escape":z.preventDefault(),Q();break;case"Tab":Q();break;default:z.key.length===1&&!z.metaKey&&!z.ctrlKey&&pe(z.key)}}}var me=ra(),Pe=J(me);ur(Pe,()=>({class:"native-select",tabindex:"-1","aria-hidden":"true",...u}),void 0,void 0,void 0,"svelte-1hwvamm");var Le=J(Pe);ir(Le,()=>s.children??rn),wi(Pe,z=>G(c,z),()=>b(c));var xe=ye(Pe,2);let Xe;xe.__click=ee,xe.__keydown=ge;var Z=J(xe);let $e;var ct=J(Z);wi(xe,z=>G(d,z),()=>b(d));var Ue=ye(xe,2);vi(Ue,23,()=>b(m),(z,ie)=>z.value+"\0"+ie,(z,ie,ce)=>{var we=na();let Ye;we.__click=()=>O(b(ce)),we.__pointermove=()=>G(y,b(ce),!0);var St=J(we);be(()=>{Ze(we,"id",`${h}-opt-${b(ce)??""}`),Ye=ei(we,1,"option svelte-1hwvamm",null,Ye,{active:b(ce)===b(y),selected:b(ie).value===b(S)}),Ze(we,"aria-selected",b(ie).value===b(S)),Ze(we,"aria-disabled",b(ie).disabled),_e(St,b(ie).label)}),fe(z,we)}),wi(Ue,z=>G(v,z),()=>b(v)),be(()=>{ei(me,1,`select-wrapper ${n()??""}`,"svelte-1hwvamm"),qi(me,o()),Xe=ei(xe,1,"select svelte-1hwvamm",null,Xe,{ghost:i(),open:b(_)}),qi(xe,b(a)),xe.disabled=b(E),Ze(xe,"aria-expanded",b(_)),Ze(xe,"aria-controls",h),Ze(xe,"aria-activedescendant",b(_)&&b(y)>=0?`${h}-opt-${b(y)}`:void 0),Ze(xe,"aria-label",u["aria-label"]),$e=ei(Z,1,"select-label svelte-1hwvamm",null,$e,{placeholder:b(P)?.disabled}),_e(ct,b(P)?.label??""),Ze(Ue,"id",h)}),ws(Pe,e),fe(r,me),Oi()}Kn(["click","keydown","pointermove"]);function Lt(r){var s,e;return r?.id||r?.["@id"]||((s=r?.__jsonld)==null?void 0:s.id)||((e=r?.__jsonld)==null?void 0:e["@id"])||(typeof r?.getId=="function"?r.getId():null)||null}function zt(r){return Lt(r)||(typeof r?.getCanvasId=="function"?r.getCanvasId():null)||(typeof r?.getId=="function"?r.getId():null)||""}function oa(r){var s;const e=r?.behavior||((s=r?.__jsonld)==null?void 0:s.behavior)||(typeof r?.getBehavior=="function"?r.getBehavior():[]);return e?(Array.isArray(e)?e:[e]).map(t=>{const i=String(t).trim().toLowerCase(),n=i.split(/[#/:]/);return n[n.length-1]||i}):[]}function wr(r){const s=oa(r);return s.includes("non-paged")||s.includes("facing-pages")}function sa(r,s){const e=[];for(let t=0;t<Math.min(s,r.length);t++){const i=r[t],n=zt(i);e.push({startIndex:t,endIndex:t,entries:n?[{canvasId:n,canvas:i}]:[]})}for(let t=s;t<r.length;){const i=r[t],n=zt(i),o=r[t+1],u=zt(o),l=!!o&&!!n&&!!u&&!wr(i)&&!wr(o);e.push({startIndex:t,endIndex:l?t+1:t,entries:[...n?[{canvasId:n,canvas:i}]:[],...l?[{canvasId:u,canvas:o}]:[]]}),t+=l?2:1}return e}function aa({canvases:r,currentCanvasId:s,currentCanvasIndex:e,viewingMode:t,pagedOffset:i}){if(!s)return[];if(e<0||e>=r.length)return[];const n=[],o=r[e];if(!o)return n;if(t!=="paged")return n.push({canvasId:s,canvas:o}),n;const u=sa(r,i).find(({startIndex:l,endIndex:a})=>e>=l&&e<=a);return u?.entries??n}function Ti(r,s){if(!r)return"";if(typeof r=="string")return r;if(typeof r=="object"&&!Array.isArray(r)){const e=r;if("@value"in e){const n=e["@value"];return Array.isArray(n)&&n.length>0?String(n[0]):n===void 0?"":String(n)}const t=Object.keys(e),i=n=>{const o=e[n];if(o!==void 0)return Array.isArray(o)&&o.length>0?String(o[0]):String(o)};for(const n of["en","none"]){const o=i(n);if(o!==void 0)return o}return t.length>0?i(t[0])??"":""}if(Array.isArray(r)&&r.length>0){if(typeof r[0]=="string")return r[0];const e=r,t=o=>o?.value??o?._value,i=(o=>e.find(u=>u.locale===o||u._locale===o||u.language===o))("en");{const o=t(i);if(o)return o}const n=e.find(o=>!o.locale&&!o._locale&&!o.language);{const o=t(n);if(o)return o}return t(e[0])??""}return String(r)}function yr(r,s){var e,t;const i=s===void 0?"Untitled canvas":`Canvas ${s+1}`;try{const o=(e=r.getLabel)==null?void 0:e.call(r);if(Array.isArray(o)&&o.length>0)return Ti(o)||i}catch{}const n=r.label||((t=r.__jsonld)==null?void 0:t.label);if(n){const o=Ti(n);if(o)return o}return i}function Xi(r){if(!r)return null;const s=r.match(/xywh=(?:pixel:)?([\d.]+),([\d.]+),([\d.]+),([\d.]+)/);return s?[Number(s[1]),Number(s[2]),Number(s[3]),Number(s[4])]:null}function la(r){const[s]=r.split("#");return s||null}function $i(r){if(!r)return null;if(typeof r=="string")return r;if(Array.isArray(r)){for(const e of r){const t=$i(e);if(t)return t}return null}if(typeof r!="object")return null;const s=r;return typeof s.id=="string"?s.id:typeof s["@id"]=="string"?s["@id"]:s.source?$i(s.source):null}function Yi(r){if(!r)return[];if(Array.isArray(r))return r.flatMap(e=>Yi(e));if(typeof r!="object")return[];const s=r;return s.item?Yi(s.item):[s]}function ua(r){const s=r.find(t=>t?.type==="FragmentSelector"&&typeof t?.value=="string"&&t.value.includes("xywh="));if(s)return Xi(s.value);const e=r.find(t=>typeof t?.value=="string"&&t.value.includes("xywh="));return e?Xi(e.value):null}function _r(r){if(!r)return[];if(Array.isArray(r))return r.flatMap(i=>_r(i));const s=$i(r),e=typeof r=="object"&&r&&"selector"in r?Yi(r.selector):[],t=ua(e)||(s?Xi(s):null);return[{raw:r,targetId:s,canvasId:s?la(s):null,selectors:e,xywh:t}]}function xr(r){return r.endsWith("/info.json")?r.slice(0,-10):r}function Ht(r){return typeof r=="number"&&Number.isFinite(r)&&r>0?r:null}function ha(r){const s=r?.__jsonld||r;return{width:Ht(r?.width)||Ht(s?.width)||(typeof r?.getWidth=="function"?Ht(r.getWidth()):null),height:Ht(r?.height)||Ht(s?.height)||(typeof r?.getHeight=="function"?Ht(r.getHeight()):null)}}function Tr(r){const s=r?.__jsonld||r;return s?.type==="SpecificResource"&&s!=null&&s.source?s.source:null}function ca(r,s){return s?.type==="Choice"||s?.type==="oa:Choice"||!!r&&!Array.isArray(r)&&(r.type==="Choice"||r.type==="oa:Choice")}function Er(r,s){return s&&(s.items||s.item)?s.items||s.item:Array.isArray(r)?r:r&&(r.items||r.item)?r.items||r.item:[]}function da({body:r,rawBody:s,canvasId:e,getSelectedChoice:t}){const i=Array.isArray(r)?r:Er(r,null),n=Er(null,s),o=t?.(e);if(o){const u=i.find(a=>Lt(a)===o);if(u)return u;const l=n.findIndex(a=>Lt(a)===o);if(l>=0)return i[l]||n[l]}return i[0]||n[0]||null}function pa(r){var s;let e=((s=r.getImages)==null?void 0:s.call(r))||[];return(!e||!e.length)&&r.getContent&&(e=r.getContent()),e||[]}function fa(r){var s,e;const t=r?.width||((s=r?.__jsonld)==null?void 0:s.width)||(typeof r?.getWidth=="function"?r.getWidth():null),i=r?.height||((e=r?.__jsonld)==null?void 0:e.height)||(typeof r?.getHeight=="function"?r.getHeight():null);return typeof t!="number"||typeof i!="number"?null:{width:t,height:i}}function ga(r){var s,e;const t=(e=_r(r?.target||((s=r?.__jsonld)==null?void 0:s.target)).find(i=>i.xywh))==null?void 0:e.xywh;return t?{x:t[0],y:t[1],width:t[2],height:t[3]}:null}function va(r,s){if(typeof r!="string"||!r.trim())return null;const e=r.trim(),t=e.startsWith("pct:"),i=(t?e.slice(4):e).split(",").map(n=>Number(n.trim()));return i.length!==4||i.some(n=>!Number.isFinite(n)||n<0)?null:t?typeof s.width!="number"||typeof s.height!="number"?null:{x:i[0]/100*s.width,y:i[1]/100*s.height,width:i[2]/100*s.width,height:i[3]/100*s.height}:{x:i[0],y:i[1],width:i[2],height:i[3]}}function ma(r,s){var e;const t=r?.__jsonld||r;return va(((e=t?.selector)==null?void 0:e.type)==="ImageApiSelector"?t.selector.region:null,s)}function wa(r){return[r.x,r.y,r.width,r.height].map(s=>Math.round(s)).join(",")}function ya(r){const s=r?.__jsonld||r,e=Tr(r);return!!(r&&(r.id||r["@id"]||s!=null&&s.service||e||s!=null&&s.id||s!=null&&s["@id"]))}function _a(r,s,e){var t;let i=r.getResource?r.getResource():null;if(!i&&r.getBody){const n=r.getBody(),o=((t=r.__jsonld)==null?void 0:t.body)||r.body;ca(n,o)?i=da({body:n,rawBody:o,canvasId:s,getSelectedChoice:e}):Array.isArray(n)&&n.length>0?i=n[0]:n&&(i=n)}if(i&&!ya(i)&&(i=null),!i){const n=r.__jsonld||r;if(n.body){let o=n.body;if(o.type==="Choice"||o.type==="oa:Choice"){const u=o.items||o.item||[],l=e?.(s);o=(l?u.find(a=>Lt(a)===l):null)||u[0]||null}i=Array.isArray(o)?o[0]:o}}return i}function br(r){return typeof r=="string"?/^https?:\/\/iiif\.io\/api\/image\//.test(r)||r==="level0"||r==="level1"||r==="level2":Array.isArray(r)?r.some(s=>br(s)):!1}function xa(r){return typeof r=="string"?r||null:Array.isArray(r)&&r.find(s=>typeof s=="string")||null}function Ta(r){let s=[];const e=r?.__jsonld||r;return e!=null&&e.service&&(s=Array.isArray(e.service)?e.service:[e.service]),!s.length&&r!=null&&r.getServices&&(s=r.getServices()),s.length&&s.find(t=>{const i=t.getType?t.getType():t.type||t["@type"]||"",n=t.getProfile?t.getProfile():t.profile||"";return i==="ImageService1"||i==="ImageService2"||i==="ImageService3"||br(n)})||null}function Ea(r,s){var e,t;for(const i of[r,s]){if(!i)continue;try{const o=(e=i.getLabel)==null?void 0:e.call(i);if(Array.isArray(o)&&o.length>0){const u=Ti(o);if(u)return u}}catch{}const n=i.label||((t=i.__jsonld)==null?void 0:t.label);if(n){const o=Ti(n);if(o)return o}}return null}function ba(r){const s=Ta(r),e=Lt(s),t=s?s.getProfile?s.getProfile():s.profile||"":null;return{serviceId:e?xr(e):null,serviceProfile:xa(t)}}function Sa(r){if(!r||!r.includes("/iiif/"))return null;const s=r.split("/"),e=s.findIndex(t=>t==="full"||/^\d+,\d+,\d+,\d+$/.test(t));return e>0?s.slice(0,e).join("/"):null}function Ei(r,s={}){const e=zt(r);if(!e)return[];const t=fa(r);if(!t)return[];const i=pa(r);return i.length?i.map(n=>{const o=_a(n,e,s.getSelectedChoice),u=Tr(o)||o;if(!u)return null;const l=Lt(u),a=ha(u),h=ba(u),c=h.serviceId||Sa(l),d=ga(n),v=ma(o,a);return{canvasId:e,annotation:n,resource:u,resourceId:l,label:Ea(u,n),canvasWidth:t.width,canvasHeight:t.height,resourceWidth:v?.width||a.width,resourceHeight:v?.height||a.height,serviceId:c,serviceProfile:h.serviceProfile,imageApiRegion:v,x:d?d.x/t.width:0,y:d?d.y/t.width:0,width:d?d.width/t.width:1}}).filter(n=>n!==null):[]}function Pa(r,s={width:1600}){const e=xr(r),t=s.region||"full",i=s.quality||"default",n=s.format||"jpg",o=typeof s.width=="number"?Math.max(1,Math.round(s.width)):null,u=typeof s.height=="number"?Math.max(1,Math.round(s.height)):null,l=s.size||(o?`${o},`:`,${u||1600}`);return`${e}/${t}/${l}/0/${i}.${n}`}function Ca(r){return typeof r=="string"?r:Array.isArray(r)&&typeof r[0]=="string"?r[0]:null}function bi(r){const s=Ca(r);return s?s==="level0"||s.endsWith("/level0.json")||s.endsWith("#level0"):!1}function Ra(r,s,e,t){var i;if(!((i=r?.IIIFTileSource)!=null&&i.prototype))return s;try{const n=r.IIIFTileSource.prototype.configure.call({},s,e,null),o=new r.IIIFTileSource(n);return Da(o,t),o}catch{return s}}function Da(r,s){if(!bi(r?.profile)||typeof r?.getTileUrl!="function"||r.__triiiceratopsLevel0LowZoomPrepared)return;const e=r.getTileUrl.bind(r),t=typeof r.getNumTiles=="function"?r.getNumTiles.bind(r):null,i=ka(),n=Aa(r),o=Ia(r,n,t);t&&(r.getNumTiles=function(u){return Pr(u,o,n,this)?{x:0,y:0}:Sr(this,u,i,n,t,o)?{x:1,y:1}:t(u)}),typeof r?.minLevel=="number"&&o>=0&&(r.minLevel=Math.max(r.minLevel,o)),r.getTileUrl=function(u,l,a){if(Pr(u,o,n,this)){const h=o>=0?o:u;return e(h,l,a)}return Sr(this,u,i,n,t,o)?Cr(this,u):e(u,l,a)},r.__triiiceratopsLevel0LowZoomPrepared=!0}function Sr(r,s,e,t,i,n){if(n>=0)return!1;if(!Ki(r,s,t))return!0;if(!i)return!1;const o=i(s);return o?.x===1&&o?.y===1}function Ia(r,s,e){if(!e||typeof r?.minLevel!="number"||typeof r?.maxLevel!="number"||s.size===0)return-1;for(let t=r.minLevel;t<=r.maxLevel;t++){if(!Ki(r,t,s))continue;const i=e(t);if(i?.x>1||i?.y>1)return t}return-1}function Pr(r,s,e,t){return s<0?!1:r<s?!0:!Ki(t,r,e)}function Aa(r){const s=new Set,e=r?.scale_factors;if(Array.isArray(e))for(const t of e)typeof t=="number"&&t>0&&s.add(t);return s}function Ki(r,s,e){if(e.size===0||typeof r?.maxLevel!="number"||typeof s!="number")return!0;const t=Math.pow(2,r.maxLevel-s);return e.has(t)}function ka(r,s){return-1}function Cr(r,s){const e=r.getLevelScale(s),t=Math.ceil(r.width*e),i=Math.ceil(r.height*e),n=r.version===3,o=bi(r?.profile),u=n?t===r.width&&i===r.height?"max":o?`${t},`:`${t},${i}`:t===r.width?"full":`${t},`,l=n?"default":"native";return`${r._id}/full/${u}/0/${l}.${r.tileFormat}`}const Si=8e3,Rr=4e7;function Oa(r,s,e,t){const i=Math.max(1,Math.round(r.width*s*t)),n=r.resourceWidth&&r.resourceHeight?r.resourceHeight/r.resourceWidth:e/s;return{x:Math.round(r.x*s*t),y:Math.round(r.y*e*t),width:i,height:Math.max(1,Math.round(i*n))}}function Ba(r,s){const e=URL.createObjectURL(r),t=document.createElement("a");t.href=e,t.download=s,document.body.appendChild(t),t.click(),t.remove(),URL.revokeObjectURL(e)}async function Qi(r,s){const e=await fetch(r,s);if(!e.ok)throw new Error(`Image request failed with ${e.status}.`);return e.blob()}async function Fa(r){const s=URL.createObjectURL(r);try{return await new Promise((e,t)=>{const i=new Image;i.onload=()=>e(i),i.onerror=()=>t(new Error("Unable to decode image for export.")),i.src=s})}finally{URL.revokeObjectURL(s)}}async function Dr(r,s,e,t="image/png"){const i=document.createElement("canvas");i.width=Math.max(1,Math.round(s)),i.height=Math.max(1,Math.round(e));const n=i.getContext("2d");if(!n)throw new Error("Unable to create a canvas for image export.");for(const o of r){const u=await Fa(o.blob);n.drawImage(u,o.x,o.y,o.width,o.height)}return new Promise((o,u)=>{i.toBlob(l=>{if(l){o(l);return}u(new Error("Unable to export composed image."))},t)})}function Ir(r,s){let e=1;r>Si&&(e=Math.min(e,Si/r)),s>Si&&(e=Math.min(e,Si/s));const t=r*s;return t*e*e>Rr&&(e=Math.min(e,Math.sqrt(Rr/t))),e>=1?{width:Math.round(r),height:Math.round(s),clamped:!1}:{width:Math.max(1,Math.round(r*e)),height:Math.max(1,Math.round(s*e)),clamped:!0}}function ni(r,s={}){if(bi(r.serviceProfile))return r.resourceId??null;if(r.serviceId){const e=r.imageApiRegion?wa(r.imageApiRegion):void 0,t=!!(s.width||s.height);return Pa(r.serviceId,{region:e,size:t?void 0:"max",width:s.width,height:s.height})}return r.resourceId??null}async function Ma(r){if(!r.serviceId)return[];const s=r.serviceId.endsWith("/info.json")?r.serviceId:`${r.serviceId}/info.json`;try{const e=await fetch(s);if(!e.ok)return[];const t=await e.json(),i=await Promise.resolve().then(()=>Dl).then(a=>a.o),n=i.default||i,o=Ra(n,t,s);if(!o||typeof o.minLevel!="number"||typeof o.maxLevel!="number"||typeof o.getLevelScale!="function")return[];const u=new Set,l=[];for(let a=o.minLevel;a<=o.maxLevel;a+=1){const h=o.getLevelScale(a),c=Math.ceil(o.width*h),d=Math.ceil(o.height*h),v=`${c}x${d}`;u.has(v)||(u.add(v),l.push({width:c,height:d,label:`${c} × ${d}px`,url:Cr(o,a)}))}return l.sort((a,h)=>h.width-a.width)}catch{return[]}}const La=[{fraction:1,label:"Original"},{fraction:.5,label:"50%"},{fraction:.25,label:"25%"}];function Ji(r,s,e){return La.map(({fraction:t,label:i})=>{const n=Math.max(1,Math.round(r*t)),o=Math.max(1,Math.round(s*t)),u=e?.({width:n,height:o,isOriginal:t===1});return{width:n,height:o,label:`${i} (${n} × ${o}px)`,url:u??void 0}}).filter(t=>!e||!!t.url)}function za(r){const s=r.resourceWidth,e=r.resourceHeight;if(!r.serviceId||!s||!e){const t=ni(r);return t?[{width:s??0,height:e??0,label:"Original",url:t}]:[]}return Ji(s,e,({width:t,height:i,isOriginal:n})=>ni(r,n?{}:{width:t,height:i}))}async function Ha(r){if(bi(r.serviceProfile)){const s=await Ma(r);return s.length?s:r.resourceId?[{width:r.resourceWidth??0,height:r.resourceHeight??0,label:"Original",url:r.resourceId}]:[]}return za(r)}const Na=.0125;function Ua(r){return!!r&&typeof r=="object"&&"tileSource"in r}function Ar(r,s){if(!r||typeof r!="object")return null;const e=r[s];return typeof e=="number"&&Number.isFinite(e)&&e>0?e:null}function Wa(r,s,e){return Math.min(e,Math.max(s,r))}function ja(r){const s=[...r].sort((t,i)=>t-i),e=Math.floor(s.length/2);return s.length%2===0?(s[e-1]+s[e])/2:s[e]}function Va(r){const s=new Map;return r.forEach((e,t)=>{const i=Ua(e),n=i?e.tileSource:e,o=i?e.canvasId??`canvas-${t}`:`canvas-${t}`,u=i?e.x??0:0,l=i?e.y??0:0,a=i?e.width??1:1,h=Ar(n,"width"),c=Ar(n,"height"),d=h&&c?a*c/h:null;let v=s.get(o);v||(v={canvasId:o,sources:[],width:0,height:null},s.set(o,v)),v.sources.push({source:e,tileSource:n,localX:u,localY:l,localWidth:a,localHeight:d}),v.width=Math.max(v.width,u+a),v.height=d===null?null:Math.max(v.height??0,l+d)}),[...s.values()]}function Ga(r){return{layouts:r.map(s=>({canvasId:s.canvasId,x:0,y:0,width:s.width,height:s.height??1})),sources:r.flatMap(s=>s.sources.map(({tileSource:e,localX:t,localY:i,localWidth:n})=>({tileSource:e,x:t,y:i,width:n,canvasId:s.canvasId})))}}function qa(r,s){const e=Va(r);if(s.mode==="individuals"||e.length<=1)return Ga(e);const t=!s.preserveCanvasScale&&e.every(o=>o.height!==null),i=t?ja(e.map(o=>o.height)):1,n=e.map(o=>{const u=t?Wa(i/o.height,.25,4):1;return{group:o,scale:u,width:o.width*u,height:(o.height??1)*u,x:0,y:0}});if(s.mode==="continuous"){let o=0;const u=s.direction==="top-to-bottom"||s.direction==="bottom-to-top",l=s.direction==="right-to-left"||s.direction==="bottom-to-top";for(const a of n)u?(a.y=l?-o:o,o+=(t?a.height:1)+s.gap):(a.x=l?-o:o,o+=(t?a.width:1)+s.gap)}else if(s.mode==="paged"){const o=Math.max(...n.map(l=>l.height)),u=s.direction==="right-to-left";n.forEach((l,a)=>{const h=u?n.slice(a+1):n.slice(0,a);l.x=h.reduce((c,d)=>c+(t?d.width:1)+s.gap,0),l.y=(o-l.height)/2})}return{layouts:n.map(o=>({canvasId:o.group.canvasId,x:o.x,y:o.y,width:o.width,height:o.height})),sources:n.flatMap(o=>o.group.sources.map(({tileSource:u,localX:l,localY:a,localWidth:h})=>({tileSource:u,x:o.x+l*o.scale,y:o.y+a*o.scale,width:h*o.scale,canvasId:o.group.canvasId})))}}function Za(r,s,e){Ys(r,"@triiiceratops/plugin-image-export","1.0.0-rc.0",s,e)}function Xa(r){return r.replace(/[^a-z0-9-_]+/gi,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function $a(r,s,e){const i=Xa(r)||"image",n=s==="single"?"":`-${s}`;return`${i}${n}.png`}function kr(r,s){return Ei(r,{getSelectedChoice:s})}function Ya(r){return Ha(r)}function Ka(r,s){const t=Ei(r,{getSelectedChoice:s})[0];return!t?.canvasWidth||!t?.canvasHeight?[]:Ji(t.canvasWidth,t.canvasHeight)}async function Qa(r,s){const e=s.url??ni(r,{width:s.width,height:s.height});if(!e)throw new Error("No exportable image found for this canvas.");return Qi(e)}async function Ja(r,s,e={}){const t=Ei(r,{getSelectedChoice:e.getSelectedChoice}),i=t[0];if(!i)throw new Error("No exportable image found for this canvas.");const{canvasWidth:n,canvasHeight:o}=i;if(!n||!o)throw new Error("Unable to determine canvas dimensions for export.");const{width:u,height:l}=Ir(s.width,s.height),a=u/n,h=await Promise.all(t.map(async c=>el(c,n,o,a)));return Dr(h,u,l,e.format??"image/png")}async function el(r,s,e,t){const i=Oa(r,s,e,t),n=ni(r,{width:i.width});if(!n)throw new Error("No exportable image found for this canvas.");return{blob:await Qi(n),...i}}function Or(r){return aa({canvases:r.canvases,currentCanvasId:r.canvasId,currentCanvasIndex:r.currentCanvasIndex,viewingMode:r.viewingMode,pagedOffset:r.pagedOffset}).map(s=>s.canvas)}function Br(r,s){const e=Or(r);if(!e.length)return null;const t=e.flatMap((c,d)=>{const v=zt(c)??`canvas-${d}`;return Ei(c,{getSelectedChoice:s}).map(m=>({canvasId:v,x:m.x,y:m.y,width:m.width,tileSource:{width:m.resourceWidth||m.canvasWidth,height:m.resourceHeight||m.canvasHeight,resolved:m}}))});if(!t.length)return null;const{layouts:i,sources:n}=qa(t,{mode:r.viewingMode,direction:r.viewingDirection,preserveCanvasScale:r.preserveCanvasScale,gap:Na});if(!i.length)return null;const o=Math.min(...i.map(c=>c.x)),u=Math.min(...i.map(c=>c.y)),l=Math.max(...i.map(c=>c.x+c.width)),a=Math.max(...i.map(c=>c.y+c.height));return{entries:n.map(c=>({resolved:c.tileSource.resolved,x:c.x-o,y:c.y-u,width:c.width})),worldWidth:l-o,worldHeight:a-u}}function tl(r,s){const e=Br(r,s);if(!e)return[];const t=e.entries[0],i=t?.resolved.resourceWidth&&t.width>0?t.resolved.resourceWidth/t.width:1600,n=Math.round(e.worldWidth*i),o=Math.round(e.worldHeight*i);return!n||!o?[]:Ji(n,o)}async function il(r,s,e={}){const t=Br(r,e.getSelectedChoice);if(!t)throw new Error("Nothing is currently displayed in the viewer.");const{width:i,height:n}=Ir(s.width,s.height),o=i/t.worldWidth,u=await Promise.all(t.entries.map(async({resolved:l,x:a,y:h,width:c})=>{const d=Math.max(1,Math.round(c*o)),v=l.resourceWidth&&l.resourceHeight?l.resourceHeight/l.resourceWidth:1,m=Math.max(1,Math.round(d*v)),_=ni(l,{width:d});if(!_)throw new Error("No exportable image found for the current view.");return{blob:await Qi(_),x:Math.round(a*o),y:Math.round(h*o),width:d,height:m}}));return Dr(u,i,n,e.format??"image/png")}var nl=ve("<option> </option>"),rl=ve("<option> </option>"),ol=ve("<!> <option> </option> <!>",1),sl=ve('<div class="tri-id-field"><label class="tri-id-label" for="tri-id-mode"><span> </span></label> <!></div>'),al=ve("<option> </option>"),ll=ve('<div class="tri-id-field"><label class="tri-id-label" for="tri-id-canvas"><span> </span></label> <!></div>'),ul=ve("<option> </option>"),hl=ve('<div class="tri-id-field"><label class="tri-id-label" for="tri-id-image"><span> </span></label> <!></div>'),cl=ve("<option> </option>"),dl=ve("<option disabled> </option> <!>",1),pl=ve('<div class="tri-id-alert is-success" data-tri-id-result=""><span> </span></div>'),fl=ve('<div class="tri-id-alert is-error" data-tri-id-error=""><span> </span></div>'),gl=ve('<div class="tri-id-alert"><span> </span></div>'),vl=ve('<div class="tri-id-card"><div class="tri-id-card-body"><!> <!> <!></div></div>'),ml=ve('<span aria-hidden="true"></span> ',1),wl=ve('<div class="tri-id" data-tri-id="" data-panel-id="image-download"><div class="tri-id-body"><p class="tri-id-desc"> </p> <div class="tri-id-fields"><!> <!> <!> <div class="tri-id-field"><label class="tri-id-label" for="tri-id-resolution"><span> </span></label> <!></div></div> <!></div> <div class="tri-id-footer"><!></div></div>');function yl(r,s){ki(s,!0);const{context:e}=xo(vr),{viewerState:t,selectors:i,locale:n,ui:o}=e;let u=le(0),l=le(0);i.select(A=>[A.canvasId,A.currentCanvasIndex,A.canvases,A.viewingMode,A.viewingDirection,A.pagedOffset,A.preserveCanvasScale]).subscribe(()=>{Tn(u)}),n.subscribe(()=>{Tn(l)});const a=(A,D)=>(b(l),n.t(A,D));let h=le("single"),c=le(0),d=le(0),v=le(lt([])),m=le(null),_=le(!1),y=le(!1),E=le(""),S=le(""),P=le(null);const B=A=>t.getSelectedChoice(A),O=ae(()=>(b(u),t.currentCanvasIndex>=0?t.canvases[t.currentCanvasIndex]??null:null)),M=ae(()=>(b(u),b(O)?kr(b(O),B):[])),L=ae(()=>b(M).length>1),W=ae(()=>b(L)),Y=ae(()=>(b(u),Or(t))),Q=ae(()=>b(Y).length>1),ee=ae(()=>b(Q)),X=ae(()=>b(W)||b(ee)),ue=ae(()=>(b(u),b(h)==="single"&&b(Q)?b(Y)[b(c)]??b(O):b(O))),he=ae(()=>(b(u),b(ue)?kr(b(ue),B):[])),de=ae(()=>b(he).length>1),pe=ae(()=>b(m)!==null?b(v)[b(m)]??null:null),ge=ae(()=>!b(y)&&!b(_)&&!!b(O)&&!!b(pe)),me=ae(()=>(b(l),b(O)?!b(_)&&!b(v).length?a("image_download_disabled_no_resolution"):null:a("image_download_disabled_no_canvas")));Zt(()=>{(b(h)==="composite"&&!b(W)||b(h)==="world"&&!b(ee))&&G(h,"single")}),Zt(()=>{b(u);const A=t.canvasId,D=b(Y).findIndex(H=>zt(H)===A);G(c,D>=0?D:0,!0)}),Zt(()=>{b(ue),G(d,0)}),Zt(()=>{const A=b(O),D=b(h),H=b(d);let V=!1;if(G(v,[],!0),G(m,null),!!A){if(D==="single"){const q=b(he)[H];if(!q)return;G(_,!0),Ya(q).then(U=>{V||(G(v,U,!0),G(m,U.length?0:null,!0))}).finally(()=>{V||G(_,!1)})}else if(D==="composite"){const q=Ka(A,B);G(v,q,!0),G(m,q.length?0:null,!0)}else{const q=tl(t,B);G(v,q,!0),G(m,q.length?0:null,!0)}return()=>{V=!0}}});function Pe(A){const D=Number(A);return Number.isInteger(D)?D:0}async function Le(){if(!(!b(O)||!b(pe)||!b(ge))){G(y,!0),G(E,""),G(S,"");try{let A,D=b(O);if(b(h)==="single"){D=b(ue);const V=b(he)[b(d)];if(!V)return;A=await Qa(V,b(pe))}else b(h)==="composite"?A=await Ja(b(O),b(pe),{getSelectedChoice:B}):A=await il(t,b(pe),{getSelectedChoice:B});const H=$a(yr(D,t.currentCanvasIndex),b(h),"image/png");Ba(A,H),G(S,a("image_download_result_downloaded",{filename:H}),!0)}catch(A){G(E,a("image_download_error_failed"),!0),b(P)&&Za(b(P),A,()=>void Le())}finally{G(y,!1)}}}function xe(A){return{destroy:o.renderIcon(mr,A)}}var Xe=wl(),Z=J(Xe),$e=J(Z),ct=J($e),Ue=ye($e,2),z=J(Ue);{var ie=A=>{var D=sl(),H=J(D),V=J(H),q=J(V),U=ye(H,2);{let $=ae(()=>a("image_download_mode"));xi(U,{id:"tri-id-mode",class:"tri-id-field-select","data-tri-id-mode":!0,get"aria-label"(){return b($)},get disabled(){return b(y)},get value(){return b(h)},onchange:g=>{G(h,g.currentTarget.value,!0)},children:(g,f)=>{var w=ol(),T=Gt(w);{var R=oe=>{var re=nl(),Ke=J(re);re.value=re.__value="composite",be(Wt=>_e(Ke,Wt),[()=>a("image_download_mode_composite")]),fe(oe,re)};ot(T,oe=>{b(W)&&oe(R)})}var I=ye(T,2),N=J(I);I.value=I.__value="single";var K=ye(I,2);{var j=oe=>{var re=rl(),Ke=J(re);re.value=re.__value="world",be(Wt=>_e(Ke,Wt),[()=>a("image_download_mode_world")]),fe(oe,re)};ot(K,oe=>{b(ee)&&oe(j)})}be(oe=>_e(N,oe),[()=>a("image_download_mode_single")]),fe(g,w)},$$slots:{default:!0}})}be($=>_e(q,$),[()=>a("image_download_mode")]),fe(A,D)};ot(z,A=>{b(X)&&A(ie)})}var ce=ye(z,2);{var we=A=>{var D=ll(),H=J(D),V=J(H),q=J(V),U=ye(H,2);{let $=ae(()=>a("image_download_canvas"));xi(U,{id:"tri-id-canvas",class:"tri-id-field-select",get"aria-label"(){return b($)},get disabled(){return b(y)},get value(){return b(c)},onchange:g=>{G(c,Pe(g.currentTarget.value),!0)},children:(g,f)=>{var w=Jn(),T=Gt(w);vi(T,17,()=>b(Y),Wi,(R,I,N)=>{var K=al(),j=J(K);K.value=K.__value=N,be(oe=>_e(j,oe),[()=>yr(b(I),N)]),fe(R,K)}),fe(g,w)},$$slots:{default:!0}})}be($=>_e(q,$),[()=>a("image_download_canvas")]),fe(A,D)};ot(ce,A=>{b(h)==="single"&&b(Q)&&A(we)})}var Ye=ye(ce,2);{var St=A=>{var D=hl(),H=J(D),V=J(H),q=J(V),U=ye(H,2);{let $=ae(()=>a("image_download_image"));xi(U,{id:"tri-id-image",class:"tri-id-field-select",get"aria-label"(){return b($)},get disabled(){return b(y)},get value(){return b(d)},onchange:g=>{G(d,Pe(g.currentTarget.value),!0)},children:(g,f)=>{var w=Jn(),T=Gt(w);vi(T,17,()=>b(he),Wi,(R,I,N)=>{var K=ul(),j=J(K);K.value=K.__value=N,be(oe=>_e(j,oe),[()=>b(I).label??`${a("image_download_image")} ${N+1}`]),fe(R,K)}),fe(g,w)},$$slots:{default:!0}})}be($=>_e(q,$),[()=>a("image_download_image")]),fe(A,D)};ot(Ye,A=>{b(h)==="single"&&b(de)&&A(St)})}var Nt=ye(Ye,2),Ut=J(Nt),Pt=J(Ut),dt=J(Pt),p=ye(Ut,2);{let A=ae(()=>a("image_download_resolution")),D=ae(()=>b(y)||b(_)||!b(v).length),H=ae(()=>b(m)??"");xi(p,{id:"tri-id-resolution",class:"tri-id-field-select","data-tri-id-resolution":!0,get"aria-label"(){return b(A)},get disabled(){return b(D)},get value(){return b(H)},onchange:V=>{G(m,Pe(V.currentTarget.value),!0)},children:(V,q)=>{var U=dl(),$=Gt(U),g=J($);$.value=$.__value="";var f=ye($,2);vi(f,17,()=>b(v),Wi,(w,T,R)=>{var I=cl(),N=J(I);I.value=I.__value=R,be(()=>_e(N,b(T).label)),fe(w,I)}),be(w=>_e(g,w),[()=>a("image_download_resolution_placeholder")]),fe(V,U)},$$slots:{default:!0}})}var x=ye(Ue,2);{var C=A=>{var D=vl(),H=J(D),V=J(H);{var q=w=>{var T=pl(),R=J(T),I=J(R);be(()=>_e(I,b(S))),fe(w,T)};ot(V,w=>{b(S)&&w(q)})}var U=ye(V,2);{var $=w=>{var T=fl(),R=J(T),I=J(R);be(()=>_e(I,b(E))),fe(w,T)};ot(U,w=>{b(E)&&w($)})}var g=ye(U,2);{var f=w=>{var T=gl(),R=J(T),I=J(R);be(()=>_e(I,b(me))),fe(w,T)};ot(g,w=>{b(me)&&w(f)})}fe(A,D)};ot(x,A=>{(b(S)||b(E)||b(me))&&A(C)})}var k=ye(Z,2),F=J(k);{let A=ae(()=>!b(ge));ta(F,{variant:"primary",class:"tri-id-download","data-tri-id-download":!0,style:"width:100%",get disabled(){return b(A)},onclick:Le,children:(D,H)=>{var V=ml(),q=Gt(V);ds(q,$=>xe?.($));var U=ye(q);be($=>_e(U,` ${$??""}`),[()=>b(y)?a("image_download_downloading"):a("image_download_download")]),fe(D,V)},$$slots:{default:!0}})}wi(Xe,A=>G(P,A),()=>b(P)),be((A,D)=>{_e(ct,A),_e(dt,D)},[()=>a("image_download_description"),()=>a("image_download_resolution")]),fe(r,Xe),Oi()}const{STYLES:_l,STYLE_ID:xl}=$s(`
5
+ Update the plugin or the core viewer so their declared ranges and capabilities overlap.`}function ks(r,s){const e=[];gr(s.coreVersion,r.coreRange)||e.push({kind:"core",required:r.coreRange,actual:s.coreVersion,message:`requires core ${r.coreRange} but this viewer is core ${s.coreVersion}`}),gr(s.pluginApiVersion,r.pluginApiRange)||e.push({kind:"pluginApi",required:r.pluginApiRange,actual:s.pluginApiVersion,message:`requires plugin API ${r.pluginApiRange} but this viewer provides plugin API ${s.pluginApiVersion}`});const t=new Set(s.capabilities);for(const i of r.requiredCapabilities)t.has(i)||e.push({kind:"capability",required:i,actual:s.capabilities.join(", ")||"(none)",message:`requires capability "${i}" which this viewer does not provide (has: ${s.capabilities.join(", ")||"none"})`});return e}function Os(r,s){const e=ks(r,s);if(e.length>0)throw new Zi(r.name,r.version,e)}function Bs(r,s={}){let e=0,t=!1;const i=new Set,n=r.subscribe(()=>{e++;for(const u of[...i])u()},s.onListenerError);return{selectors:{select(u,l=Object.is){let a=-1,h;const c=()=>(a!==e&&(h=u(r),a=e),h);return{get:c,subscribe(d){if(t)return()=>{};let v=c();const m=()=>{let _;try{_=c()}catch(y){s.onProjectionError?.(y);return}l(v,_)||(v=_,d(_))};return i.add(m),()=>{i.delete(m)}}}}},dispose(){t||(t=!0,i.clear(),n())}}}const Mt=()=>{};function Fs(){return{install(r,s){return Mt}}}function Ms(){return{current:"en",t(r,s){return r},subscribe(r){return Mt}}}function Ls(){return{renderIcon(r,s){return Mt}}}function zs(r){return{id:r??"",isOpen:!0,target:"panel",open:Mt,close:Mt,toggle:Mt}}function Hs(r){const s=new Set;return{service:{install(e,t){const i=r.install(e,t);let n=!1;const o=()=>{n||(n=!0,s.delete(o),i())};return s.add(o),o}},releaseAll(){for(const e of[...s])e();s.clear()}}}function Ns(r){const s=new Set;return{service:{get current(){return r.current},t(e,t){return r.t(e,t)},subscribe(e){const t=r.subscribe(e);let i=!1;const n=()=>{i||(i=!0,s.delete(n),t())};return s.add(n),n}},releaseAll(){for(const e of[...s])e();s.clear()}}}const Us={deactivate(){}};function Ws(r,s){const e=s.reportError;let t,i,n,o;try{Os(r,s),t=Bs(s.viewerState,{onProjectionError:e?d=>e({phase:"command",error:d}):void 0,onListenerError:e?d=>e({phase:"subscription",error:d}):void 0}),i=Hs(s.styles??Fs()),n=Ns(s.locale??Ms()),o={viewerState:s.viewerState,selectors:t.selectors,surface:s.surface??zs(r.uiId??r.name),styles:i.service,locale:n.service,ui:s.ui??Ls()}}catch(d){if(t?.dispose(),i?.releaseAll(),n?.releaseAll(),e)return e({phase:"setup",error:d}),Us;throw d}const u=[],l=i,a=n,h=t;try{const d=r.view.mount(s.container,o);typeof d=="function"&&u.push(d)}catch(d){if(!e)throw l.releaseAll(),a.releaseAll(),h.dispose(),d;e({phase:"mount",error:d})}u.push(()=>l.releaseAll()),u.push(()=>a.releaseAll()),u.push(()=>h.dispose());let c=!1;return{deactivate(){if(!c){c=!0;for(let d=u.length-1;d>=0;d--)try{u[d]?.()}catch(v){e?e({phase:"cleanup",error:v}):console.error(`[triiiceratops] Plugin "${r.name}" cleanup threw during deactivation; teardown continues.`,v)}u.length=0}}}}const js="triiiceratops-plugin";function Vs(r){const s={name:r.name,title:r.title,uiId:r.uiId,version:r.version,coreRange:r.coreRange,pluginApiRange:r.pluginApiRange,requiredCapabilities:r.requiredCapabilities??[],icon:r.icon,target:r.target??"panel",dismiss:r.dismiss,catalog:r.catalog,view:r.view};return{kind:js,...s,activate(e){return Ws(s,e)}}}class Gs extends Error{name="SvgIconError";constructor(s){super(`svgIcon: ${s}`)}}const qs="0 0 24 24";function bt(r,s){if(!r)throw new Gs(s)}const Zs=/<svg\b[^>]*>/i;function Xs(r){bt(typeof r=="string","expected an SVG string.");const s=r.trim();bt(s.length>0,"received an empty string.");const e=Zs.exec(s);bt(e!==null,"the markup must contain an <svg> root element."),bt(!/<script[\s/>]/i.test(s),"<script> elements are not allowed in plugin icons."),bt(!/<foreignObject[\s/>]/i.test(s),"<foreignObject> is not allowed in plugin icons."),bt(!/\son[a-z]+\s*=/i.test(s),"on* event-handler attributes (e.g. onload, onclick) are not allowed in plugin icons.");for(const u of s.matchAll(/(?:xlink:)?href\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+))/gi)){const l=(u[1]??u[2]??u[3]??"").trim();bt(l.startsWith("#"),`external href/xlink:href URLs are not allowed in plugin icons (found "${l}"); only internal "#id" references are.`)}const t=e[0],i=/\bviewBox\s*=\s*(?:"([^"]*)"|'([^']*)')/i.exec(t);let n=(i?.[1]??i?.[2])?.trim();if(!n){const u=/\bwidth\s*=\s*(?:"([^"]*)"|'([^']*)')/i.exec(t),l=/\bheight\s*=\s*(?:"([^"]*)"|'([^']*)')/i.exec(t),a=parseFloat(u?.[1]??u?.[2]??""),h=parseFloat(l?.[1]??l?.[2]??"");n=Number.isFinite(a)&&Number.isFinite(h)?`0 0 ${a} ${h}`:qs}let o="";if(!/\/\s*>$/.test(t)){const u=e.index+t.length,l=s.lastIndexOf("</svg>");o=(l>=u?s.slice(u,l):s.slice(u)).trim()}return{kind:"svg",inner:o,viewBox:n}}function $s(r,s){return{STYLES:r,STYLE_ID:s}}function Ys(r,s,e,t,i){const n={pluginName:s,pluginVersion:e,phase:"command",error:t,retry:i};r.dispatchEvent(new CustomEvent("pluginerror",{detail:n,bubbles:!0,composed:!0}))}const Ks=".btn.svelte-sgoebi{display:inline-flex;flex-wrap:nowrap;flex-shrink:0;justify-content:center;align-items:center;gap:.375rem;cursor:pointer;text-align:center;vertical-align:middle;user-select:none;-webkit-user-select:none;touch-action:manipulation;font-weight:600;height:var(--size);padding-inline:var(--btn-p);font-size:var(--fontsize, .875rem);color:var(--btn-fg);background-color:var(--btn-bg);border-width:var(--tri-border);border-style:solid;border-color:var(--btn-border);border-start-start-radius:var(--join-ss, var(--tri-radius-buttons));border-start-end-radius:var(--join-se, var(--tri-radius-buttons));border-end-end-radius:var(--join-ee, var(--tri-radius-buttons));border-end-start-radius:var(--join-es, var(--tri-radius-buttons));outline-offset:2px;outline-color:var(--btn-color, var(--tri-content));text-shadow:0 .5px oklch(100% 0 0 / calc(var(--tri-depth) * .15));box-shadow:0 .5px 0 .5px oklch(100% 0 0 / calc(var(--tri-depth) * 6%)) inset,var(--btn-shadow);transition-property:color,background-color,border-color,box-shadow;transition-duration:.2s;transition-timing-function:cubic-bezier(0,0,.2,1);--size: calc(var(--tri-size-field, .25rem) * 10);--btn-bg: var(--btn-color, var(--tri-toolbar-bg));--btn-fg: var(--tri-content);--btn-p: 1rem;--btn-border: color-mix( in oklab, var(--btn-bg), #000 calc(var(--tri-depth) * 5%) );--btn-shadow: 0 3px 2px -2px color-mix( in oklab, var(--btn-bg) calc(var(--tri-depth) * 30%), #0000 ), 0 4px 3px -2px color-mix( in oklab, var(--btn-bg) calc(var(--tri-depth) * 30%), #0000 )}@media(hover:hover){.btn.svelte-sgoebi:hover{--btn-bg: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 7% )}}.btn.svelte-sgoebi:focus-visible{isolation:isolate;outline-width:2px;outline-style:solid}.btn.svelte-sgoebi:active:not(.active){--btn-bg: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 5% );--btn-border: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 7% );--btn-shadow: 0 0 0 0 oklch(0% 0 0 / 0), 0 0 0 0 oklch(0% 0 0 / 0);translate:0 .5px}.btn.active.svelte-sgoebi{--btn-bg: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 7% )}.btn.svelte-sgoebi:disabled,.btn[disabled].svelte-sgoebi{pointer-events:none;--btn-border: #0000;--btn-fg: color-mix(in oklch, var(--tri-content) 20%, #0000)}.btn.svelte-sgoebi:disabled:not(.ghost):not(.outline),.btn[disabled].svelte-sgoebi:not(.ghost):not(.outline){background-color:color-mix(in oklab,var(--tri-content) 10%,transparent);box-shadow:none}.circle.svelte-sgoebi{width:var(--size);height:var(--size);border-radius:3.40282e38px;padding-inline:0}.square.svelte-sgoebi{width:var(--size);height:var(--size);padding-inline:0}.ghost.svelte-sgoebi{--btn-bg: transparent;--btn-border: transparent;--btn-fg: var(--btn-color-text, var(--btn-color, var(--tri-content)));box-shadow:none;text-shadow:none}@media(hover:hover){.ghost.svelte-sgoebi:hover{--btn-bg: color-mix(in oklab, var(--tri-content) 10%, transparent)}}.ghost.svelte-sgoebi:active:not(.active),.ghost.active.svelte-sgoebi{--btn-bg: color-mix(in oklab, var(--tri-content) 10%, transparent);--btn-border: transparent}.outline.svelte-sgoebi:not(:hover):not(:active):not(:focus-visible):not(.active):not(:disabled):not([disabled]){--btn-bg: transparent;--btn-fg: var(--btn-color-text, var(--btn-color, var(--tri-content)));--btn-border: var(--btn-color, var(--tri-content));box-shadow:none;text-shadow:none}.select-wrapper.svelte-1hwvamm{display:inline-flex;width:clamp(3rem,20rem,100%);max-width:100%}.native-select.svelte-1hwvamm{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0;pointer-events:none}.select.svelte-1hwvamm{border:var(--tri-border) solid var(--input-color);appearance:none;background-color:var(--tri-input-bg);vertical-align:middle;width:100%;height:var(--size);touch-action:manipulation;white-space:nowrap;box-shadow:0 1px color-mix(in oklab,var(--input-color) calc(var(--tri-depth) * 10%),#0000) inset,0 -1px oklch(100% 0 0 / calc(var(--tri-depth) * .1)) inset;--input-color: color-mix(in oklab, var(--tri-content) 20%, #0000);--size: calc(var(--tri-size-field, .25rem) * 10);background-image:linear-gradient(45deg,#0000 50%,currentColor 50%),linear-gradient(135deg,currentColor 50%,#0000 50%);background-position:calc(100% - 20px) calc(1px + 50%),calc(100% - 16.1px) calc(1px + 50%);background-repeat:no-repeat;background-size:4px 4px,4px 4px;border-start-start-radius:var(--join-ss, var(--tri-radius-buttons));border-start-end-radius:var(--join-se, var(--tri-radius-buttons));border-end-end-radius:var(--join-ee, var(--tri-radius-buttons));border-end-start-radius:var(--join-es, var(--tri-radius-buttons));align-items:center;gap:.375rem;padding-inline:.75rem 1.75rem;font-size:.875rem;display:inline-flex;position:relative;cursor:pointer;color:inherit;text-align:start}.select-label.svelte-1hwvamm{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.select-label.placeholder.svelte-1hwvamm{color:color-mix(in oklab,var(--tri-content) 55%,transparent)}.select.svelte-1hwvamm:hover:not(:disabled){--input-color: color-mix(in oklab, var(--tri-content) 40%, #0000)}.select.svelte-1hwvamm:focus-visible,.select.open.svelte-1hwvamm{--input-color: var(--tri-content);box-shadow:0 1px color-mix(in oklab,var(--input-color) calc(var(--tri-depth) * 10%),#0000);outline:2px solid var(--input-color);outline-offset:2px;isolation:isolate;z-index:1}.select.svelte-1hwvamm:is(:where(.svelte-1hwvamm):disabled,[disabled]:where(.svelte-1hwvamm)){cursor:not-allowed;border-color:var(--tri-panel-bg);background-color:var(--tri-panel-bg);color:color-mix(in oklab,var(--tri-content) 40%,transparent)}.ghost.svelte-1hwvamm{box-shadow:none;background-color:#0000;border-color:#0000;transition:background-color .2s}.ghost.svelte-1hwvamm:hover:not(:disabled){background-color:color-mix(in oklab,var(--tri-content) 8%,transparent)}.ghost.svelte-1hwvamm:focus-visible,.ghost.open.svelte-1hwvamm{background-color:var(--tri-input-bg);color:var(--tri-content)}.listbox.svelte-1hwvamm{position:fixed;inset:auto;margin:0;padding:.1875rem;border:var(--tri-border) solid color-mix(in oklab,var(--tri-content) 20%,#0000);background-color:var(--tri-input-bg);color:var(--tri-content);border-radius:var(--tri-radius-buttons);box-shadow:0 8px 24px oklch(0 0 0 / calc(.12 + var(--tri-depth) * .06));max-height:16rem;overflow-y:auto;min-width:8rem;z-index:1}.listbox.svelte-1hwvamm:not(:popover-open){display:none}.option.svelte-1hwvamm{padding:.25rem .5rem;border-radius:calc(var(--tri-radius-buttons) * .6);cursor:pointer;font-size:.8125rem;line-height:1.3;white-space:nowrap;color:inherit}.option.active.svelte-1hwvamm{background-color:color-mix(in oklab,var(--tri-content) 12%,#0000)}.option.selected.svelte-1hwvamm{background-color:color-mix(in oklab,var(--tri-color-primary) 90%,#0000);color:var(--tri-color-primary-content)}.option.selected.active.svelte-1hwvamm{background-color:var(--tri-color-primary)}.option[aria-disabled=true].svelte-1hwvamm{opacity:.5;cursor:not-allowed;color:color-mix(in oklab,var(--tri-content) 55%,transparent)}\n",Qs={en:{image_download_title:"Download Image",image_download_close:"Close Download Image",image_download_description:"Download the current canvas as an image.",image_download_mode:"What to download",image_download_mode_composite:"Composite canvas",image_download_mode_composite_hint:"Every image on the current canvas, composited together.",image_download_mode_single:"Single image",image_download_mode_single_hint:"One image from the current canvas.",image_download_mode_world:"Current view",image_download_mode_world_hint:"Everything currently laid out together in the viewer.",image_download_canvas:"Canvas",image_download_image:"Image",image_download_resolution:"Resolution",image_download_resolution_placeholder:"Select a resolution",image_download_downloading:"Downloading...",image_download_download:"Download",image_download_disabled_no_canvas:"Load a manifest to download an image.",image_download_disabled_no_resolution:"Select a resolution to download.",image_download_result_downloaded:"Downloaded {filename}.",image_download_error_failed:"Unable to download image. Check the browser console for details."},de:{image_download_title:"Bild herunterladen",image_download_close:"Bild-Download schließen",image_download_description:"Die aktuelle Leinwand als Bild herunterladen.",image_download_mode:"Was heruntergeladen werden soll",image_download_mode_composite:"Zusammengesetzte Leinwand",image_download_mode_composite_hint:"Alle Bilder der aktuellen Leinwand, zusammengesetzt.",image_download_mode_single:"Einzelbild",image_download_mode_single_hint:"Ein Bild von der aktuellen Leinwand.",image_download_mode_world:"Aktuelle Ansicht",image_download_mode_world_hint:"Alles, was aktuell zusammen im Viewer angezeigt wird.",image_download_canvas:"Leinwand",image_download_image:"Bild",image_download_resolution:"Auflösung",image_download_resolution_placeholder:"Auflösung auswählen",image_download_downloading:"Wird heruntergeladen...",image_download_download:"Herunterladen",image_download_disabled_no_canvas:"Laden Sie ein Manifest, um ein Bild herunterzuladen.",image_download_disabled_no_resolution:"Wählen Sie eine Auflösung zum Herunterladen aus.",image_download_result_downloaded:"{filename} heruntergeladen.",image_download_error_failed:"Bild kann nicht heruntergeladen werden. Details in der Browserkonsole."}},vr=Symbol("triiiceratops:plugin-image-download"),mr=Xs('<svg viewBox="0 0 256 256"><path d="M224,144v64a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V144a8,8,0,0,1,16,0v56H208V144a8,8,0,0,1,16,0Zm-101.66,5.66a8,8,0,0,0,11.32,0l40-40a8,8,0,0,0-11.32-11.32L136,124.69V32a8,8,0,0,0-16,0v92.69L93.66,98.34a8,8,0,0,0-11.32,11.32Z"/></svg>'),Js="5";typeof window<"u"&&((window.__svelte??={}).v??=new Set).add(Js);var ea=ve("<button><!></button>");function ta(r,s){let e=Oe(s,"variant",3,"default"),t=Oe(s,"size",3,"md"),i=Oe(s,"circle",3,!1),n=Oe(s,"square",3,!1),o=Oe(s,"ghost",3,!1),u=Oe(s,"outline",3,!1),l=Oe(s,"active",3,!1),a=Oe(s,"class",3,""),h=Oe(s,"style",3,""),c=fr(s,["$$slots","$$events","$$legacy","variant","size","circle","square","ghost","outline","active","class","style","children"]);const d={default:"",primary:"--btn-color:var(--tri-color-primary);--btn-color-text:var(--tri-color-primary-text);--btn-fg:var(--tri-color-primary-content);",neutral:"--btn-color:var(--tri-color-neutral);--btn-fg:var(--tri-color-neutral-content);",success:"--btn-color:var(--tri-color-success);--btn-fg:var(--tri-color-success-content);",warning:"--btn-color:var(--tri-color-warning);--btn-fg:var(--tri-color-warning-content);",error:"--btn-color:var(--tri-color-error);--btn-fg:var(--tri-color-error-content);"},v={xs:"--fontsize:0.6875rem;--btn-p:0.5rem;--size:calc(var(--tri-size-field,0.25rem)*6);",sm:"--fontsize:0.75rem;--btn-p:0.75rem;--size:calc(var(--tri-size-field,0.25rem)*8);",md:"--fontsize:0.875rem;--btn-p:1rem;--size:calc(var(--tri-size-field,0.25rem)*10);",lg:"--fontsize:1.125rem;--btn-p:1.25rem;--size:calc(var(--tri-size-field,0.25rem)*12);"};let m=ae(()=>`${v[t()]}${d[e()]}${h()}`);var _=ea();ur(_,()=>({class:`btn ${a()??""}`,style:b(m),...c,[Ft]:{circle:i(),square:n(),ghost:o(),outline:u(),active:l()}}),void 0,void 0,void 0,"svelte-sgoebi");var y=J(_);ir(y,()=>s.children??rn),fe(r,_)}let ia=0;var na=ve('<div role="option"> </div>'),ra=ve('<div><select><!></select> <button type="button" role="combobox" aria-haspopup="listbox"><span> </span></button> <div role="listbox" class="listbox svelte-1hwvamm" popover="manual" tabindex="-1"></div></div>');function xi(r,s){ki(s,!0);let e=Oe(s,"value",15),t=Oe(s,"size",3,"md"),i=Oe(s,"ghost",3,!1),n=Oe(s,"class",3,""),o=Oe(s,"style",3,""),u=fr(s,["$$slots","$$events","$$legacy","value","size","ghost","class","style","children"]);const l={xs:"calc(var(--tri-size-field,0.25rem)*6)",sm:"calc(var(--tri-size-field,0.25rem)*8)",md:"calc(var(--tri-size-field,0.25rem)*10)",lg:"calc(var(--tri-size-field,0.25rem)*12)"};let a=ae(()=>`--size:${l[t()]};${o()}`);const h=`tri-listbox-${ia++}`;let c=le(null),d=le(null),v=le(null),m=le(lt([])),_=le(!1),y=le(-1),E=ae(()=>!!s.disabled),S=ae(()=>e()==null?"":String(e())),P=ae(()=>b(m).find(z=>z.value===b(S))??b(m)[0]);function B(){b(c)&&G(m,Array.from(b(c).querySelectorAll("option")).map(z=>({value:z.value,label:(z.textContent??"").trim(),disabled:z.disabled})),!0)}Zt(()=>{if(!b(c))return;B();const z=new MutationObserver(()=>B());return z.observe(b(c),{childList:!0,subtree:!0,characterData:!0,attributes:!0}),()=>z.disconnect()});function O(z){const ie=b(m)[z];!b(c)||!ie||ie.disabled||(b(c).value=ie.value,b(c).dispatchEvent(new Event("input",{bubbles:!0})),b(c).dispatchEvent(new Event("change",{bubbles:!0})),Q())}function M(){if(!b(d)||!b(v))return;const z=b(d).getBoundingClientRect();b(v).style.minWidth=`${z.width}px`,b(v).style.left=`${z.left}px`;const ie=b(v).offsetHeight,ce=window.innerHeight-z.bottom;ce<ie&&z.top>ce?b(v).style.top=`${Math.max(4,z.top-ie-4)}px`:b(v).style.top=`${z.bottom+4}px`}function L(){b(v)?.children[b(y)]?.scrollIntoView({block:"nearest"})}function W(z){const ie=z.composedPath();b(d)&&ie.includes(b(d))||b(v)&&ie.includes(b(v))||Q()}function Y(){b(E)||b(_)||!b(v)||(G(_,!0),b(v).showPopover(),M(),G(y,b(m).findIndex(z=>z.value===b(S)),!0),b(y)<0&&G(y,b(m).findIndex(z=>!z.disabled),!0),L(),window.addEventListener("scroll",M,!0),window.addEventListener("resize",M),document.addEventListener("pointerdown",W,!0))}function Q(){b(_)&&(G(_,!1),b(v)?.hidePopover(),window.removeEventListener("scroll",M,!0),window.removeEventListener("resize",M),document.removeEventListener("pointerdown",W,!0),b(d)?.focus())}function ee(){b(_)?Q():Y()}function X(z){if(!b(m).length)return;let ie=b(y);for(let ce=0;ce<b(m).length;ce++)if(ie=(ie+z+b(m).length)%b(m).length,!b(m)[ie]?.disabled){G(y,ie,!0),L();return}}function ue(z){const ie=z==="start"?b(m).map((ce,we)=>we):b(m).map((ce,we)=>b(m).length-1-we);for(const ce of ie)if(!b(m)[ce]?.disabled){G(y,ce,!0),L();return}}let he="",de;function pe(z){he+=z.toLowerCase(),clearTimeout(de),de=setTimeout(()=>he="",600);const ie=b(m).findIndex(ce=>!ce.disabled&&ce.label.toLowerCase().startsWith(he));ie>=0&&(G(y,ie,!0),L())}function ge(z){if(!b(E)){if(!b(_)){["ArrowDown","ArrowUp","Enter"," "].includes(z.key)&&(z.preventDefault(),Y());return}switch(z.key){case"ArrowDown":z.preventDefault(),X(1);break;case"ArrowUp":z.preventDefault(),X(-1);break;case"Home":z.preventDefault(),ue("start");break;case"End":z.preventDefault(),ue("end");break;case"Enter":case" ":z.preventDefault(),b(y)>=0&&O(b(y));break;case"Escape":z.preventDefault(),Q();break;case"Tab":Q();break;default:z.key.length===1&&!z.metaKey&&!z.ctrlKey&&pe(z.key)}}}var me=ra(),Pe=J(me);ur(Pe,()=>({class:"native-select",tabindex:"-1","aria-hidden":"true",...u}),void 0,void 0,void 0,"svelte-1hwvamm");var Le=J(Pe);ir(Le,()=>s.children??rn),wi(Pe,z=>G(c,z),()=>b(c));var xe=ye(Pe,2);let Xe;xe.__click=ee,xe.__keydown=ge;var Z=J(xe);let $e;var ct=J(Z);wi(xe,z=>G(d,z),()=>b(d));var Ue=ye(xe,2);vi(Ue,23,()=>b(m),(z,ie)=>z.value+"\0"+ie,(z,ie,ce)=>{var we=na();let Ye;we.__click=()=>O(b(ce)),we.__pointermove=()=>G(y,b(ce),!0);var St=J(we);be(()=>{Ze(we,"id",`${h}-opt-${b(ce)??""}`),Ye=ei(we,1,"option svelte-1hwvamm",null,Ye,{active:b(ce)===b(y),selected:b(ie).value===b(S)}),Ze(we,"aria-selected",b(ie).value===b(S)),Ze(we,"aria-disabled",b(ie).disabled),_e(St,b(ie).label)}),fe(z,we)}),wi(Ue,z=>G(v,z),()=>b(v)),be(()=>{ei(me,1,`select-wrapper ${n()??""}`,"svelte-1hwvamm"),qi(me,o()),Xe=ei(xe,1,"select svelte-1hwvamm",null,Xe,{ghost:i(),open:b(_)}),qi(xe,b(a)),xe.disabled=b(E),Ze(xe,"aria-expanded",b(_)),Ze(xe,"aria-controls",h),Ze(xe,"aria-activedescendant",b(_)&&b(y)>=0?`${h}-opt-${b(y)}`:void 0),Ze(xe,"aria-label",u["aria-label"]),$e=ei(Z,1,"select-label svelte-1hwvamm",null,$e,{placeholder:b(P)?.disabled}),_e(ct,b(P)?.label??""),Ze(Ue,"id",h)}),ws(Pe,e),fe(r,me),Oi()}Kn(["click","keydown","pointermove"]);function Lt(r){var s,e;return r?.id||r?.["@id"]||((s=r?.__jsonld)==null?void 0:s.id)||((e=r?.__jsonld)==null?void 0:e["@id"])||(typeof r?.getId=="function"?r.getId():null)||null}function zt(r){return Lt(r)||(typeof r?.getCanvasId=="function"?r.getCanvasId():null)||(typeof r?.getId=="function"?r.getId():null)||""}function oa(r){var s;const e=r?.behavior||((s=r?.__jsonld)==null?void 0:s.behavior)||(typeof r?.getBehavior=="function"?r.getBehavior():[]);return e?(Array.isArray(e)?e:[e]).map(t=>{const i=String(t).trim().toLowerCase(),n=i.split(/[#/:]/);return n[n.length-1]||i}):[]}function wr(r){const s=oa(r);return s.includes("non-paged")||s.includes("facing-pages")}function sa(r,s){const e=[];for(let t=0;t<Math.min(s,r.length);t++){const i=r[t],n=zt(i);e.push({startIndex:t,endIndex:t,entries:n?[{canvasId:n,canvas:i}]:[]})}for(let t=s;t<r.length;){const i=r[t],n=zt(i),o=r[t+1],u=zt(o),l=!!o&&!!n&&!!u&&!wr(i)&&!wr(o);e.push({startIndex:t,endIndex:l?t+1:t,entries:[...n?[{canvasId:n,canvas:i}]:[],...l?[{canvasId:u,canvas:o}]:[]]}),t+=l?2:1}return e}function aa({canvases:r,currentCanvasId:s,currentCanvasIndex:e,viewingMode:t,pagedOffset:i}){if(!s)return[];if(e<0||e>=r.length)return[];const n=[],o=r[e];if(!o)return n;if(t!=="paged")return n.push({canvasId:s,canvas:o}),n;const u=sa(r,i).find(({startIndex:l,endIndex:a})=>e>=l&&e<=a);return u?.entries??n}function Ti(r,s){if(!r)return"";if(typeof r=="string")return r;if(typeof r=="object"&&!Array.isArray(r)){const e=r;if("@value"in e){const n=e["@value"];return Array.isArray(n)&&n.length>0?String(n[0]):n===void 0?"":String(n)}const t=Object.keys(e),i=n=>{const o=e[n];if(o!==void 0)return Array.isArray(o)&&o.length>0?String(o[0]):String(o)};for(const n of["en","none"]){const o=i(n);if(o!==void 0)return o}return t.length>0?i(t[0])??"":""}if(Array.isArray(r)&&r.length>0){if(typeof r[0]=="string")return r[0];const e=r,t=o=>o?.value??o?._value,i=(o=>e.find(u=>u.locale===o||u._locale===o||u.language===o))("en");{const o=t(i);if(o)return o}const n=e.find(o=>!o.locale&&!o._locale&&!o.language);{const o=t(n);if(o)return o}return t(e[0])??""}return String(r)}function yr(r,s){var e,t;const i=s===void 0?"Untitled canvas":`Canvas ${s+1}`;try{const o=(e=r.getLabel)==null?void 0:e.call(r);if(Array.isArray(o)&&o.length>0)return Ti(o)||i}catch{}const n=r.label||((t=r.__jsonld)==null?void 0:t.label);if(n){const o=Ti(n);if(o)return o}return i}function Xi(r){if(!r)return null;const s=r.match(/xywh=(?:pixel:)?([\d.]+),([\d.]+),([\d.]+),([\d.]+)/);return s?[Number(s[1]),Number(s[2]),Number(s[3]),Number(s[4])]:null}function la(r){const[s]=r.split("#");return s||null}function $i(r){if(!r)return null;if(typeof r=="string")return r;if(Array.isArray(r)){for(const e of r){const t=$i(e);if(t)return t}return null}if(typeof r!="object")return null;const s=r;return typeof s.id=="string"?s.id:typeof s["@id"]=="string"?s["@id"]:s.source?$i(s.source):null}function Yi(r){if(!r)return[];if(Array.isArray(r))return r.flatMap(e=>Yi(e));if(typeof r!="object")return[];const s=r;return s.item?Yi(s.item):[s]}function ua(r){const s=r.find(t=>t?.type==="FragmentSelector"&&typeof t?.value=="string"&&t.value.includes("xywh="));if(s)return Xi(s.value);const e=r.find(t=>typeof t?.value=="string"&&t.value.includes("xywh="));return e?Xi(e.value):null}function _r(r){if(!r)return[];if(Array.isArray(r))return r.flatMap(i=>_r(i));const s=$i(r),e=typeof r=="object"&&r&&"selector"in r?Yi(r.selector):[],t=ua(e)||(s?Xi(s):null);return[{raw:r,targetId:s,canvasId:s?la(s):null,selectors:e,xywh:t}]}function xr(r){return r.endsWith("/info.json")?r.slice(0,-10):r}function Ht(r){return typeof r=="number"&&Number.isFinite(r)&&r>0?r:null}function ha(r){const s=r?.__jsonld||r;return{width:Ht(r?.width)||Ht(s?.width)||(typeof r?.getWidth=="function"?Ht(r.getWidth()):null),height:Ht(r?.height)||Ht(s?.height)||(typeof r?.getHeight=="function"?Ht(r.getHeight()):null)}}function Tr(r){const s=r?.__jsonld||r;return s?.type==="SpecificResource"&&s!=null&&s.source?s.source:null}function ca(r,s){return s?.type==="Choice"||s?.type==="oa:Choice"||!!r&&!Array.isArray(r)&&(r.type==="Choice"||r.type==="oa:Choice")}function Er(r,s){return s&&(s.items||s.item)?s.items||s.item:Array.isArray(r)?r:r&&(r.items||r.item)?r.items||r.item:[]}function da({body:r,rawBody:s,canvasId:e,getSelectedChoice:t}){const i=Array.isArray(r)?r:Er(r,null),n=Er(null,s),o=t?.(e);if(o){const u=i.find(a=>Lt(a)===o);if(u)return u;const l=n.findIndex(a=>Lt(a)===o);if(l>=0)return i[l]||n[l]}return i[0]||n[0]||null}function pa(r){var s;let e=((s=r.getImages)==null?void 0:s.call(r))||[];return(!e||!e.length)&&r.getContent&&(e=r.getContent()),e||[]}function fa(r){var s,e;const t=r?.width||((s=r?.__jsonld)==null?void 0:s.width)||(typeof r?.getWidth=="function"?r.getWidth():null),i=r?.height||((e=r?.__jsonld)==null?void 0:e.height)||(typeof r?.getHeight=="function"?r.getHeight():null);return typeof t!="number"||typeof i!="number"?null:{width:t,height:i}}function ga(r){var s,e;const t=(e=_r(r?.target||((s=r?.__jsonld)==null?void 0:s.target)).find(i=>i.xywh))==null?void 0:e.xywh;return t?{x:t[0],y:t[1],width:t[2],height:t[3]}:null}function va(r,s){if(typeof r!="string"||!r.trim())return null;const e=r.trim(),t=e.startsWith("pct:"),i=(t?e.slice(4):e).split(",").map(n=>Number(n.trim()));return i.length!==4||i.some(n=>!Number.isFinite(n)||n<0)?null:t?typeof s.width!="number"||typeof s.height!="number"?null:{x:i[0]/100*s.width,y:i[1]/100*s.height,width:i[2]/100*s.width,height:i[3]/100*s.height}:{x:i[0],y:i[1],width:i[2],height:i[3]}}function ma(r,s){var e;const t=r?.__jsonld||r;return va(((e=t?.selector)==null?void 0:e.type)==="ImageApiSelector"?t.selector.region:null,s)}function wa(r){return[r.x,r.y,r.width,r.height].map(s=>Math.round(s)).join(",")}function ya(r){const s=r?.__jsonld||r,e=Tr(r);return!!(r&&(r.id||r["@id"]||s!=null&&s.service||e||s!=null&&s.id||s!=null&&s["@id"]))}function _a(r,s,e){var t;let i=r.getResource?r.getResource():null;if(!i&&r.getBody){const n=r.getBody(),o=((t=r.__jsonld)==null?void 0:t.body)||r.body;ca(n,o)?i=da({body:n,rawBody:o,canvasId:s,getSelectedChoice:e}):Array.isArray(n)&&n.length>0?i=n[0]:n&&(i=n)}if(i&&!ya(i)&&(i=null),!i){const n=r.__jsonld||r;if(n.body){let o=n.body;if(o.type==="Choice"||o.type==="oa:Choice"){const u=o.items||o.item||[],l=e?.(s);o=(l?u.find(a=>Lt(a)===l):null)||u[0]||null}i=Array.isArray(o)?o[0]:o}}return i}function br(r){return typeof r=="string"?/^https?:\/\/iiif\.io\/api\/image\//.test(r)||r==="level0"||r==="level1"||r==="level2":Array.isArray(r)?r.some(s=>br(s)):!1}function xa(r){return typeof r=="string"?r||null:Array.isArray(r)&&r.find(s=>typeof s=="string")||null}function Ta(r){let s=[];const e=r?.__jsonld||r;return e!=null&&e.service&&(s=Array.isArray(e.service)?e.service:[e.service]),!s.length&&r!=null&&r.getServices&&(s=r.getServices()),s.length&&s.find(t=>{const i=t.getType?t.getType():t.type||t["@type"]||"",n=t.getProfile?t.getProfile():t.profile||"";return i==="ImageService1"||i==="ImageService2"||i==="ImageService3"||br(n)})||null}function Ea(r,s){var e,t;for(const i of[r,s]){if(!i)continue;try{const o=(e=i.getLabel)==null?void 0:e.call(i);if(Array.isArray(o)&&o.length>0){const u=Ti(o);if(u)return u}}catch{}const n=i.label||((t=i.__jsonld)==null?void 0:t.label);if(n){const o=Ti(n);if(o)return o}}return null}function ba(r){const s=Ta(r),e=Lt(s),t=s?s.getProfile?s.getProfile():s.profile||"":null;return{serviceId:e?xr(e):null,serviceProfile:xa(t)}}function Sa(r){if(!r||!r.includes("/iiif/"))return null;const s=r.split("/"),e=s.findIndex(t=>t==="full"||/^\d+,\d+,\d+,\d+$/.test(t));return e>0?s.slice(0,e).join("/"):null}function Ei(r,s={}){const e=zt(r);if(!e)return[];const t=fa(r);if(!t)return[];const i=pa(r);return i.length?i.map(n=>{const o=_a(n,e,s.getSelectedChoice),u=Tr(o)||o;if(!u)return null;const l=Lt(u),a=ha(u),h=ba(u),c=h.serviceId||Sa(l),d=ga(n),v=ma(o,a);return{canvasId:e,annotation:n,resource:u,resourceId:l,label:Ea(u,n),canvasWidth:t.width,canvasHeight:t.height,resourceWidth:v?.width||a.width,resourceHeight:v?.height||a.height,serviceId:c,serviceProfile:h.serviceProfile,imageApiRegion:v,x:d?d.x/t.width:0,y:d?d.y/t.width:0,width:d?d.width/t.width:1}}).filter(n=>n!==null):[]}function Pa(r,s={width:1600}){const e=xr(r),t=s.region||"full",i=s.quality||"default",n=s.format||"jpg",o=typeof s.width=="number"?Math.max(1,Math.round(s.width)):null,u=typeof s.height=="number"?Math.max(1,Math.round(s.height)):null,l=s.size||(o?`${o},`:`,${u||1600}`);return`${e}/${t}/${l}/0/${i}.${n}`}function Ca(r){return typeof r=="string"?r:Array.isArray(r)&&typeof r[0]=="string"?r[0]:null}function bi(r){const s=Ca(r);return s?s==="level0"||s.endsWith("/level0.json")||s.endsWith("#level0"):!1}function Ra(r,s,e,t){var i;if(!((i=r?.IIIFTileSource)!=null&&i.prototype))return s;try{const n=r.IIIFTileSource.prototype.configure.call({},s,e,null),o=new r.IIIFTileSource(n);return Da(o,t),o}catch{return s}}function Da(r,s){if(!bi(r?.profile)||typeof r?.getTileUrl!="function"||r.__triiiceratopsLevel0LowZoomPrepared)return;const e=r.getTileUrl.bind(r),t=typeof r.getNumTiles=="function"?r.getNumTiles.bind(r):null,i=ka(),n=Aa(r),o=Ia(r,n,t);t&&(r.getNumTiles=function(u){return Pr(u,o,n,this)?{x:0,y:0}:Sr(this,u,i,n,t,o)?{x:1,y:1}:t(u)}),typeof r?.minLevel=="number"&&o>=0&&(r.minLevel=Math.max(r.minLevel,o)),r.getTileUrl=function(u,l,a){if(Pr(u,o,n,this)){const h=o>=0?o:u;return e(h,l,a)}return Sr(this,u,i,n,t,o)?Cr(this,u):e(u,l,a)},r.__triiiceratopsLevel0LowZoomPrepared=!0}function Sr(r,s,e,t,i,n){if(n>=0)return!1;if(!Ki(r,s,t))return!0;if(!i)return!1;const o=i(s);return o?.x===1&&o?.y===1}function Ia(r,s,e){if(!e||typeof r?.minLevel!="number"||typeof r?.maxLevel!="number"||s.size===0)return-1;for(let t=r.minLevel;t<=r.maxLevel;t++){if(!Ki(r,t,s))continue;const i=e(t);if(i?.x>1||i?.y>1)return t}return-1}function Pr(r,s,e,t){return s<0?!1:r<s?!0:!Ki(t,r,e)}function Aa(r){const s=new Set,e=r?.scale_factors;if(Array.isArray(e))for(const t of e)typeof t=="number"&&t>0&&s.add(t);return s}function Ki(r,s,e){if(e.size===0||typeof r?.maxLevel!="number"||typeof s!="number")return!0;const t=Math.pow(2,r.maxLevel-s);return e.has(t)}function ka(r,s){return-1}function Cr(r,s){const e=r.getLevelScale(s),t=Math.ceil(r.width*e),i=Math.ceil(r.height*e),n=r.version===3,o=bi(r?.profile),u=n?t===r.width&&i===r.height?"max":o?`${t},`:`${t},${i}`:t===r.width?"full":`${t},`,l=n?"default":"native";return`${r._id}/full/${u}/0/${l}.${r.tileFormat}`}const Si=8e3,Rr=4e7;function Oa(r,s,e,t){const i=Math.max(1,Math.round(r.width*s*t)),n=r.resourceWidth&&r.resourceHeight?r.resourceHeight/r.resourceWidth:e/s;return{x:Math.round(r.x*s*t),y:Math.round(r.y*e*t),width:i,height:Math.max(1,Math.round(i*n))}}function Ba(r,s){const e=URL.createObjectURL(r),t=document.createElement("a");t.href=e,t.download=s,document.body.appendChild(t),t.click(),t.remove(),URL.revokeObjectURL(e)}async function Qi(r,s){const e=await fetch(r,s);if(!e.ok)throw new Error(`Image request failed with ${e.status}.`);return e.blob()}async function Fa(r){const s=URL.createObjectURL(r);try{return await new Promise((e,t)=>{const i=new Image;i.onload=()=>e(i),i.onerror=()=>t(new Error("Unable to decode image for export.")),i.src=s})}finally{URL.revokeObjectURL(s)}}async function Dr(r,s,e,t="image/png"){const i=document.createElement("canvas");i.width=Math.max(1,Math.round(s)),i.height=Math.max(1,Math.round(e));const n=i.getContext("2d");if(!n)throw new Error("Unable to create a canvas for image export.");for(const o of r){const u=await Fa(o.blob);n.drawImage(u,o.x,o.y,o.width,o.height)}return new Promise((o,u)=>{i.toBlob(l=>{if(l){o(l);return}u(new Error("Unable to export composed image."))},t)})}function Ir(r,s){let e=1;r>Si&&(e=Math.min(e,Si/r)),s>Si&&(e=Math.min(e,Si/s));const t=r*s;return t*e*e>Rr&&(e=Math.min(e,Math.sqrt(Rr/t))),e>=1?{width:Math.round(r),height:Math.round(s),clamped:!1}:{width:Math.max(1,Math.round(r*e)),height:Math.max(1,Math.round(s*e)),clamped:!0}}function ni(r,s={}){if(bi(r.serviceProfile))return r.resourceId??null;if(r.serviceId){const e=r.imageApiRegion?wa(r.imageApiRegion):void 0,t=!!(s.width||s.height);return Pa(r.serviceId,{region:e,size:t?void 0:"max",width:s.width,height:s.height})}return r.resourceId??null}async function Ma(r){if(!r.serviceId)return[];const s=r.serviceId.endsWith("/info.json")?r.serviceId:`${r.serviceId}/info.json`;try{const e=await fetch(s);if(!e.ok)return[];const t=await e.json(),i=await Promise.resolve().then(()=>Dl).then(a=>a.o),n=i.default||i,o=Ra(n,t,s);if(!o||typeof o.minLevel!="number"||typeof o.maxLevel!="number"||typeof o.getLevelScale!="function")return[];const u=new Set,l=[];for(let a=o.minLevel;a<=o.maxLevel;a+=1){const h=o.getLevelScale(a),c=Math.ceil(o.width*h),d=Math.ceil(o.height*h),v=`${c}x${d}`;u.has(v)||(u.add(v),l.push({width:c,height:d,label:`${c} × ${d}px`,url:Cr(o,a)}))}return l.sort((a,h)=>h.width-a.width)}catch{return[]}}const La=[{fraction:1,label:"Original"},{fraction:.5,label:"50%"},{fraction:.25,label:"25%"}];function Ji(r,s,e){return La.map(({fraction:t,label:i})=>{const n=Math.max(1,Math.round(r*t)),o=Math.max(1,Math.round(s*t)),u=e?.({width:n,height:o,isOriginal:t===1});return{width:n,height:o,label:`${i} (${n} × ${o}px)`,url:u??void 0}}).filter(t=>!e||!!t.url)}function za(r){const s=r.resourceWidth,e=r.resourceHeight;if(!r.serviceId||!s||!e){const t=ni(r);return t?[{width:s??0,height:e??0,label:"Original",url:t}]:[]}return Ji(s,e,({width:t,height:i,isOriginal:n})=>ni(r,n?{}:{width:t,height:i}))}async function Ha(r){if(bi(r.serviceProfile)){const s=await Ma(r);return s.length?s:r.resourceId?[{width:r.resourceWidth??0,height:r.resourceHeight??0,label:"Original",url:r.resourceId}]:[]}return za(r)}const Na=.0125;function Ua(r){return!!r&&typeof r=="object"&&"tileSource"in r}function Ar(r,s){if(!r||typeof r!="object")return null;const e=r[s];return typeof e=="number"&&Number.isFinite(e)&&e>0?e:null}function Wa(r,s,e){return Math.min(e,Math.max(s,r))}function ja(r){const s=[...r].sort((t,i)=>t-i),e=Math.floor(s.length/2);return s.length%2===0?(s[e-1]+s[e])/2:s[e]}function Va(r){const s=new Map;return r.forEach((e,t)=>{const i=Ua(e),n=i?e.tileSource:e,o=i?e.canvasId??`canvas-${t}`:`canvas-${t}`,u=i?e.x??0:0,l=i?e.y??0:0,a=i?e.width??1:1,h=Ar(n,"width"),c=Ar(n,"height"),d=h&&c?a*c/h:null;let v=s.get(o);v||(v={canvasId:o,sources:[],width:0,height:null},s.set(o,v)),v.sources.push({source:e,tileSource:n,localX:u,localY:l,localWidth:a,localHeight:d}),v.width=Math.max(v.width,u+a),v.height=d===null?null:Math.max(v.height??0,l+d)}),[...s.values()]}function Ga(r){return{layouts:r.map(s=>({canvasId:s.canvasId,x:0,y:0,width:s.width,height:s.height??1})),sources:r.flatMap(s=>s.sources.map(({tileSource:e,localX:t,localY:i,localWidth:n})=>({tileSource:e,x:t,y:i,width:n,canvasId:s.canvasId})))}}function qa(r,s){const e=Va(r);if(s.mode==="individuals"||e.length<=1)return Ga(e);const t=!s.preserveCanvasScale&&e.every(o=>o.height!==null),i=t?ja(e.map(o=>o.height)):1,n=e.map(o=>{const u=t?Wa(i/o.height,.25,4):1;return{group:o,scale:u,width:o.width*u,height:(o.height??1)*u,x:0,y:0}});if(s.mode==="continuous"){let o=0;const u=s.direction==="top-to-bottom"||s.direction==="bottom-to-top",l=s.direction==="right-to-left"||s.direction==="bottom-to-top";for(const a of n)u?(a.y=l?-o:o,o+=(t?a.height:1)+s.gap):(a.x=l?-o:o,o+=(t?a.width:1)+s.gap)}else if(s.mode==="paged"){const o=Math.max(...n.map(l=>l.height)),u=s.direction==="right-to-left";n.forEach((l,a)=>{const h=u?n.slice(a+1):n.slice(0,a);l.x=h.reduce((c,d)=>c+(t?d.width:1)+s.gap,0),l.y=(o-l.height)/2})}return{layouts:n.map(o=>({canvasId:o.group.canvasId,x:o.x,y:o.y,width:o.width,height:o.height})),sources:n.flatMap(o=>o.group.sources.map(({tileSource:u,localX:l,localY:a,localWidth:h})=>({tileSource:u,x:o.x+l*o.scale,y:o.y+a*o.scale,width:h*o.scale,canvasId:o.group.canvasId})))}}function Za(r,s,e){Ys(r,"@triiiceratops/plugin-image-export","1.0.0-rc.0",s,e)}function Xa(r){return r.replace(/[^a-z0-9-_]+/gi,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function $a(r,s,e){const i=Xa(r)||"image",n=s==="single"?"":`-${s}`;return`${i}${n}.png`}function kr(r,s){return Ei(r,{getSelectedChoice:s})}function Ya(r){return Ha(r)}function Ka(r,s){const t=Ei(r,{getSelectedChoice:s})[0];return!t?.canvasWidth||!t?.canvasHeight?[]:Ji(t.canvasWidth,t.canvasHeight)}async function Qa(r,s){const e=s.url??ni(r,{width:s.width,height:s.height});if(!e)throw new Error("No exportable image found for this canvas.");return Qi(e)}async function Ja(r,s,e={}){const t=Ei(r,{getSelectedChoice:e.getSelectedChoice}),i=t[0];if(!i)throw new Error("No exportable image found for this canvas.");const{canvasWidth:n,canvasHeight:o}=i;if(!n||!o)throw new Error("Unable to determine canvas dimensions for export.");const{width:u,height:l}=Ir(s.width,s.height),a=u/n,h=await Promise.all(t.map(async c=>el(c,n,o,a)));return Dr(h,u,l,e.format??"image/png")}async function el(r,s,e,t){const i=Oa(r,s,e,t),n=ni(r,{width:i.width});if(!n)throw new Error("No exportable image found for this canvas.");return{blob:await Qi(n),...i}}function Or(r){return aa({canvases:r.canvases,currentCanvasId:r.canvasId,currentCanvasIndex:r.currentCanvasIndex,viewingMode:r.viewingMode,pagedOffset:r.pagedOffset}).map(s=>s.canvas)}function Br(r,s){const e=Or(r);if(!e.length)return null;const t=e.flatMap((c,d)=>{const v=zt(c)??`canvas-${d}`;return Ei(c,{getSelectedChoice:s}).map(m=>({canvasId:v,x:m.x,y:m.y,width:m.width,tileSource:{width:m.resourceWidth||m.canvasWidth,height:m.resourceHeight||m.canvasHeight,resolved:m}}))});if(!t.length)return null;const{layouts:i,sources:n}=qa(t,{mode:r.viewingMode,direction:r.viewingDirection,preserveCanvasScale:r.preserveCanvasScale,gap:Na});if(!i.length)return null;const o=Math.min(...i.map(c=>c.x)),u=Math.min(...i.map(c=>c.y)),l=Math.max(...i.map(c=>c.x+c.width)),a=Math.max(...i.map(c=>c.y+c.height));return{entries:n.map(c=>({resolved:c.tileSource.resolved,x:c.x-o,y:c.y-u,width:c.width})),worldWidth:l-o,worldHeight:a-u}}function tl(r,s){const e=Br(r,s);if(!e)return[];const t=e.entries[0],i=t?.resolved.resourceWidth&&t.width>0?t.resolved.resourceWidth/t.width:1600,n=Math.round(e.worldWidth*i),o=Math.round(e.worldHeight*i);return!n||!o?[]:Ji(n,o)}async function il(r,s,e={}){const t=Br(r,e.getSelectedChoice);if(!t)throw new Error("Nothing is currently displayed in the viewer.");const{width:i,height:n}=Ir(s.width,s.height),o=i/t.worldWidth,u=await Promise.all(t.entries.map(async({resolved:l,x:a,y:h,width:c})=>{const d=Math.max(1,Math.round(c*o)),v=l.resourceWidth&&l.resourceHeight?l.resourceHeight/l.resourceWidth:1,m=Math.max(1,Math.round(d*v)),_=ni(l,{width:d});if(!_)throw new Error("No exportable image found for the current view.");return{blob:await Qi(_),x:Math.round(a*o),y:Math.round(h*o),width:d,height:m}}));return Dr(u,i,n,e.format??"image/png")}var nl=ve("<option> </option>"),rl=ve("<option> </option>"),ol=ve("<!> <option> </option> <!>",1),sl=ve('<div class="tri-id-field"><label class="tri-id-label" for="tri-id-mode"><span> </span></label> <!></div>'),al=ve("<option> </option>"),ll=ve('<div class="tri-id-field"><label class="tri-id-label" for="tri-id-canvas"><span> </span></label> <!></div>'),ul=ve("<option> </option>"),hl=ve('<div class="tri-id-field"><label class="tri-id-label" for="tri-id-image"><span> </span></label> <!></div>'),cl=ve("<option> </option>"),dl=ve("<option disabled> </option> <!>",1),pl=ve('<div class="tri-id-alert is-success" data-tri-id-result=""><span> </span></div>'),fl=ve('<div class="tri-id-alert is-error" data-tri-id-error=""><span> </span></div>'),gl=ve('<div class="tri-id-alert"><span> </span></div>'),vl=ve('<div class="tri-id-card"><div class="tri-id-card-body"><!> <!> <!></div></div>'),ml=ve('<span aria-hidden="true"></span> ',1),wl=ve('<div class="tri-id" data-tri-id="" data-panel-id="image-download"><div class="tri-id-body"><p class="tri-id-desc"> </p> <div class="tri-id-fields"><!> <!> <!> <div class="tri-id-field"><label class="tri-id-label" for="tri-id-resolution"><span> </span></label> <!></div></div> <!></div> <div class="tri-id-footer"><!></div></div>');function yl(r,s){ki(s,!0);const{context:e}=xo(vr),{viewerState:t,selectors:i,locale:n,ui:o}=e;let u=le(0),l=le(0);i.select(A=>[A.canvasId,A.currentCanvasIndex,A.canvases,A.viewingMode,A.viewingDirection,A.pagedOffset,A.preserveCanvasScale]).subscribe(()=>{Tn(u)}),n.subscribe(()=>{Tn(l)});const a=(A,D)=>(b(l),n.t(A,D));let h=le("single"),c=le(0),d=le(0),v=le(lt([])),m=le(null),_=le(!1),y=le(!1),E=le(""),S=le(""),P=le(null);const B=A=>t.getSelectedChoice(A),O=ae(()=>(b(u),t.currentCanvasIndex>=0?t.canvases[t.currentCanvasIndex]??null:null)),M=ae(()=>(b(u),b(O)?kr(b(O),B):[])),L=ae(()=>b(M).length>1),W=ae(()=>b(L)),Y=ae(()=>(b(u),Or(t))),Q=ae(()=>b(Y).length>1),ee=ae(()=>b(Q)),X=ae(()=>b(W)||b(ee)),ue=ae(()=>(b(u),b(h)==="single"&&b(Q)?b(Y)[b(c)]??b(O):b(O))),he=ae(()=>(b(u),b(ue)?kr(b(ue),B):[])),de=ae(()=>b(he).length>1),pe=ae(()=>b(m)!==null?b(v)[b(m)]??null:null),ge=ae(()=>!b(y)&&!b(_)&&!!b(O)&&!!b(pe)),me=ae(()=>(b(l),b(O)?!b(_)&&!b(v).length?a("image_download_disabled_no_resolution"):null:a("image_download_disabled_no_canvas")));Zt(()=>{(b(h)==="composite"&&!b(W)||b(h)==="world"&&!b(ee))&&G(h,"single")}),Zt(()=>{b(u);const A=t.canvasId,D=b(Y).findIndex(H=>zt(H)===A);G(c,D>=0?D:0,!0)}),Zt(()=>{b(ue),G(d,0)}),Zt(()=>{const A=b(O),D=b(h),H=b(d);let V=!1;if(G(v,[],!0),G(m,null),!!A){if(D==="single"){const q=b(he)[H];if(!q)return;G(_,!0),Ya(q).then(U=>{V||(G(v,U,!0),G(m,U.length?0:null,!0))}).finally(()=>{V||G(_,!1)})}else if(D==="composite"){const q=Ka(A,B);G(v,q,!0),G(m,q.length?0:null,!0)}else{const q=tl(t,B);G(v,q,!0),G(m,q.length?0:null,!0)}return()=>{V=!0}}});function Pe(A){const D=Number(A);return Number.isInteger(D)?D:0}async function Le(){if(!(!b(O)||!b(pe)||!b(ge))){G(y,!0),G(E,""),G(S,"");try{let A,D=b(O);if(b(h)==="single"){D=b(ue);const V=b(he)[b(d)];if(!V)return;A=await Qa(V,b(pe))}else b(h)==="composite"?A=await Ja(b(O),b(pe),{getSelectedChoice:B}):A=await il(t,b(pe),{getSelectedChoice:B});const H=$a(yr(D,t.currentCanvasIndex),b(h),"image/png");Ba(A,H),G(S,a("image_download_result_downloaded",{filename:H}),!0)}catch(A){G(E,a("image_download_error_failed"),!0),b(P)&&Za(b(P),A,()=>void Le())}finally{G(y,!1)}}}function xe(A){return{destroy:o.renderIcon(mr,A)}}var Xe=wl(),Z=J(Xe),$e=J(Z),ct=J($e),Ue=ye($e,2),z=J(Ue);{var ie=A=>{var D=sl(),H=J(D),V=J(H),q=J(V),U=ye(H,2);{let $=ae(()=>a("image_download_mode"));xi(U,{id:"tri-id-mode",class:"tri-id-field-select","data-tri-id-mode":!0,get"aria-label"(){return b($)},get disabled(){return b(y)},get value(){return b(h)},onchange:g=>{G(h,g.currentTarget.value,!0)},children:(g,f)=>{var w=ol(),T=Gt(w);{var R=oe=>{var re=nl(),Ke=J(re);re.value=re.__value="composite",be(Wt=>_e(Ke,Wt),[()=>a("image_download_mode_composite")]),fe(oe,re)};ot(T,oe=>{b(W)&&oe(R)})}var I=ye(T,2),N=J(I);I.value=I.__value="single";var K=ye(I,2);{var j=oe=>{var re=rl(),Ke=J(re);re.value=re.__value="world",be(Wt=>_e(Ke,Wt),[()=>a("image_download_mode_world")]),fe(oe,re)};ot(K,oe=>{b(ee)&&oe(j)})}be(oe=>_e(N,oe),[()=>a("image_download_mode_single")]),fe(g,w)},$$slots:{default:!0}})}be($=>_e(q,$),[()=>a("image_download_mode")]),fe(A,D)};ot(z,A=>{b(X)&&A(ie)})}var ce=ye(z,2);{var we=A=>{var D=ll(),H=J(D),V=J(H),q=J(V),U=ye(H,2);{let $=ae(()=>a("image_download_canvas"));xi(U,{id:"tri-id-canvas",class:"tri-id-field-select",get"aria-label"(){return b($)},get disabled(){return b(y)},get value(){return b(c)},onchange:g=>{G(c,Pe(g.currentTarget.value),!0)},children:(g,f)=>{var w=Jn(),T=Gt(w);vi(T,17,()=>b(Y),Wi,(R,I,N)=>{var K=al(),j=J(K);K.value=K.__value=N,be(oe=>_e(j,oe),[()=>yr(b(I),N)]),fe(R,K)}),fe(g,w)},$$slots:{default:!0}})}be($=>_e(q,$),[()=>a("image_download_canvas")]),fe(A,D)};ot(ce,A=>{b(h)==="single"&&b(Q)&&A(we)})}var Ye=ye(ce,2);{var St=A=>{var D=hl(),H=J(D),V=J(H),q=J(V),U=ye(H,2);{let $=ae(()=>a("image_download_image"));xi(U,{id:"tri-id-image",class:"tri-id-field-select",get"aria-label"(){return b($)},get disabled(){return b(y)},get value(){return b(d)},onchange:g=>{G(d,Pe(g.currentTarget.value),!0)},children:(g,f)=>{var w=Jn(),T=Gt(w);vi(T,17,()=>b(he),Wi,(R,I,N)=>{var K=ul(),j=J(K);K.value=K.__value=N,be(oe=>_e(j,oe),[()=>b(I).label??`${a("image_download_image")} ${N+1}`]),fe(R,K)}),fe(g,w)},$$slots:{default:!0}})}be($=>_e(q,$),[()=>a("image_download_image")]),fe(A,D)};ot(Ye,A=>{b(h)==="single"&&b(de)&&A(St)})}var Nt=ye(Ye,2),Ut=J(Nt),Pt=J(Ut),dt=J(Pt),p=ye(Ut,2);{let A=ae(()=>a("image_download_resolution")),D=ae(()=>b(y)||b(_)||!b(v).length),H=ae(()=>b(m)??"");xi(p,{id:"tri-id-resolution",class:"tri-id-field-select","data-tri-id-resolution":!0,get"aria-label"(){return b(A)},get disabled(){return b(D)},get value(){return b(H)},onchange:V=>{G(m,Pe(V.currentTarget.value),!0)},children:(V,q)=>{var U=dl(),$=Gt(U),g=J($);$.value=$.__value="";var f=ye($,2);vi(f,17,()=>b(v),Wi,(w,T,R)=>{var I=cl(),N=J(I);I.value=I.__value=R,be(()=>_e(N,b(T).label)),fe(w,I)}),be(w=>_e(g,w),[()=>a("image_download_resolution_placeholder")]),fe(V,U)},$$slots:{default:!0}})}var x=ye(Ue,2);{var C=A=>{var D=vl(),H=J(D),V=J(H);{var q=w=>{var T=pl(),R=J(T),I=J(R);be(()=>_e(I,b(S))),fe(w,T)};ot(V,w=>{b(S)&&w(q)})}var U=ye(V,2);{var $=w=>{var T=fl(),R=J(T),I=J(R);be(()=>_e(I,b(E))),fe(w,T)};ot(U,w=>{b(E)&&w($)})}var g=ye(U,2);{var f=w=>{var T=gl(),R=J(T),I=J(R);be(()=>_e(I,b(me))),fe(w,T)};ot(g,w=>{b(me)&&w(f)})}fe(A,D)};ot(x,A=>{(b(S)||b(E)||b(me))&&A(C)})}var k=ye(Z,2),F=J(k);{let A=ae(()=>!b(ge));ta(F,{variant:"primary",class:"tri-id-download","data-tri-id-download":!0,style:"width:100%",get disabled(){return b(A)},onclick:Le,children:(D,H)=>{var V=ml(),q=Gt(V);ds(q,$=>xe?.($));var U=ye(q);be($=>_e(U,` ${$??""}`),[()=>b(y)?a("image_download_downloading"):a("image_download_download")]),fe(D,V)},$$slots:{default:!0}})}wi(Xe,A=>G(P,A),()=>b(P)),be((A,D)=>{_e(ct,A),_e(dt,D)},[()=>a("image_download_description"),()=>a("image_download_resolution")]),fe(r,Xe),Oi()}const{STYLES:_l,STYLE_ID:xl}=$s(`
6
6
  .tri-id {
7
7
  display: flex;
8
8
  flex-direction: column;
@@ -119,7 +119,7 @@ Update the plugin or the core viewer so their declared ranges and capabilities o
119
119
  height: 1.125rem;
120
120
  fill: currentColor;
121
121
  }
122
- `,"panel"),Tl=Vs({name:"@triiiceratops/plugin-image-export",uiId:"image-download",version:"1.0.0-rc.0",coreRange:">=1.0.0-rc.0",pluginApiRange:"^1.0.0",requiredCapabilities:["osd@5"],icon:mr,target:"panel",catalog:Qs,view:{mount(r,s){const e=s.styles.install(_l,xl),t=s.styles.install(Ks,"bundled"),i=ss(yl,{target:r,context:new Map([[vr,{context:s}]])});return()=>{ls(i),t(),e()}}}});function El(){const r=new Map;return{register(s){const e=r.get(s.name);if(!e){r.set(s.name,s);return}e.version!==s.version&&console.warn(`[triiiceratops] Ignoring plugin "${s.name}" version ${s.version}: version ${e.version} is already registered on this page and wins (first registration wins).`)},get(s){return r.get(s)},has(s){return r.has(s)},list(){return[...r.values()]}}}function bl(r){(window.Triiiceratops??={coreVersion:"",pluginApiVersion:"",capabilities:[],plugins:El()}).plugins.register(r)}bl(Tl);function Sl(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function Pl(r,s){for(var e=0;e<s.length;e++){const t=s[e];if(typeof t!="string"&&!Array.isArray(t)){for(const i in t)if(i!=="default"&&!(i in r)){const n=Object.getOwnPropertyDescriptor(t,i);n&&Object.defineProperty(r,i,n.get?n:{enumerable:!0,get:()=>t[i]})}}}return Object.freeze(Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}))}var en={exports:{}},Cl=en.exports,Fr;function Rl(){return Fr||(Fr=1,(function(r){//! openseadragon 5.0.1
122
+ `,"panel"),Tl=Vs({name:"@triiiceratops/plugin-image-export",title:"image_download_title",uiId:"image-download",version:"1.0.0-rc.0",coreRange:">=1.0.0-rc.0",pluginApiRange:"^1.0.0",requiredCapabilities:["osd@5"],icon:mr,target:"panel",catalog:Qs,view:{mount(r,s){const e=s.styles.install(_l,xl),t=s.styles.install(Ks,"bundled"),i=ss(yl,{target:r,context:new Map([[vr,{context:s}]])});return()=>{ls(i),t(),e()}}}});function El(){const r=new Map;return{register(s){const e=r.get(s.name);if(!e){r.set(s.name,s);return}e.version!==s.version&&console.warn(`[triiiceratops] Ignoring plugin "${s.name}" version ${s.version}: version ${e.version} is already registered on this page and wins (first registration wins).`)},get(s){return r.get(s)},has(s){return r.has(s)},list(){return[...r.values()]}}}function bl(r){(window.Triiiceratops??={coreVersion:"",pluginApiVersion:"",capabilities:[],plugins:El()}).plugins.register(r)}bl(Tl);function Sl(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function Pl(r,s){for(var e=0;e<s.length;e++){const t=s[e];if(typeof t!="string"&&!Array.isArray(t)){for(const i in t)if(i!=="default"&&!(i in r)){const n=Object.getOwnPropertyDescriptor(t,i);n&&Object.defineProperty(r,i,n.get?n:{enumerable:!0,get:()=>t[i]})}}}return Object.freeze(Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}))}var en={exports:{}},Cl=en.exports,Fr;function Rl(){return Fr||(Fr=1,(function(r){//! openseadragon 5.0.1
123
123
  //! Built on 2024-12-09
124
124
  //! Git commit: v5.0.1-0-480de92d
125
125
  //! http://openseadragon.github.io
package/dist/index.js CHANGED
@@ -3554,6 +3554,7 @@ const { STYLES: Ho, STYLE_ID: Vo } = di(
3554
3554
  }
3555
3555
  }, Ko = vi({
3556
3556
  name: "@triiiceratops/plugin-image-export",
3557
+ title: "image_download_title",
3557
3558
  uiId: "image-download",
3558
3559
  version: "1.0.0-rc.0",
3559
3560
  coreRange: ">=1.0.0-rc.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triiiceratops/plugin-image-export",
3
- "version": "1.0.0-rc.3",
3
+ "version": "1.0.0-rc.4",
4
4
  "type": "module",
5
5
  "description": "Image download (single/composite/current-view export) plugin for the triiiceratops IIIF viewer, authored on @triiiceratops/plugin-sdk.",
6
6
  "license": "MIT",
@@ -49,17 +49,17 @@
49
49
  "lint:fix": "eslint . --fix --max-warnings 0"
50
50
  },
51
51
  "peerDependencies": {
52
- "triiiceratops": "^1.0.0-rc.28",
53
- "@triiiceratops/plugin-sdk": "^1.0.0-rc.4"
52
+ "triiiceratops": "^1.0.0-rc.29",
53
+ "@triiiceratops/plugin-sdk": "^1.0.0-rc.5"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@sveltejs/vite-plugin-svelte": "^6.2.1",
57
- "@triiiceratops/plugin-sdk": "1.0.0-rc.4",
57
+ "@triiiceratops/plugin-sdk": "1.0.0-rc.5",
58
58
  "@triiiceratops/ui": "0.0.0",
59
59
  "@vitest/coverage-v8": "4.0.15",
60
60
  "svelte": "5.45.5",
61
61
  "svelte-check": "^4.3.4",
62
- "triiiceratops": "1.0.0-rc.28",
62
+ "triiiceratops": "1.0.0-rc.29",
63
63
  "typescript": "~5.9.3",
64
64
  "vite": "^6.0.0",
65
65
  "vitest": "^4.0.15"