diff --git a/config.json b/config.json index ab731b1e..fcdccf49 100644 --- a/config.json +++ b/config.json @@ -1,7 +1,7 @@ { "info": { "name": "CAIO", - "version": "1.8.1", + "version": "1.8.2", "author": "ipuppet", "module": false }, diff --git a/dist/CAIO-en.json b/dist/CAIO-en.json index 5c855750..4b10dc91 100644 --- a/dist/CAIO-en.json +++ b/dist/CAIO-en.json @@ -12,7 +12,7 @@ "type": "@flow.javascript", "parameters": { "script": { - "value": "(()=>{var $parcel$global=\"undefined\"!=typeof globalThis?globalThis:\"undefined\"!=typeof self?self:\"undefined\"!=typeof window?window:\"undefined\"!=typeof global?global:{},$parcel$modules={},$parcel$inits={},parcelRequire=$parcel$global.parcelRequire94c2;null==parcelRequire&&(parcelRequire=function(e){if(e in $parcel$modules)return $parcel$modules[e].exports;if(e in $parcel$inits){var t=$parcel$inits[e];delete $parcel$inits[e];var i={id:e,exports:{}};return $parcel$modules[e]=i,t.call(i.exports,i,i.exports),i.exports}var r=new Error(\"Cannot find module '\"+e+\"'\");throw r.code=\"MODULE_NOT_FOUND\",r},parcelRequire.register=function(e,t){$parcel$inits[e]=t},$parcel$global.parcelRequire94c2=parcelRequire),parcelRequire.register(\"8Makm\",(function(e,t){var i=parcelRequire(\"gxpqj\"),r=i.UIKit,s=i.ViewController,a=i.TabBarController,n=i.Kernel,o=i.FileStorage,l=i.Setting,c=i.FileManager,h=parcelRequire(\"hOw2h\"),d=parcelRequire(\"imdB1\"),p=parcelRequire(\"44eiF\"),u=parcelRequire(\"gYDdO\"),g=parcelRequire(\"9RsVy\");const $=new o;class f extends n{constructor(){let e;super(),this.query=$context.query,this.fileStorage=$;try{e=__SETTING__}catch{}this.setting=new l({fileStorage:this.fileStorage,structure:e}),this.setting.loadConfig(),this.storage=new h(this),this.initComponents(),g(this)}addOpenInJsboxButton(){this.useJsboxNav(),this.setNavButtons([{image:$image(\"assets/icon.png\"),handler:()=>this.openInJsbox()}])}initComponents(){this.clips=new d(this),this.actionManager=new p(this),this.fileManager=new c}deleteConfirm(e,t){$ui.alert({title:$l10n(\"CONFIRM_DELETE_TITLE\"),message:e,actions:[{title:$l10n(\"DELETE\"),style:$alertActionType.destructive,handler:()=>{t()}},{title:$l10n(\"CANCEL\")}]})}}class b{static kernel=$app.env!==$env.widget?new f:void 0;static renderMainUI(){const e={clips:{icon:\"doc.on.clipboard\",title:$l10n(\"CLIPS\")},actions:{icon:\"command\",title:$l10n(\"ACTIONS\")},setting:{icon:\"gear\",title:$l10n(\"SETTING\")}};if(this.kernel.setting.setEvent(\"onSet\",(e=>{\"mainUIDisplayMode\"===e&&$delay(.3,(()=>$addin.restart()))})),0===this.kernel.setting.get(\"mainUIDisplayMode\"))this.kernel.useJsboxNav(),this.kernel.setting.useJsboxNav(),this.kernel.setNavButtons([{symbol:e.setting.icon,title:e.setting.title,handler:()=>{r.push({title:e.setting.title,views:[this.kernel.setting.getListView()]})}},{symbol:e.actions.icon,title:e.actions.title,handler:()=>{this.kernel.actionManager.present()}}]),this.kernel.UIRender(this.kernel.clips.getNavigationView().getPage());else{this.kernel.fileManager.setViewController(new s),this.kernel.tabBarController=new a;const t=this.kernel.clips.getNavigationView();this.kernel.tabBarController.setPages({clips:t.getPage(),actions:this.kernel.actionManager.getPage(),setting:this.kernel.setting.getPage()}).setCells({clips:e.clips,actions:e.actions,setting:e.setting}),this.kernel.UIRender(this.kernel.tabBarController.generateView().definition)}}static renderKeyboardUI(){this.kernel.addOpenInJsboxButton();const e=new(parcelRequire(\"7eNYp\"))(this.kernel);this.kernel.UIRender(e.getView())}static renderTodayUI(){this.kernel.addOpenInJsboxButton();const e=new(parcelRequire(\"49je6\"))(this.kernel);this.kernel.UIRender(e.getView())}static renderUnsupported(){$intents.finish(\"不支持在此环境中运行\"),$ui.render({views:[{type:\"label\",props:{text:\"不支持在此环境中运行\",align:$align.center},layout:$layout.fill}]})}}class y{static widgetInstance(e,...t){if($file.exists(`/scripts/widget/${e}.js`)){const{Widget:i}=require(`./widget/${e}.js`);return new i(...t)}return!1}static renderError(){$widget.setTimeline({render:()=>({type:\"text\",props:{text:\"Invalid argument\"}})})}static renderClipboard(){const e=new l;e.loadConfig().setReadonly();y.widgetInstance(\"Clipboard\",e,new h({fileStorage:$})).render()}static render(e=$widget.inputValue){\"Clipboard\"===(e=e??\"Clipboard\")?y.renderClipboard():y.renderError()}}e.exports={Widget:y,run:()=>{u(b.kernel),$app.env===$env.app||$app.env===$env.action?b.renderMainUI():$app.env===$env.keyboard?b.renderKeyboardUI():$app.env===$env.widget?y.render():$app.env===$env.today?b.renderTodayUI():b.renderUnsupported()}}})),parcelRequire.register(\"gxpqj\",(function(module,exports){var $parcel$global=\"undefined\"!=typeof globalThis?globalThis:\"undefined\"!=typeof self?self:\"undefined\"!=typeof window?window:void 0!==$parcel$global?$parcel$global:{},$parcel$modules={},$parcel$inits={},parcelRequire=$parcel$global.parcelRequire94c2;null==parcelRequire&&(parcelRequire=function(e){if(e in $parcel$modules)return $parcel$modules[e].exports;if(e in $parcel$inits){var t=$parcel$inits[e];delete $parcel$inits[e];var i={id:e,exports:{}};return $parcel$modules[e]=i,t.call(i.exports,i,i.exports),i.exports}var r=new Error(\"Cannot find module '\"+e+\"'\");throw r.code=\"MODULE_NOT_FOUND\",r},parcelRequire.register=function(e,t){$parcel$inits[e]=t},$parcel$global.parcelRequire94c2=parcelRequire),parcelRequire.register(\"45Ip7\",(function(e,t){class i{static#e=$objc(\"UIApplication\").$sharedApplication();static#t=$objc(\"UINotificationFeedbackGenerator\").$new();static feedbackSuccess(){i.#t.$notificationOccurred(0)}static feedbackError(){i.#t.$notificationOccurred(2)}static align={left:0,right:1,top:2,bottom:3};static textColor=$color(\"primaryText\");static linkColor=$color(\"systemLink\");static primaryViewBackgroundColor=$color(\"primarySurface\");static scrollViewBackgroundColor=$color(\"insetGroupedBackground\");static scrollViewList=[\"list\",\"matrix\"];static isLargeScreen=$device.isIpad||$device.isIpadPro;static get windowSize(){return $objc(\"UIWindow\").$keyWindow().jsValue().size}static NavigationBarNormalHeight=$objc(\"UINavigationController\").invoke(\"alloc.init\").$navigationBar().jsValue().frame.height;static NavigationBarLargeTitleHeight=$objc(\"UITabBarController\").invoke(\"alloc.init\").$tabBar().jsValue().frame.height+i.NavigationBarNormalHeight;static get isSplitScreenMode(){return i.isLargeScreen&&$device.info.screen.width!==i.windowSize.width}static get topSafeAreaInsets(){return i.#e?.$keyWindow()?.$safeAreaInsets()?.top??0}static get bottomSafeAreaInsets(){return i.#e?.$keyWindow()?.$safeAreaInsets()?.bottom??0}static get statusBarOrientation(){return i.#e.$statusBarOrientation()}static get consoleBarHeight(){if($app.isDebugging){let e=i.#e.$statusBarFrame().height+26;return $device.isIphoneX&&(e+=30),e}return 0}static get isHorizontal(){return 3===i.statusBarOrientation||4===i.statusBarOrientation}static loading(){const e=$ui.create(i.blurBox({cornerRadius:15},[{type:\"spinner\",props:{loading:!0,style:0},layout:(e,t)=>{e.size.equalTo(t.prev),e.center.equalTo(t.super)}}]));return{start:()=>{$ui.controller.view.insertAtIndex(e,0),e.layout(((e,t)=>{e.center.equalTo(t.super);const r=Math.min(.6*Math.min(i.windowSize.width,i.windowSize.height),260);e.size.equalTo($size(r,r))})),e.moveToFront()},end:()=>{e.remove()}}}static defaultBackgroundColor(e){return i.scrollViewList.indexOf(e)>-1?i.scrollViewBackgroundColor:i.primaryViewBackgroundColor}static separatorLine(e={},t=i.align.bottom){return{type:\"canvas\",props:e,layout:(e,r)=>{void 0===r.prev?e.top.equalTo(r.super):t===i.align.bottom?e.top.equalTo(r.prev.bottom):e.top.equalTo(r.prev.top),e.height.equalTo(1/$device.info.screen.scale),e.left.right.inset(0)},events:{draw:(t,i)=>{i.strokeColor=e.bgcolor??$color(\"separatorColor\"),i.setLineWidth(1),i.moveToPoint(0,0),i.addLineToPoint(t.frame.width,0),i.strokePath()}}}}static blurBox(e={},t=[],i=$layout.fill){return{type:\"blur\",props:Object.assign({style:$blurStyle.thinMaterial},e),views:t,layout:i}}static getContentSize(e,t=\"A\",r=i.windowSize.width,s){const a={text:t,width:r,font:e};return void 0!==s&&(a.lineSpacing=s),$text.sizeThatFits(a)}static push({views:e,statusBarStyle:t=0,title:i=\"\",navButtons:r=[{title:\"\"}],bgcolor:s=e[0]?.props?.bgcolor??\"primarySurface\",disappeared:a}={}){$ui.push({props:{statusBarStyle:t,navButtons:r,title:i,bgcolor:\"string\"==typeof s?$color(s):s},events:{disappeared:()=>{void 0!==a&&a()}},views:[{type:\"view\",views:e,layout:(e,t)=>{e.top.equalTo(t.super.safeArea),e.bottom.equalTo(t.super),e.left.right.equalTo(t.super.safeArea)}}]})}}e.exports={UIKit:i}})),parcelRequire.register(\"7D8Kb\",(function(module,exports){var $fYz8N=parcelRequire(\"fYz8N\"),$58e2f5443faff7c0$require$Controller=$fYz8N.Controller,$8aDdQ=parcelRequire(\"8aDdQ\"),$58e2f5443faff7c0$require$FileStorageFileNotFoundError=$8aDdQ.FileStorageFileNotFoundError,$58e2f5443faff7c0$require$FileStorage=$8aDdQ.FileStorage,$cgaQ6=parcelRequire(\"cgaQ6\"),$58e2f5443faff7c0$require$Kernel=$cgaQ6.Kernel,$45Ip7=parcelRequire(\"45Ip7\"),$58e2f5443faff7c0$require$UIKit=$45Ip7.UIKit,$aXWmO=parcelRequire(\"aXWmO\"),$58e2f5443faff7c0$require$Sheet=$aXWmO.Sheet,$12xzj=parcelRequire(\"12xzj\"),$58e2f5443faff7c0$require$NavigationView=$12xzj.NavigationView,$dcStC=parcelRequire(\"dcStC\"),$58e2f5443faff7c0$require$NavigationBar=$dcStC.NavigationBar,$gMc1q=parcelRequire(\"gMc1q\"),$58e2f5443faff7c0$require$ViewController=$gMc1q.ViewController;class SettingLoadConfigError extends Error{constructor(){super(\"Call loadConfig() first.\"),this.name=\"SettingLoadConfigError\"}}class SettingReadonlyError extends Error{constructor(){super(\"Attempted to assign to readonly property.\"),this.name=\"SettingReadonlyError\"}}class Setting extends $58e2f5443faff7c0$require$Controller{name;setting={};userData;fileStorage;imagePath;viewController=new $58e2f5443faff7c0$require$ViewController;method={readme:()=>{const e=(()=>{const e=$device.info?.language?.startsWith(\"zh\")?\"README_CN.md\":\"README.md\";try{return __README__[e]??__README__[\"README.md\"]}catch{return $file.read(e)?.string??$file.read(\"README.md\")?.string}})();(new $58e2f5443faff7c0$require$Sheet).setView({type:\"markdown\",props:{content:e},layout:(e,t)=>{e.size.equalTo(t.super)}}).init().present()}};rowHeight=50;edgeOffset=10;iconSize=30;#i={};#r=!1;#s=!1;#a;constructor(e={}){super(),\"function\"==typeof e.set&&\"function\"==typeof e.get?(this.set=e.set,this.get=e.get,this.userData=e.userData):(this.fileStorage=e.fileStorage??new $58e2f5443faff7c0$require$FileStorage,this.dataFile=e.dataFile??\"setting.json\"),e.structure?this.setStructure(e.structure):this.setStructurePath(e.structurePath??\"setting.json\"),this.isUseJsboxNav=e.isUseJsboxNav??!1,this.imagePath=(e.name??\"default\")+\".image/\",this.setName(e.name??$text.uuid),this.loadL10n()}useJsboxNav(){return this.isUseJsboxNav=!0,this}#n(){if(!this.#s)throw new SettingLoadConfigError}loadConfig(){const e=[\"script\",\"info\"],t=this.userData??this.fileStorage.readAsJSON(this.dataFile,{});return this.setting=function i(r){const s={};for(let a of r)for(let r of a.items)if(\"child\"===r.type){const e=i(r.children);Object.assign(s,e)}else-1===e.indexOf(r.type)?s[r.key]=r.key in t?t[r.key]:r.value:s[r.key]=r.value;return s}(this.structure),this.#s=!0,this}hasSectionTitle(e){return this.#n(),!!e[0]?.title}loadL10n(){$58e2f5443faff7c0$require$Kernel.l10n(\"zh-Hans\",{OK:\"好\",DONE:\"完成\",CANCEL:\"取消\",CLEAR:\"清除\",BACK:\"返回\",ERROR:\"发生错误\",SUCCESS:\"成功\",LOADING:\"加载中\",INVALID_VALUE:\"非法参数\",CONFIRM_CHANGES:\"数据已变化,确认修改?\",SETTING:\"设置\",GENERAL:\"一般\",ADVANCED:\"高级\",TIPS:\"小贴士\",COLOR:\"颜色\",COPY:\"复制\",COPIED:\"复制成功\",JSBOX_ICON:\"JSBox 内置图标\",SF_SYMBOLS:\"SF Symbols\",IMAGE_BASE64:\"图片 / base64\",PREVIEW:\"预览\",SELECT_IMAGE:\"选择图片\",CLEAR_IMAGE:\"清除图片\",NO_IMAGE:\"无图片\",ABOUT:\"关于\",VERSION:\"Version\",AUTHOR:\"作者\",AT_BOTTOM:\"已经到底啦~\"},!1),$58e2f5443faff7c0$require$Kernel.l10n(\"en\",{OK:\"OK\",DONE:\"Done\",CANCEL:\"Cancel\",CLEAR:\"Clear\",BACK:\"Back\",ERROR:\"Error\",SUCCESS:\"Success\",LOADING:\"Loading\",INVALID_VALUE:\"Invalid value\",CONFIRM_CHANGES:\"The data has changed, confirm the modification?\",SETTING:\"Setting\",GENERAL:\"General\",ADVANCED:\"Advanced\",TIPS:\"Tips\",COLOR:\"Color\",COPY:\"Copy\",COPIED:\"Copide\",JSBOX_ICON:\"JSBox in app icon\",SF_SYMBOLS:\"SF Symbols\",IMAGE_BASE64:\"Image / base64\",PREVIEW:\"Preview\",SELECT_IMAGE:\"Select Image\",CLEAR_IMAGE:\"Clear Image\",NO_IMAGE:\"No Image\",ABOUT:\"About\",VERSION:\"Version\",AUTHOR:\"Author\",AT_BOTTOM:\"It's the end~\"},!1)}setUserData(e){this.userData=e}setStructure(e){return this.structure=e,this}setStructurePath(e){return this.structure||this.setStructure($58e2f5443faff7c0$require$FileStorage.readFromRootAsJSON(e)),this}setName(e){return this.name=e,this}setFooter(e){return this.#a=e,this}set footer(e){this.#a=e}get footer(){if(void 0===this.#a){let e=$58e2f5443faff7c0$require$FileStorage.readFromRootAsJSON(\"config.json\",{}).info??{};if(!e.version||!e.author)try{e=__INFO__}catch{}this.#a={},e.version&&e.author&&(this.#a={type:\"view\",props:{height:70},views:[{type:\"label\",props:{font:$font(14),text:`${$l10n(\"VERSION\")} ${e.version} ♥ ${e.author}`,textColor:$color({light:\"#C0C0C0\",dark:\"#545454\"}),align:$align.center},layout:e=>{e.left.right.inset(0),e.top.inset(10)}}]})}return this.#a}setReadonly(){return this.#r=!0,this}set(e,t){if(this.#r)throw new SettingReadonlyError;return this.#n(),this.setting[e]=t,this.fileStorage.write(this.dataFile,$data({string:JSON.stringify(this.setting)})),this.callEvent(\"onSet\",e,t),!0}get(e,t=null){return this.#n(),Object.prototype.hasOwnProperty.call(this.setting,e)?this.setting[e]:t}getColor(e){return\"string\"==typeof e?$color(e):$rgba(e.red,e.green,e.blue,e.alpha)}getImagePath(e,t=!1){let i=$text.MD5(e)+\".jpg\";return t&&(i=\"compress.\"+i),this.imagePath+i}getImage(e,t=!1){try{return this.fileStorage.readSync(this.getImagePath(e,t)).image}catch(e){if(e instanceof $58e2f5443faff7c0$require$FileStorageFileNotFoundError)return null;throw e}}getId(e){return`setting-${this.name}-${e}`}#o(e){$(e).bgcolor=$color(\"systemFill\")}#l(e,t=.3){0===t?$(e).bgcolor=$color(\"clear\"):$ui.animate({duration:t,animation:()=>{$(e).bgcolor=$color(\"clear\")}})}#c(e,t,i=!1,r=0){if(t=Object.assign(t,{touchesBegan:()=>{this.#o(e),this.#i[e]=$delay(1,(()=>this.#l(e,0)))},touchesMoved:()=>{this.#i[e]?.cancel(),this.#l(e,0)}}),i){const i=t.tapped;t.tapped=()=>{this.#o(e),setTimeout((()=>this.#l(e)),1e3*r),\"function\"==typeof i&&i()}}return t}createLineLabel(e,t){return t[1]||(t[1]=\"#00CC00\"),\"object\"!=typeof t[1]&&(t[1]=[t[1],t[1]]),\"object\"!=typeof t[0]&&(t[0]=[t[0],t[0]]),{type:\"view\",views:[{type:\"view\",props:{bgcolor:$color(t[1][0],t[1][1]),cornerRadius:5,smoothCorners:!0},views:[{type:\"image\",props:{tintColor:$color(\"white\"),image:$image(t[0][0],t[0][1])},layout:(e,t)=>{e.center.equalTo(t.super),e.size.equalTo(20)}}],layout:(e,t)=>{e.centerY.equalTo(t.super),e.size.equalTo(this.iconSize),e.left.inset(this.edgeOffset)}},{type:\"label\",props:{text:e,lines:1,textColor:this.textColor,align:$align.left},layout:(e,t)=>{e.centerY.equalTo(t.super),e.height.equalTo(t.super),e.left.equalTo(t.prev.right).offset(this.edgeOffset),e.width.greaterThanOrEqualTo(10)}}],layout:(e,t)=>{e.height.centerY.equalTo(t.super),e.left.inset(0)}}}createInfo(e,t,i){const r=Array.isArray(i),s=r?i[0]:i,a=r?i[1]:i;return{type:\"view\",props:{selectable:!0},views:[this.createLineLabel(t,e),{type:\"label\",props:{text:s,align:$align.right,textColor:$color(\"darkGray\")},layout:(e,t)=>{e.centerY.equalTo(t.prev),e.right.inset(this.edgeOffset),e.width.equalTo(180)}},{type:\"view\",events:{tapped:()=>{$ui.alert({title:t,message:a,actions:[{title:$l10n(\"COPY\"),handler:()=>{$clipboard.text=a,$ui.toast($l10n(\"COPIED\"))}},{title:$l10n(\"OK\")}]})}},layout:(e,t)=>{e.right.inset(0),e.size.equalTo(t.super)}}],layout:$layout.fill}}createSwitch(e,t,i){return{type:\"view\",props:{id:this.getId(e),selectable:!0},views:[this.createLineLabel(i,t),{type:\"switch\",props:{on:this.get(e),onColor:$color(\"#00CC00\")},events:{changed:t=>{try{this.set(e,t.on)}catch(e){throw t.on=!t.on,e}}},layout:(e,t)=>{e.centerY.equalTo(t.prev),e.right.inset(this.edgeOffset)}}],layout:$layout.fill}}createString(e,t,i){return{type:\"view\",props:{id:this.getId(e),selectable:!0},views:[this.createLineLabel(i,t),{type:\"button\",props:{symbol:\"square.and.pencil\",bgcolor:$color(\"clear\"),tintColor:$color(\"primaryText\")},events:{tapped:t=>{const i=$ui.popover({sourceView:t,sourceRect:t.bounds,directions:$popoverDirection.down,size:$size(320,150),views:[{type:\"text\",props:{id:`${this.name}-string-${e}`,align:$align.left,text:this.get(e)},layout:e=>{e.left.right.inset(10),e.top.inset(20),e.height.equalTo(90)}},{type:\"button\",props:{symbol:\"checkmark\",bgcolor:$color(\"clear\"),titleEdgeInsets:10,contentEdgeInsets:0},layout:e=>{e.right.inset(10),e.bottom.inset(25),e.size.equalTo(30)},events:{tapped:()=>{this.set(e,$(`${this.name}-string-${e}`).text),i.dismiss()}}}]})}},layout:(e,t)=>{e.centerY.equalTo(t.prev),e.right.inset(0),e.size.equalTo(50)}}],layout:$layout.fill}}createStepper(e,t,i,r,s){const a=this.getId(e),n=`${a}-label`;return{type:\"view\",props:{id:a,selectable:!0},views:[this.createLineLabel(i,t),{type:\"label\",props:{id:n,text:this.get(e),textColor:this.textColor,align:$align.left},layout:(e,t)=>{e.height.equalTo(t.super),e.right.inset(120)}},{type:\"stepper\",props:{min:r,max:s,value:this.get(e)},events:{changed:t=>{$(n).text=t.value;try{this.set(e,t.value)}catch(t){throw $(n).text=this.get(e),t}}},layout:(e,t)=>{e.centerY.equalTo(t.prev),e.right.inset(this.edgeOffset)}}],layout:$layout.fill}}createScript(key,icon,title,script){const id=this.getId(key),buttonId=`${id}-button`,actionStart=()=>{$(buttonId).alpha=0,$(`${buttonId}-spinner`).alpha=1,this.#o(id)},actionCancel=()=>{$(buttonId).alpha=1,$(`${buttonId}-spinner`).alpha=0,this.#l(id)},actionDone=(e=!0,t=$l10n(\"ERROR\"))=>{$(`${buttonId}-spinner`).alpha=0,this.#l(id);const i=$(buttonId);if(!e)return $ui.toast(t),void(i.alpha=1);i.symbol=\"checkmark\",$ui.animate({duration:.6,animation:()=>{i.alpha=1},completion:()=>{setTimeout((()=>{$ui.animate({duration:.4,animation:()=>{i.alpha=0},completion:()=>{i.symbol=\"chevron.right\",$ui.animate({duration:.4,animation:()=>{i.alpha=1},completion:()=>{i.alpha=1}})}})}),600)}})};return{type:\"view\",props:{id:id},views:[this.createLineLabel(title,icon),{type:\"view\",views:[{type:\"image\",props:{id:buttonId,symbol:\"chevron.right\",tintColor:$color(\"secondaryText\")},layout:(e,t)=>{e.centerY.equalTo(t.super),e.right.inset(0),e.size.equalTo(15)}},{type:\"spinner\",props:{id:`${buttonId}-spinner`,loading:!0,alpha:0},layout:(e,t)=>{e.size.equalTo(t.prev),e.left.top.equalTo(t.prev)}}],layout:(e,t)=>{e.right.inset(this.edgeOffset),e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],events:this.#c(id,{tapped:()=>{const animate={actionStart:actionStart,actionCancel:actionCancel,actionDone:actionDone,touchHighlightStart:()=>this.#o(id),touchHighlightEnd:()=>this.#l(id)};\"function\"==typeof script?script(animate):script.startsWith(\"this\")?eval(`(()=>{return ${script}(animate)})()`):eval(script)}}),layout:$layout.fill}}createTab(key,icon,title,items,values){\"string\"==typeof items?items=eval(`(()=>{return ${items}()})()`):\"function\"==typeof items&&(items=items()),\"string\"==typeof values?values=eval(`(()=>{return ${values}()})()`):\"function\"==typeof values&&(values=values());const id=this.getId(key),isCustomizeValues=items?.length>0&&values?.length===items?.length;return{type:\"view\",props:{id:id,selectable:!0},views:[this.createLineLabel(title,icon),{type:\"tab\",props:{items:items??[],index:isCustomizeValues?values.indexOf(this.get(key)):this.get(key),dynamicWidth:!0},layout:(e,t)=>{e.right.inset(this.edgeOffset),e.centerY.equalTo(t.prev)},events:{changed:e=>{isCustomizeValues?this.set(key,values[e.index]):this.set(key,e.index)}}}],layout:$layout.fill}}createMenu(key,icon,title,items,values){const id=this.getId(key),labelId=`${id}-label`,getItems=()=>{let res;return res=\"string\"==typeof items?eval(`(()=>{return ${items}()})()`):\"function\"==typeof items?items():items??[],res},getValues=()=>{let res;return res=\"string\"==typeof values?eval(`(()=>{return ${values}()})()`):\"function\"==typeof values?values():values,res},tmpItems=getItems(),tmpValues=getValues(),isCustomizeValues=tmpItems?.length>0&&tmpValues?.length===tmpItems?.length;return{type:\"view\",props:{id:id,selectable:!0},views:[this.createLineLabel(title,icon),{type:\"view\",views:[{type:\"label\",props:{text:isCustomizeValues?tmpItems[tmpValues.indexOf(this.get(key))]:tmpItems[this.get(key)],color:$color(\"secondaryText\"),id:labelId},layout:(e,t)=>{e.right.inset(0),e.height.equalTo(t.super)}}],layout:(e,t)=>{e.right.inset(this.edgeOffset),e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],events:{tapped:()=>{const e=getItems(),t=getValues();$ui.menu({items:e,handler:(e,i)=>{isCustomizeValues?this.set(key,t[i]):this.set(key,i),$(labelId).text=$l10n(e)}})}},layout:$layout.fill}}createColor(e,t,i){const r=this.getId(e),s=`${r}-color`;return{type:\"view\",props:{id:r,selectable:!0},views:[this.createLineLabel(i,t),{type:\"view\",views:[{type:\"view\",props:{id:s,bgcolor:this.getColor(this.get(e)),circular:!0,borderWidth:1,borderColor:$color(\"#e3e3e3\")},layout:(e,t)=>{e.centerY.equalTo(t.super),e.right.inset(this.edgeOffset),e.size.equalTo(20)}},{type:\"view\",events:{tapped:async()=>{const t=await $picker.color({color:this.getColor(this.get(e))});this.set(e,t.components),$(s).bgcolor=$rgba(t.components.red,t.components.green,t.components.blue,t.components.alpha)}},layout:(e,t)=>{e.right.inset(0),e.height.width.equalTo(t.super.height)}}],layout:(e,t)=>{e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],layout:$layout.fill}}createDate(e,t,i,r=2){const s=this.getId(e),a=e=>{let t=\"\";switch(\"number\"==typeof e&&(e=new Date(e)),r){case 0:t=e.toLocaleTimeString();break;case 1:t=e.toLocaleDateString();break;case 2:t=e.toLocaleString()}return t};return{type:\"view\",props:{id:s,selectable:!0},views:[this.createLineLabel(i,t),{type:\"view\",views:[{type:\"label\",props:{id:`${s}-label`,color:$color(\"secondaryText\"),text:this.get(e)?a(this.get(e)):\"None\"},layout:(e,t)=>{e.right.inset(0),e.height.equalTo(t.super)}}],events:{tapped:async()=>{const t=this.get(e),i=await $picker.date({props:{mode:r,date:t||Date.now()}});this.set(e,i.getTime()),$(`${s}-label`).text=a(i)}},layout:(e,t)=>{e.right.inset(this.edgeOffset),e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],layout:$layout.fill}}createNumber(e,t,i){return this.createInput(e,t,i,!1,$kbType.decimal,(t=>\"\"!==t&&/^[0-9]+.?[0-9]*$/.test(t)?this.set(e,Number(t)):($ui.toast($l10n(\"INVALID_VALUE\")),!1)))}createInput(e,t,i,r=!1,s=$kbType.default,a){void 0===a&&(a=t=>this.set(e,t));const n=this.getId(e),o=n+\"-input\";return{type:\"view\",props:{id:n,selectable:!0},views:[this.createLineLabel(i,t),{type:\"input\",props:{id:o,type:s,align:$align.right,bgcolor:$color(\"clear\"),textColor:$color(\"secondaryText\"),text:this.get(e),font:$font(16),secure:r,accessoryView:$58e2f5443faff7c0$require$UIKit.blurBox({height:44},[$58e2f5443faff7c0$require$UIKit.separatorLine({},$58e2f5443faff7c0$require$UIKit.align.top),{type:\"button\",props:{title:$l10n(\"DONE\"),bgcolor:$color(\"clear\"),titleColor:$color(\"primaryText\")},layout:(e,t)=>{e.right.inset(this.edgeOffset),e.centerY.equalTo(t.super)},events:{tapped:()=>{$(o).blur()}}},{type:\"button\",props:{title:$l10n(\"CANCEL\"),bgcolor:$color(\"clear\"),titleColor:$color(\"primaryText\")},layout:(e,t)=>{e.left.inset(this.edgeOffset),e.centerY.equalTo(t.super)},events:{tapped:()=>{const t=$(o),i=this.get(e,\"\");t.text!==i&&(t.text=i),t.blur()}}}])},layout:(t,i)=>{t.left.equalTo(i.prev.get(\"label\").right).offset(this.edgeOffset),t.right.inset(this.edgeOffset);const r=$58e2f5443faff7c0$require$UIKit.getContentSize($font(16),this.get(e)).width;t.width.greaterThanOrEqualTo(r+30),t.height.equalTo(i.super)},events:{didBeginEditing:e=>{e.secure=!1,$app.autoKeyboardEnabled||($app.autoKeyboardEnabled=!0)},returned:e=>{e.blur()},didEndEditing:async t=>{const i=this.get(e,\"\");a(t.text)||(t.text=i),r&&(t.secure=r)}}}],layout:$layout.fill}}createIcon(e,t,i,r=\"#000000\"){const s=this.getId(e),a=`${s}-image`;return{type:\"view\",props:{id:s,selectable:!0},views:[this.createLineLabel(i,t),{type:\"view\",views:[{type:\"image\",props:{cornerRadius:8,bgcolor:\"string\"==typeof r?$color(r):r,smoothCorners:!0},layout:(e,t)=>{e.right.inset(this.edgeOffset),e.centerY.equalTo(t.super),e.size.equalTo($size(30,30))}},{type:\"image\",props:{id:a,image:$image(this.get(e)),icon:$icon(this.get(e).slice(5,this.get(e).indexOf(\".\")),$color(\"#ffffff\")),tintColor:$color(\"#ffffff\")},layout:(e,t)=>{e.right.equalTo(t.prev).offset(-5),e.centerY.equalTo(t.super),e.size.equalTo($size(20,20))}}],events:{tapped:()=>{$ui.menu({items:[$l10n(\"JSBOX_ICON\"),$l10n(\"SF_SYMBOLS\"),$l10n(\"IMAGE_BASE64\")],handler:async(t,i)=>{if(0===i){const t=await $ui.selectIcon();this.set(e,t),$(a).icon=$icon(t.slice(5,t.indexOf(\".\")),$color(\"#ffffff\"))}else 1!==i&&2!==i||$input.text({text:\"\",placeholder:t,handler:t=>{\"\"!==t?(this.set(e,t),1===i?$(a).symbol=t:$(a).image=$image(t)):$ui.toast($l10n(\"INVALID_VALUE\"))}})}})}},layout:(e,t)=>{e.right.inset(0),e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],layout:$layout.fill}}createPush(key,icon,title,view,tapped){const id=this.getId(key);return{type:\"view\",layout:$layout.fill,props:{id:id,selectable:!0},views:[this.createLineLabel(title,icon),{type:\"image\",props:{symbol:\"chevron.right\",tintColor:$color(\"secondaryText\")},layout:(e,t)=>{e.centerY.equalTo(t.super),e.right.inset(this.edgeOffset),e.size.equalTo(15)}}],events:{tapped:()=>{const push=view=>{if(\"string\"==typeof view&&view.startsWith(\"this.method\")?view=eval(`(()=>{return ${view}()})()`):\"function\"==typeof view&&(view=view()),this.isUseJsboxNav)$58e2f5443faff7c0$require$UIKit.push({title:title,props:view.props??{},views:[view]});else{const e=new $58e2f5443faff7c0$require$NavigationView;e.setView(view).navigationBarTitle(title),e.navigationBarItems.addPopButton(),e.navigationBar.setLargeTitleDisplayMode($58e2f5443faff7c0$require$NavigationBar.largeTitleDisplayModeNever),this.hasSectionTitle(view)&&e.navigationBar.setContentViewHeightOffset(-10),this.viewController.push(e)}};\"function\"==typeof tapped?tapped(push):push(view)}}}}createChild(e,t,i,r){return this.createPush(e,t,i,void 0,(e=>{this.events?.onChildPush?this.callEvent(\"onChildPush\",this.getListView(r,{}),i):e(this.getListView(r,{}))}))}createImage(e,t,i){const r=this.getId(e),s=`${r}-image`,a=$image(\"questionmark.square.dashed\");return{type:\"view\",props:{id:r,selectable:!0},views:[this.createLineLabel(i,t),{type:\"view\",views:[{type:\"image\",props:{id:s,image:this.getImage(e,!0)??a},layout:(e,t)=>{e.right.inset(this.edgeOffset),e.centerY.equalTo(t.super),e.size.equalTo($size(30,30))}}],events:{tapped:()=>{this.#o(r),$ui.menu({items:[$l10n(\"PREVIEW\"),$l10n(\"SELECT_IMAGE\"),$l10n(\"CLEAR_IMAGE\")],handler:(t,i)=>{if(0===i){const t=this.getImage(e);t?$quicklook.open({image:t}):$ui.toast($l10n(\"NO_IMAGE\"))}else 1===i?$photo.pick({format:\"data\"}).then((t=>{if($ui.toast($l10n(\"LOADING\")),!t.status||!t.data)return void(\"canceled\"!==t?.error?.description&&$ui.toast($l10n(\"ERROR\")));const i=$58e2f5443faff7c0$require$Kernel.compressImage(t.data.image);this.fileStorage.write(this.getImagePath(e,!0),i.jpg(.8)),this.fileStorage.write(this.getImagePath(e),t.data),$(s).image=i,$ui.success($l10n(\"SUCCESS\"))})):2===i&&(this.fileStorage.delete(this.getImagePath(e,!0)),this.fileStorage.delete(this.getImagePath(e)),$(s).image=a,$ui.success($l10n(\"SUCCESS\")))},finished:()=>{this.#l(r)}})}},layout:(e,t)=>{e.right.inset(0),e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],layout:$layout.fill}}#h(e){const t=[];for(let i of e){const e=[];for(let t of i.items){const i=this.get(t.key);let r=null;switch(t.icon||(t.icon=[\"square.grid.2x2.fill\",\"#00CC00\"]),\"object\"==typeof t.items&&(t.items=t.items.map((e=>$l10n(e)))),t.title=$l10n(t.title),t.type){case\"switch\":r=this.createSwitch(t.key,t.icon,t.title);break;case\"stepper\":r=this.createStepper(t.key,t.icon,t.title,t.min??1,t.max??12);break;case\"string\":r=this.createString(t.key,t.icon,t.title);break;case\"info\":r=this.createInfo(t.icon,t.title,i);break;case\"script\":r=this.createScript(t.key,t.icon,t.title,i);break;case\"tab\":r=this.createTab(t.key,t.icon,t.title,t.items,t.values);break;case\"menu\":r=this.createMenu(t.key,t.icon,t.title,t.items,t.values);break;case\"color\":r=this.createColor(t.key,t.icon,t.title);break;case\"date\":r=this.createDate(t.key,t.icon,t.title,t.mode);break;case\"number\":r=this.createNumber(t.key,t.icon,t.title);break;case\"input\":r=this.createInput(t.key,t.icon,t.title,t.secure);break;case\"icon\":r=this.createIcon(t.key,t.icon,t.title,t.bgcolor);break;case\"push\":r=this.createPush(t.key,t.icon,t.title,t.view);break;case\"child\":r=this.createChild(t.key,t.icon,t.title,t.children);break;case\"image\":r=this.createImage(t.key,t.icon,t.title);break;default:continue}e.push(r)}t.push({title:$l10n(i.title??\"\"),rows:e})}return t}getListView(e,t=this.footer){return{type:\"list\",props:{id:this.name,style:2,separatorInset:$insets(0,this.iconSize+2*this.edgeOffset,0,this.edgeOffset),bgcolor:$58e2f5443faff7c0$require$UIKit.scrollViewBackgroundColor,footer:t,data:this.#h(e??this.structure)},layout:$layout.fill,events:{rowHeight:(e,t)=>(e.object(t)?.props?.info??{}).rowHeight??this.rowHeight}}}getPage(){const e=new $58e2f5443faff7c0$require$NavigationView;return e.setView(this.getListView(this.structure)).navigationBarTitle($l10n(\"SETTING\")),this.hasSectionTitle(this.structure)&&e.navigationBar.setContentViewHeightOffset(-10),e.getPage()}}module.exports={Setting:Setting}})),parcelRequire.register(\"fYz8N\",(function(e,t){e.exports={Controller:class{events={};setEvents(e){return Object.keys(e).forEach((t=>this.setEvent(t,e[t]))),this}setEvent(e,t){return this.events[e]=t,this}callEvent(e,...t){\"function\"==typeof this.events[e]&&this.events[e](...t)}}}})),parcelRequire.register(\"8aDdQ\",(function(e,t){class i extends Error{constructor(e){super(`Parameter [${e}] is required.`),this.name=\"FileStorageParameterError\"}}class r extends Error{constructor(e){super(`File not found: ${e}`),this.name=\"FileStorageFileNotFoundError\"}}class s{basePath;constructor({basePath:e=\"storage\"}={}){this.basePath=e,this.#d(this.basePath)}#d(e){$file.isDirectory(e)||$file.mkdir(e)}filePath(e=\"\",t=!0){e.startsWith(\"/\")&&(e=e.substring(1));let i=\"\";if(!(e=`${this.basePath}/${e}`).endsWith(\"/\")){const t=e.lastIndexOf(\"/\");e.lastIndexOf(\".\")>t&&(i=e.substring(t+1),e=e.substring(0,t+1))}return t&&this.#d(e),e+i}exists(e=\"\"){return e=this.filePath(e,!1),!!$file.exists(e)}write(e=\"\",t){return new Promise(((i,r)=>{try{const s=this.writeSync(e,t);s?i(s):r(s)}catch(e){r(e)}}))}writeSync(e=\"\",t){if(!t)throw new i(\"data\");return $file.write({data:t,path:this.filePath(e)})}read(e=\"\"){return new Promise(((t,i)=>{try{const r=this.readSync(e);r?t(r):i()}catch(e){i(e)}}))}readSync(e=\"\"){if(e=this.filePath(e),!$file.exists(e))throw new r(e);return $file.isDirectory(e)?$file.list(e):$file.read(e)}readAsJSON(e=\"\",t=null){try{const t=this.readSync(e)?.string;return JSON.parse(t)}catch(e){return t}}static readFromRoot(e=\"\"){return new Promise(((t,i)=>{try{const r=s.readFromRootSync(e);r?t(r):i()}catch(e){i(e)}}))}static readFromRootSync(e=\"\"){if(!e)throw new i(\"path\");if(!$file.exists(e))throw new r(e);return $file.isDirectory(e)?$file.list(e):$file.read(e)}static readFromRootAsJSON(e=\"\",t=null){try{const t=s.readFromRootSync(e)?.string;return JSON.parse(t)}catch(e){return t}}delete(e=\"\"){return $file.delete(this.filePath(e,!1))}copy(e,t){e=this.filePath(e),t=this.filePath(t),$file.copy({src:e,dst:t})}move(e,t){e=this.filePath(e),t=this.filePath(t),$file.move({src:e,dst:t})}}e.exports={FileStorageParameterError:i,FileStorageFileNotFoundError:r,FileStorage:s}})),parcelRequire.register(\"cgaQ6\",(function(e,t){var i=parcelRequire(\"czAIJ\").VERSION;class r{startTime=Date.now();isUseJsboxNav=!1;title=$addin?.current?.name;constructor(){$app.isDebugging&&this.debug()}static isTaio=$app.info.bundleID.includes(\"taio\");static l10n(e,t,i=!0){if(\"string\"==typeof t){const e={};t.split(\";\").forEach((t=>{if(\"\"!==(t=t.trim())){const i=t.split(\"=\");e[i[0].trim().slice(1,-1)]=i[1].trim().slice(1,-1)}})),t=e}const r=$app.strings;r[e]=i?Object.assign($app.strings[e],t):Object.assign(t,$app.strings[e]),$app.strings=r}static compressImage(e,t=921600){const i=$imagekit.info(e);if(i.height*i.width>t){const r=t/(i.height*i.width);e=$imagekit.scaleBy(e,r)}return e}static objectEqual(e,t){let i=Object.getOwnPropertyNames(e),s=Object.getOwnPropertyNames(t);if(i.length!==s.length)return!1;for(let s=0;se?i[e]:0,s=isNaN(Number(t))?t.charCodeAt():Number(t),n=r.length>e?r[e]:0,o=isNaN(Number(n))?n.charCodeAt():Number(n);if(so){a=1;break}}return a}static deleteConfirm(e,t){$ui.alert({title:$l10n(\"DELETE_CONFIRM_TITLE\"),message:e,actions:[{title:$l10n(\"DELETE\"),style:$alertActionType.destructive,handler:()=>{t()}},{title:$l10n(\"CANCEL\")}]})}static bytesToSize(e){if(0===e)return\"0 B\";const t=Math.floor(Math.log(e)/Math.log(1024));return(e/Math.pow(1024,t)).toPrecision(3)+\" \"+[\"B\",\"KB\",\"MB\",\"GB\",\"TB\",\"PB\",\"EB\",\"ZB\",\"YB\"][t]}debug(e,t){this.debugMode=!0,$app.idleTimerDisabled=!0,\"function\"==typeof e&&(this.debugPrint=e),\"function\"==typeof t&&(this.debugError=t),this.print(\"You are running EasyJsBox in debug mode.\")}print(e){this.debugMode&&(\"function\"==typeof this.debugPrint?this.debugPrint(e):console.log(e))}error(e){this.debugMode&&(\"function\"==typeof this.debugError?this.debugError(e):console.error(e))}useJsboxNav(){return this.isUseJsboxNav=!0,this}setTitle(e){this.isUseJsboxNav&&($ui.title=e),this.title=e}setNavButtons(e){this.navButtons=e}openInJsbox(){$app.openURL(`jsbox://run?name=${this.title}`)}UIRender(e){try{e.props=Object.assign({title:this.title,navBarHidden:!this.isUseJsboxNav,navButtons:this.navButtons??[],statusBarStyle:0},e.props),e.events||(e.events={});const t=e.events.layoutSubviews,{UIKit:i}=parcelRequire(\"45Ip7\");e.events.layoutSubviews=()=>{$app.notify({name:\"interfaceOrientationEvent\",object:{statusBarOrientation:i.statusBarOrientation,isHorizontal:i.isHorizontal}}),\"function\"==typeof t&&t()},$ui.render(e)}catch(e){this.print(e)}}async checkUpdate(){const e=await $http.get(\"https://raw.githubusercontent.com/ipuppet/EasyJsBox/dev/src/version.js\");if(e.error)throw e.error;const t=srcRes.data.match(/.*VERSION.?\\\"([0-9\\.]+)\\\"/)[1];if(this.print(`easy-jsbox latest version: ${t}`),r.versionCompare(t,i)>0){const e=await $http.get(\"https://raw.githubusercontent.com/ipuppet/EasyJsBox/dev/dist/easy-jsbox.js\");if(e.error)throw e.error;return e.data}return!1}}r.l10n(\"zh-Hans\",{DELETE_CONFIRM_TITLE:\"删除前确认\"},!1),r.l10n(\"en\",{DELETE_CONFIRM_TITLE:\"Delete Confirmation\"},!1),e.exports={Kernel:r}})),parcelRequire.register(\"czAIJ\",(function(e,t){e.exports={VERSION:\"1.3.3\"}})),parcelRequire.register(\"aXWmO\",(function(e,t){var i=parcelRequire(\"6Xrbz\").ValidationError,r=parcelRequire(\"liCrE\").View,s=parcelRequire(\"45Ip7\").UIKit,a=parcelRequire(\"12xzj\").NavigationView,n=parcelRequire(\"dcStC\").NavigationBar,o=parcelRequire(\"gAYmG\").BarButtonItem;class l extends Error{constructor(){super(\"Please call setView(view) first.\"),this.name=\"SheetAddNavBarError\"}}class c extends i{constructor(e,t){super(e,t),this.name=\"SheetViewTypeError\"}}class h extends r{#p=()=>{};#u=()=>{};style=h.UIModalPresentationStyle.PageSheet;#g=!1;static UIModalPresentationStyle={Automatic:-2,FullScreen:0,PageSheet:1,FormSheet:2,CurrentContext:3,Custom:4,OverFullScreen:5,OverCurrentContext:6,Popover:7,BlurOverFullScreen:8};navigationView;init(){const{width:e,height:t}=$device.info.screen,i=$objc(\"UIView\").invoke(\"initWithFrame\",$rect(0,0,e,t)),r=$objc(\"UIViewController\").invoke(\"alloc.init\"),a=r.$view();return a.$setBackgroundColor(s.primaryViewBackgroundColor),a.$addSubview(i),r.$setModalPresentationStyle(this.style),r.$setModalInPresentation(this.#g),this.#p=()=>{a.jsValue().add(this.navigationView?.getPage().definition??this.view),$ui.vc.ocValue().invoke(\"presentViewController:animated:completion:\",r,!0,void 0)},this.#u=()=>r.invoke(\"dismissViewControllerAnimated:completion:\",!0,void 0),this}preventDismiss(){return this.#g=!0,this}setStyle(e){return this.style=e,this}setView(e={}){if(\"object\"!=typeof e)throw new c(\"view\",\"object\");return this.view=e,this}addNavBar({title:e=\"\",popButton:t={title:$l10n(\"DONE\")},rightButtons:i=[]}={}){if(void 0===this.view)throw new l;this.navigationView=new a;const r=new o;r.setEvents(Object.assign({tapped:()=>{this.dismiss(),\"function\"==typeof t.tapped&&t.tapped()}},t.events)).setAlign(s.align.left).setSymbol(t.symbol).setTitle(t.title).setColor(t.color).setMenu(t.menu);const c=r.definition.views[0];return c.layout=(e,t)=>{e.left.equalTo(t.super.safeArea).offset(15),e.centerY.equalTo(t.super.safeArea)},this.navigationView.navigationBar.setLargeTitleDisplayMode(n.largeTitleDisplayModeNever).pageSheetMode(),this.navigationView.navigationBarItems.addPopButton(\"\",c).setRightButtons(i),this.navigationView.setView(this.view).navigationBarTitle(e),this.view.props?.bgcolor&&this.navigationView?.getPage().setProp(\"bgcolor\",this.view.props?.bgcolor),this}present(){this.#p()}dismiss(){this.#u()}}e.exports={Sheet:h}})),parcelRequire.register(\"6Xrbz\",(function(e,t){class i extends Error{constructor(e,t){super(`The type of the parameter '${e}' must be '${t}'`),this.name=\"ValidationError\"}}e.exports={ValidationError:i}})),parcelRequire.register(\"liCrE\",(function(e,t){var i=parcelRequire(\"45Ip7\").UIKit;class r{id=$text.uuid;type;props;views;events;layout;#$=void 0;#f=null;constructor({type:e=\"view\",props:t={},views:i=[],events:r={},layout:s=$layout.fill}={}){this.type=e,this.props=t,this.views=i,this.events=r,this.layout=s,this.props.id?this.id=this.props.id:this.props.id=this.id}static create(e){return new this(e)}static createFromViews(e){return new this({views:e})}get scrollableView(){return this.scrollable?this.#f:null}set scrollableView(e){this.#f=e}get scrollable(){if(void 0===this.#$)if(this.#$=!1,i.scrollViewList.indexOf(this.type)>-1)this.scrollableView=this,this.#$=!0;else if(this.views.length>0){const e=t=>{if(!this.#$&&t?.length>0)for(let s=0;s-1)return typeof t[s]!==r&&(t[s]=r.create(t[s])),this.scrollableView=t[s],void(this.#$=!0);e(t[s].views)}};e(this.views)}return this.#$}set scrollable(e){throw new Error(\"[scrollable] is readonly prop.\")}setProps(e){return Object.keys(e).forEach((t=>this.setProp(t,e[t]))),this}setProp(e,t){return\"id\"===e&&(this.id=t),this.props[e]=t,this}setViews(e){return this.views=e,this.#$=void 0,this}setEvents(e){return Object.keys(e).forEach((t=>this.setEvent(t,e[t]))),this}setEvent(e,t){return this.events[e]=t,this}eventMiddleware(e,t){const i=this.events[e];return this.events[e]=(...e)=>{\"function\"==typeof i&&t(i,...e)},this}assignEvent(e,t){const i=this.events[e];return this.events[e]=(...e)=>{\"function\"==typeof i&&i(...e),t(...e)},this}setLayout(e){return this.layout=e,this}getView(){return this}get definition(){return this.getView()}}e.exports={View:r,PageView:class extends r{constructor(e={}){super(e),this.activeStatus=!0}show(){$(this.props.id).hidden=!1,this.activeStatus=!0}hide(){$(this.props.id).hidden=!0,this.activeStatus=!1}setHorizontalSafeArea(e){return this.horizontalSafeArea=e,this}#b(e,t){e.top.bottom.equalTo(t.super),this.horizontalSafeArea?e.left.right.equalTo(t.super.safeArea):e.left.right.equalTo(t.super)}getView(){return this.layout=this.#b,this.props.clipsToBounds=!0,this.props.hidden=!this.activeStatus,super.getView()}}}})),parcelRequire.register(\"12xzj\",(function(e,t){var i=parcelRequire(\"fYz8N\").Controller,r=parcelRequire(\"liCrE\"),s=r.View,a=r.PageView,n=parcelRequire(\"6Xrbz\").ValidationError,o=parcelRequire(\"cgaQ6\").Kernel,l=parcelRequire(\"45Ip7\").UIKit,c=parcelRequire(\"dcStC\"),h=c.NavigationBar,d=c.NavigationBarController,p=parcelRequire(\"gAYmG\").NavigationBarItems;class u extends n{constructor(e,t){super(e,t),this.name=\"NavigationViewTypeError\"}}e.exports={NavigationView:class extends i{page;navigationController=new d;navigationBar=new h;navigationBarItems=new p;constructor(){super(),this.navigationBar.navigationBarItems=this.navigationBarItems,this.navigationController.navigationBar=this.navigationBar}navigationBarTitle(e){return this.navigationBar.setTitle(e),this}setView(e){if(\"object\"!=typeof e)throw new u(\"view\",\"object\");return this.view=s.create(e),this}#y(){if(!(this.view instanceof s))throw new u(\"view\",\"View\");const e=this.view.scrollableView,t=$app.isDebugging||o.isTaio?0:l.topSafeAreaInsets,i=this.navigationBar.largeTitleDisplayMode===h.largeTitleDisplayModeNever?this.navigationBar.navigationBarNormalHeight:this.navigationBar.navigationBarLargeTitleHeight;let r=this.navigationBar.contentViewHeightOffset+i;if(this.navigationBarItems.titleView&&(r+=this.navigationBarItems.titleView.topOffset,r+=this.navigationBarItems.titleView.height,r+=this.navigationBarItems.titleView.bottomOffset),!this.view.scrollable||!1===e.props.associateWithNavigationBar)return void(this.view.layout=(e,i)=>{e.left.right.equalTo(i.super.safeArea),e.bottom.equalTo(i.super);let s=r-this.navigationBar.contentViewHeightOffset;l.isHorizontal&&!l.isLargeScreen||!this.navigationBar.topSafeArea||(s+=t),e.top.equalTo(s)});e.props.stickyHeader&&(r-=i,r+=this.navigationBar.largeTitleFontHeight),e.props.header?e.props.header={type:\"view\",props:{height:r+(e.props.header?.props?.height??0)},views:[{type:\"view\",props:{clipsToBounds:!0},views:[e.props.header],layout:(e,t)=>{e.top.equalTo(r),e.bottom.width.equalTo(t.super)}}]}:e.props.header={props:{height:r}},e.props.footer=Object.assign({props:{}},e.props.footer??{}),e.props.footer.props.height=(this.navigationBarItems.fixedFooterView?.height??0)+(e.props.footer.props?.height??0);const a=this.navigationBarItems.isPinTitleView?this.navigationBarItems.titleView.height+this.navigationBarItems.titleView.bottomOffset+this.navigationBar.contentViewHeightOffset:0;if(e.props.indicatorInsets){const t=e.props.indicatorInsets;e.props.indicatorInsets=$insets(t.top+this.navigationBar.navigationBarNormalHeight+a,t.left,t.bottom+(this.navigationBarItems.fixedFooterView?.height??0),t.right)}else e.props.indicatorInsets=$insets(this.navigationBar.navigationBarNormalHeight+a,0,this.navigationBarItems.fixedFooterView?.height??0,0);e.layout=(t,i)=>{e.props.stickyHeader?t.top.equalTo(i.super.safeArea).offset(this.navigationBar.navigationBarNormalHeight):t.top.equalTo(i.super),t.left.right.equalTo(i.super.safeArea),t.bottom.equalTo(i.super)},e.assignEvent(\"didScroll\",(i=>{let r=i.contentOffset.y;l.isHorizontal&&!l.isLargeScreen||!this.navigationBar.topSafeArea||e.props.stickyHeader||(r+=t),this.navigationController.didScroll(r)})).assignEvent(\"didEndDragging\",((i,r)=>{let s=i.contentOffset.y,a=0;l.isHorizontal&&!l.isLargeScreen||!this.navigationBar.topSafeArea||e.props.stickyHeader||(s+=t,a=t),this.navigationController.didEndDragging(s,r,((...e)=>i.scrollToOffset(...e)),a)})).assignEvent(\"didEndDecelerating\",((...t)=>{t[0].tracking||e.events?.didEndDragging(...t)}))}#m(){if(this.navigationBar.prefersLargeTitles){this.#y();let e={};if(this.navigationBarItems.titleView){const t=this.navigationBar.largeTitleDisplayMode===h.largeTitleDisplayModeNever?1:0;e=s.create({views:[this.navigationBar.backgroundColor?{type:\"view\",props:{alpha:t,bgcolor:this.navigationBar.backgroundColor,id:this.navigationBar.id+\"-title-view-background\"},layout:$layout.fill}:l.blurBox({alpha:t,id:this.navigationBar.id+\"-title-view-background\"}),l.separatorLine({id:this.navigationBar.id+\"-title-view-underline\",alpha:t}),this.navigationBarItems.titleView.definition],layout:(e,t)=>{e.top.equalTo(t.prev.bottom),e.width.equalTo(t.super),e.height.equalTo(this.navigationBarItems.titleView.topOffset+this.navigationBarItems.titleView.height+this.navigationBarItems.titleView.bottomOffset)}})}this.page=a.createFromViews([this.view,this.navigationBar.getLargeTitleView(),e,this.navigationBar.getNavigationBarView(),this.navigationBarItems.fixedFooterView?.definition??{}])}else this.page=a.createFromViews([this.view]);this.view.props?.bgcolor?this.page.setProp(\"bgcolor\",this.view.props.bgcolor):this.page.setProp(\"bgcolor\",l.defaultBackgroundColor(this.view.type))}getPage(){return this.page||this.#m(),this.page}}}})),parcelRequire.register(\"dcStC\",(function(e,t){var i=parcelRequire(\"liCrE\").View,r=parcelRequire(\"fYz8N\").Controller,s=parcelRequire(\"45Ip7\").UIKit;parcelRequire(\"gAYmG\").BarButtonItem;class a extends i{static largeTitleDisplayModeAutomatic=0;static largeTitleDisplayModeAlways=1;static largeTitleDisplayModeNever=2;static pageSheetNavigationBarHeight=56;navigationBarItems;title=\"\";prefersLargeTitles=!0;largeTitleDisplayMode=a.largeTitleDisplayModeAutomatic;largeTitleFontSize=34;largeTitleFontFamily=\"bold\";largeTitleFontHeight=$text.sizeThatFits({text:\"A\",width:100,font:$font(this.largeTitleFontFamily,this.largeTitleFontSize)}).height;navigationBarTitleFontSize=17;topSafeArea=!0;contentViewHeightOffset=10;navigationBarNormalHeight=s.NavigationBarNormalHeight;navigationBarLargeTitleHeight=s.NavigationBarLargeTitleHeight;pageSheetMode(){return this.navigationBarLargeTitleHeight-=this.navigationBarNormalHeight,this.navigationBarNormalHeight=a.pageSheetNavigationBarHeight,this.navigationBarLargeTitleHeight+=this.navigationBarNormalHeight,this.topSafeArea=!1,this}setTopSafeArea(){return this.topSafeArea=!0,this}removeTopSafeArea(){return this.topSafeArea=!1,this}setLargeTitleDisplayMode(e){return this.largeTitleDisplayMode=e,this}setBackgroundColor(e){return this.backgroundColor=e,this}setTitle(e){return this.title=e,this}setPrefersLargeTitles(e){return this.prefersLargeTitles=e,this}setContentViewHeightOffset(e){return this.contentViewHeightOffset=e,this}getLargeTitleView(){return this.prefersLargeTitles&&this.largeTitleDisplayMode!==a.largeTitleDisplayModeNever?{type:\"label\",props:{id:this.id+\"-large-title\",text:this.title,textColor:s.textColor,align:$align.left,font:$font(this.largeTitleFontFamily,this.largeTitleFontSize),line:1},layout:(e,t)=>{e.left.equalTo(t.super.safeArea).offset(15),e.height.equalTo(this.largeTitleFontHeight),e.top.equalTo(t.super.safeAreaTop).offset(this.navigationBarNormalHeight)}}:{props:{id:this.id+\"-large-title\"},layout:(e,t)=>{e.left.top.right.inset(0),e.bottom.equalTo(t.super.safeAreaTop).offset(this.navigationBarNormalHeight)}}}getNavigationBarView(){const e=(e,t)=>{let i=0;const r=[];return e.forEach((e=>{i+=e.width,r.push(e.definition)})),i+=e[0]?.edges??0,e.length>0?{type:\"view\",views:r,layout:(e,r)=>{e.top.equalTo(r.super.safeAreaTop),e.bottom.equalTo(r.super.safeAreaTop).offset(this.navigationBarNormalHeight),t===s.align.left?e.left.equalTo(r.super.safeArea):e.right.equalTo(r.super.safeArea),e.width.equalTo(i)}}:{}},t=e(this.navigationBarItems.rightButtons,s.align.right),i=this.navigationBarItems.popButtonView??e(this.navigationBarItems.leftButtons,s.align.left),r=this.prefersLargeTitles,n=!this.prefersLargeTitles||this.largeTitleDisplayMode===a.largeTitleDisplayModeNever;return{type:\"view\",props:{id:this.id+\"-navigation\",bgcolor:$color(\"clear\")},layout:(e,t)=>{e.left.top.right.inset(0),e.bottom.equalTo(t.super.safeAreaTop).offset(this.navigationBarNormalHeight)},views:[this.backgroundColor?{type:\"view\",props:{hidden:r,bgcolor:this.backgroundColor,id:this.id+\"-background\"},layout:$layout.fill}:s.blurBox({hidden:r,id:this.id+\"-background\"}),s.separatorLine({id:this.id+\"-underline\",alpha:r?0:1}),{type:\"view\",props:{alpha:0,bgcolor:$color(\"clear\"),id:this.id+\"-large-title-mask\"},events:{ready:e=>{e.bgcolor=$(this.id+\"-large-title\")?.prev.bgcolor}},layout:$layout.fill},{type:\"label\",props:{id:this.id+\"-small-title\",alpha:n?1:0,text:this.title,font:$font(this.largeTitleFontFamily,this.navigationBarTitleFontSize),align:$align.center,bgcolor:$color(\"clear\"),textColor:s.textColor},layout:(e,t)=>{e.left.right.inset(0),e.height.equalTo(20),e.centerY.equalTo(t.super.safeArea)}}].concat(t,i)}}}class n extends r{static largeTitleViewSmallMode=0;static largeTitleViewLargeMode=1;navigationBar;updateSelector(){this.selector={navigation:$(this.navigationBar.id+\"-navigation\"),largeTitleView:$(this.navigationBar.id+\"-large-title\"),smallTitleView:$(this.navigationBar.id+\"-small-title\"),underlineView:this.navigationBar.navigationBarItems.isPinTitleView?$(this.navigationBar.id+\"-title-view-underline\"):$(this.navigationBar.id+\"-underline\"),largeTitleMaskView:$(this.navigationBar.id+\"-large-title-mask\"),backgroundView:$(this.navigationBar.id+\"-background\"),titleViewBackgroundView:$(this.navigationBar.id+\"-title-view-background\")}}toNormal(e=!0){this.updateSelector(),this.selector.backgroundView.hidden=!1,$ui.animate({duration:.2,animation:()=>{this.selector.underlineView.alpha=1,this.selector.smallTitleView.alpha=1,this.selector.largeTitleView.alpha=0}}),e&&this.navigationBar.navigationBarItems&&(this.navigationBar.largeTitleDisplayMode=a.largeTitleDisplayModeNever)}toLargeTitle(e=!0){this.updateSelector(),this.selector.backgroundView.hidden=!0,$ui.animate({duration:.2,animation:()=>{this.selector.underlineView.alpha=0,this.selector.smallTitleView.alpha=0,this.selector.largeTitleView.alpha=1}}),e&&this.navigationBar.navigationBarItems&&(this.navigationBar.largeTitleDisplayMode=a.largeTitleDisplayModeAlways)}#v(e){const t=e===n.largeTitleViewSmallMode;this.selector.largeTitleView.alpha=t?0:1,$ui.animate({duration:.2,animation:()=>{this.selector.smallTitleView.alpha=t?1:0}})}#w(e){if(this.selector.largeTitleView.updateLayout(((t,i)=>{this.navigationBar.navigationBarNormalHeight-e>0?t.top.equalTo(i.super.safeAreaTop).offset(this.navigationBar.navigationBarNormalHeight-e):t.top.equalTo(i.super.safeAreaTop).offset(0)})),e>0)e>=this.navigationBar.navigationBarNormalHeight?this.#v(n.largeTitleViewSmallMode):this.#v(n.largeTitleViewLargeMode);else{this.#v(n.largeTitleViewLargeMode);let t=this.navigationBar.largeTitleFontSize-.04*e;t>40&&(t=40),this.selector.largeTitleView.font=$font(this.navigationBar.largeTitleFontFamily,t)}}#T(e){const t=this.navigationBar.largeTitleDisplayMode===a.largeTitleDisplayModeNever?5:this.navigationBar.navigationBarNormalHeight,i=void 0!==this.selector.titleViewBackgroundView;if(e>t){this.selector.backgroundView.hidden=!1;const r=()=>{i&&this.navigationBar.navigationBarItems.isPinTitleView&&(this.selector.titleViewBackgroundView.alpha=1),this.selector.largeTitleMaskView.alpha=0,this.selector.underlineView.alpha=1};(e-t)/3>=1?r():$ui.animate({duration:.2,animation:()=>{r()}})}else this.selector.largeTitleMaskView.alpha=e>0?1:0,this.selector.underlineView.alpha=0,i&&(this.selector.titleViewBackgroundView.alpha=0),this.selector.backgroundView.hidden=!0}didScroll(e){if(!this.navigationBar.prefersLargeTitles)return;const t=this.navigationBar.largeTitleDisplayMode;t!==a.largeTitleDisplayModeAlways&&(this.updateSelector(),t===a.largeTitleDisplayModeAutomatic?(!this.navigationBar.navigationBarItems?.isPinTitleView&&(this.navigationBar.navigationBarItems?.titleView?.controller.didScroll(e),e>0)&&(e-=this.navigationBar.navigationBarItems?.titleView?.height??0)<0&&(e=0),this.#w(e),this.#T(e)):t===a.largeTitleDisplayModeNever&&this.#T(e))}didEndDragging(e,t,i,r){if(!this.navigationBar.prefersLargeTitles)return;const s=this.navigationBar.largeTitleDisplayMode;if(s!==a.largeTitleDisplayModeAlways&&(this.updateSelector(),s===a.largeTitleDisplayModeAutomatic)){let s=0;this.navigationBar.navigationBarItems?.isPinTitleView||(this.navigationBar.navigationBarItems?.titleView?.controller.didEndDragging(e,t,i,r),s=this.navigationBar.navigationBarItems?.titleView?.height??0,e-=s),e>=0&&e<=this.navigationBar.largeTitleFontHeight&&i($point(0,e>=this.navigationBar.largeTitleFontHeight/2?this.navigationBar.navigationBarNormalHeight+s-r:s-r))}}}e.exports={NavigationBar:a,NavigationBarController:n}})),parcelRequire.register(\"gAYmG\",(function(e,t){var i=parcelRequire(\"liCrE\").View,r=parcelRequire(\"45Ip7\").UIKit;class s extends i{static#E;edges=15;iconSize=$size(23,23);fontSize=16;color=r.textColor;title;symbol;align=r.align.right;get width(){if(this.title){const e=$text.sizeThatFits({text:this.title,width:r.windowSize.width,font:$font(this.fontSize)});return Math.ceil(e.width)+this.edges}return this.iconSize.width+this.edges}static get style(){return void 0===this.#E&&(this.#E=new s),this.#E}setEdges(e){return this.edges=e,this}setFontSize(e){return this.fontSize=e,this}setColor(e=r.textColor){return this.color=e,this}setTitle(e){return this.title=e,this}setSymbol(e){return this.symbol=e,this}setMenu(e){return this.menu=e,this}setAlign(e){return this.align=e,this}#I(){$(this.id).hidden=!0,$(\"spinner-\"+this.id).hidden=!1}#C(){const e=$(`icon-button-${this.id}`),t=$(`icon-checkmark-${this.id}`);e.alpha=0,$(this.id).hidden=!1,$(\"spinner-\"+this.id).hidden=!0,$ui.animate({duration:.6,animation:()=>{t.alpha=1},completion:()=>{$delay(.3,(()=>$ui.animate({duration:.6,animation:()=>{t.alpha=0},completion:()=>{$ui.animate({duration:.4,animation:()=>{e.alpha=1},completion:()=>{e.alpha=1}})}})))}})}#A(){$(this.id).hidden=!1,$(\"spinner-\"+this.id).hidden=!0}getView(){const e=this.events.tapped;return this.events.tapped=t=>{e&&e({start:()=>this.#I(),done:()=>this.#C(),cancel:()=>this.#A()},t)},{type:\"view\",props:{info:{align:this.align}},views:[{type:\"button\",props:Object.assign({id:this.id,bgcolor:$color(\"clear\"),font:$font(this.fontSize),titleColor:this.color,contentEdgeInsets:$insets(0,0,0,0),titleEdgeInsets:$insets(0,0,0,0),imageEdgeInsets:$insets(0,0,0,0)},this.menu?{menu:this.menu}:{},this.title?{title:this.title}:{},this.props),views:[{type:\"image\",props:Object.assign({id:`icon-button-${this.id}`,hidden:void 0===this.symbol,tintColor:this.color},void 0===this.symbol?{}:\"string\"==typeof this.symbol?{symbol:this.symbol}:{data:this.symbol.png}),layout:(e,t)=>{e.center.equalTo(t.super),e.size.equalTo(this.iconSize)}},{type:\"image\",props:{id:`icon-checkmark-${this.id}`,alpha:0,tintColor:this.color,symbol:\"checkmark\"},layout:(e,t)=>{e.center.equalTo(t.super),e.size.equalTo(this.iconSize)}}],events:this.events,layout:$layout.fill},{type:\"spinner\",props:{id:\"spinner-\"+this.id,loading:!0,hidden:!0},layout:$layout.fill}],layout:(e,t)=>{if(e.size.equalTo($size(this.width,r.NavigationBarNormalHeight)),e.centerY.equalTo(t.super),t.prev&&t.prev?.info?.align===this.align)this.align===r.align.right?e.right.equalTo(t.prev.left):e.left.equalTo(t.prev.right);else{const t=this.edges/2;this.align===r.align.right?e.right.inset(t):e.left.inset(t)}}}}static creat({symbol:e,title:t,tapped:i,menu:a,events:n,color:o,align:l=r.align.right}={}){const c=new s;return c.setEvents(Object.assign({tapped:i},n)).setAlign(l).setSymbol(e).setTitle(t).setColor(o).setMenu(a),c}}e.exports={BarTitleView:class extends i{controller={};setController(e){return this.controller=e,this}},BarButtonItem:s,NavigationBarItems:class{rightButtons=[];leftButtons=[];hasbutton=!1;isPinTitleView=!1;setTitleView(e){return this.titleView=e,this}pinTitleView(){return this.isPinTitleView=!0,this}setFixedFooterView(e){return this.fixedFooterView=e,this}setRightButtons(e){return e.forEach((e=>this.addRightButton(e))),this.hasbutton||(this.hasbutton=!0),this}setLeftButtons(e){return e.forEach((e=>this.addLeftButton(e))),this.hasbutton||(this.hasbutton=!0),this}addRightButton({symbol:e,title:t,tapped:i,menu:a,events:n,color:o}={}){return this.rightButtons.push(s.creat({symbol:e,title:t,tapped:i,menu:a,events:n,color:o,align:r.align.right})),this.hasbutton||(this.hasbutton=!0),this}addLeftButton({symbol:e,title:t,tapped:i,menu:a,events:n,color:o}={}){return this.leftButtons.push(s.creat({symbol:e,title:t,tapped:i,menu:a,events:n,color:o,align:r.align.left})),this.hasbutton||(this.hasbutton=!0),this}addPopButton(e,t,i){return e||(e=$l10n(\"BACK\")),this.popButtonView=t??{type:\"button\",props:{bgcolor:$color(\"clear\"),symbol:\"chevron.left\",tintColor:r.linkColor,title:` ${e}`,titleColor:r.linkColor,font:$font(\"bold\",16)},layout:(e,t)=>{e.left.equalTo(t.super.safeArea).offset(s.style.edges),e.centerY.equalTo(t.super.safeArea)},events:{tapped:()=>{$ui.pop(),\"function\"==typeof i&&i()}}},this}removePopButton(){return this.popButtonView=void 0,this}}}})),parcelRequire.register(\"gMc1q\",(function(e,t){var i=parcelRequire(\"fYz8N\").Controller;e.exports={ViewController:class extends i{#S=[];#x(e){e.callEvent(\"onPop\"),this.callEvent(\"onPop\",e),this.#S.pop()}push(e){const t=this.#S[this.#S.length-1];e.navigationBarItems.addPopButton(t?.navigationBar.title),this.#S.push(e),$ui.push({props:{statusBarStyle:0,navBarHidden:!0},events:{dealloc:()=>{this.#x(e)}},views:[e.getPage().definition],layout:$layout.fill})}}}})),String.prototype.trim=function(e,t){return e?\"l\"===t?this.replace(new RegExp(\"^\\\\\"+e+\"+\",\"g\"),\"\"):\"r\"===t?this.replace(new RegExp(\"\\\\\"+e+\"+$\",\"g\"),\"\"):this.replace(new RegExp(\"^\\\\\"+e+\"+|\\\\\"+e+\"+$\",\"g\"),\"\"):this.replace(/^\\s+|\\s+$/g,\"\")};var $czAIJ=parcelRequire(\"czAIJ\"),$bb0fea222fc5aea5$require$VERSION=$czAIJ.VERSION,$fYz8N=parcelRequire(\"fYz8N\"),$bb0fea222fc5aea5$require$Controller=$fYz8N.Controller,$272f042430a952c6$exports={},$45Ip7=parcelRequire(\"45Ip7\"),$272f042430a952c6$require$UIKit=$45Ip7.UIKit,$aXWmO=parcelRequire(\"aXWmO\"),$272f042430a952c6$require$Sheet=$aXWmO.Sheet,$cgaQ6=parcelRequire(\"cgaQ6\"),$272f042430a952c6$require$Kernel=$cgaQ6.Kernel,$12xzj=parcelRequire(\"12xzj\"),$272f042430a952c6$require$NavigationView=$12xzj.NavigationView,$dcStC=parcelRequire(\"dcStC\"),$272f042430a952c6$require$NavigationBar=$dcStC.NavigationBar;class $272f042430a952c6$var$FileManager{viewController;constructor(){this.listId=\"file-manager-list\",this.edges=10,this.iconSize=25,this.loadL10n()}loadL10n(){$272f042430a952c6$require$Kernel.l10n(\"zh-Hans\",{FILE_MANAGER_DELETE_CONFIRM_MSG:\"确认要删除吗\",DELETE:\"删除\",CANCEL:\"取消\",CLOSE:\"关闭\",SHARE:\"分享\",SAVE:\"保存\",SAVE_SUCCESS:\"保存成功\"},!1),$272f042430a952c6$require$Kernel.l10n(\"en\",{FILE_MANAGER_DELETE_CONFIRM_MSG:\"Are you sure you want to delete\",DELETE:\"Delete\",CANCEL:\"Cancel\",CLOSE:\"Close\",SHARE:\"Share\",SAVE:\"Save\",SAVE_SUCCESS:\"Save Success\"},!1)}setViewController(e){this.viewController=e}get menu(){return{items:[{title:$l10n(\"SHARE\"),symbol:\"square.and.arrow.up\",handler:async(e,t)=>{const i=e.object(t).info.info;$share.sheet([$file.absolutePath(i.path)])}}]}}delete(e){$file.delete(e.path)}edit(e){const t=$file.read(e.path);if(t.image)$quicklook.open({image:t.image});else{const i=new $272f042430a952c6$require$Sheet,r=$text.uuid;i.setView({type:\"code\",layout:$layout.fill,props:{id:r,lineNumbers:!0,theme:$device.isDarkMode?\"atom-one-dark\":\"atom-one-light\",text:t.string,insets:$insets(15,15,15,15)}}).addNavBar({title:e.file,popButton:{title:$l10n(\"CLOSE\")},rightButtons:[{title:$l10n(\"SAVE\"),tapped:()=>{$file.write({data:$data({string:$(r).text}),path:e.path}),$ui.success($l10n(\"SAVE_SUCCESS\"))}}]}),i.init().present()}}getFiles(e=\"\"){return $file.list(e).map((t=>{const i=e+\"/\"+t,r=$file.isDirectory(i);return{info:{info:{path:i,file:t,isDirectory:r}},icon:{symbol:r?\"folder.fill\":\"doc\"},name:{text:t},size:{text:r?\"\":\"--\"}}})).sort(((e,t)=>e.info.info.isDirectory!==t.info.info.isDirectory?e.info.info.isDirectory?-1:1:e.info.info.isDirectory===t.info.info.isDirectory?e.info.info.file.localeCompare(t.info.info.file):void 0))}async loadFileSize(e){return e.map(((t,i)=>{const r=t.info.info;if(!r.isDirectory)try{e[i].size.text=$272f042430a952c6$require$Kernel.bytesToSize($file.read(r.path).info.size)}catch(t){e[i].size.text=t}})),e}get listTemplate(){return{props:{bgcolor:$color(\"clear\")},views:[{props:{id:\"info\"}},{type:\"image\",props:{id:\"icon\"},layout:(e,t)=>{e.centerY.equalTo(t.super),e.left.inset(this.edges),e.size.equalTo(this.iconSize)}},{type:\"label\",props:{id:\"name\",lines:1},layout:(e,t)=>{e.centerY.equalTo(t.super),e.left.equalTo(t.prev.right).offset(this.edges)}},{type:\"label\",props:{id:\"size\",color:$color(\"secondaryText\"),lines:1},layout:(e,t)=>{e.centerY.equalTo(t.super),e.right.inset(this.edges)}}]}}#k(e,t){if(this.viewController){const i=new $272f042430a952c6$require$NavigationView;i.setView(t).navigationBarTitle(e),i.navigationBar.setLargeTitleDisplayMode($272f042430a952c6$require$NavigationBar.largeTitleDisplayModeNever),this.viewController.push(i)}else $272f042430a952c6$require$UIKit.push({title:e,views:[t]})}getListView(e=\"\"){return{type:\"list\",props:{id:this.listId,menu:this.menu,info:{basePath:e},bgcolor:$272f042430a952c6$require$UIKit.primaryViewBackgroundColor,separatorInset:$insets(0,this.edges,0,0),data:[],template:this.listTemplate,actions:[{title:\" \"+$l10n(\"DELETE\")+\" \",color:$color(\"red\"),handler:(e,t)=>{const i=e.object(t).info.info;$272f042430a952c6$require$Kernel.deleteConfirm($l10n(\"FILE_MANAGER_DELETE_CONFIRM_MSG\")+' \"'+i.file+'\" ?',(()=>{this.delete(i),e.delete(t)}))}}]},layout:$layout.fill,events:{ready:()=>{const t=this.getFiles(e);$(this.listId).data=t,this.loadFileSize(t).then((e=>{$(this.listId).data=e}))},pulled:async e=>{const t=this.getFiles($(this.listId).info.basePath);$(this.listId).data=t,$(this.listId).data=await this.loadFileSize(t),$delay(.5,(()=>{e.endRefreshing()}))},didSelect:(e,t,i)=>{const r=i.info.info;r.isDirectory?this.#k(r.file,this.getListView(r.path)):this.edit(r)}}}}push(e=\"\"){const t=e.substring(e.lastIndexOf(\"/\"));this.#k(t,this.getListView(e))}}$272f042430a952c6$exports={FileManager:$272f042430a952c6$var$FileManager};var $bb0fea222fc5aea5$require$FileManager=$272f042430a952c6$exports.FileManager,$8aDdQ=parcelRequire(\"8aDdQ\"),$bb0fea222fc5aea5$require$FileStorageParameterError=$8aDdQ.FileStorageParameterError,$bb0fea222fc5aea5$require$FileStorageFileNotFoundError=$8aDdQ.FileStorageFileNotFoundError,$bb0fea222fc5aea5$require$FileStorage=$8aDdQ.FileStorage,$4c192cc93140b629$exports={},$liCrE=parcelRequire(\"liCrE\"),$4c192cc93140b629$require$View=$liCrE.View,$45Ip7=parcelRequire(\"45Ip7\"),$4c192cc93140b629$require$UIKit=$45Ip7.UIKit;class $4c192cc93140b629$var$FixedFooterView extends $4c192cc93140b629$require$View{height=60;getView(){return this.type=\"view\",this.setProp(\"bgcolor\",$4c192cc93140b629$require$UIKit.primaryViewBackgroundColor),this.layout=(e,t)=>{e.left.right.bottom.equalTo(t.super),e.top.equalTo(t.super.safeAreaBottom).offset(-this.height)},this.views=[$4c192cc93140b629$require$View.create({props:this.props,views:this.views,layout:(e,t)=>{e.left.right.top.equalTo(t.super),e.height.equalTo(this.height)}})],this}}$4c192cc93140b629$exports={FixedFooterView:$4c192cc93140b629$var$FixedFooterView};var $bb0fea222fc5aea5$require$FixedFooterView=$4c192cc93140b629$exports.FixedFooterView,$cgaQ6=parcelRequire(\"cgaQ6\"),$bb0fea222fc5aea5$require$Kernel=$cgaQ6.Kernel,$50aa538fe0dbd3b0$exports={},$liCrE=parcelRequire(\"liCrE\"),$50aa538fe0dbd3b0$require$View=$liCrE.View;class $50aa538fe0dbd3b0$var$Matrix extends $50aa538fe0dbd3b0$require$View{titleStyle={font:$font(\"bold\",21),height:30};#B;#q;templateIdByIndex(e){return void 0===this.props.template.views[e]?.props?.id&&(void 0===this.props.template.views[e].props&&(this.props.template.views[e].props={}),this.props.template.views[e].props.id=$text.uuid),this.props.template.views[e].props.id}get templateHiddenStatus(){if(!this.#q){this.#q={};for(let e=0;e(e.items=e.items.map((e=>(Object.keys(e).forEach((t=>{e[t].hidden=this.templateHiddenStatus[t]??!1})),Object.keys(this.templateHiddenStatus).forEach((t=>{e[t]||(e[t]={}),e[t].hidden=this.templateHiddenStatus[t]})),e.__templateProps={hidden:!1},e.__title={hidden:!0},e))),e.title&&e.items.unshift(this.#R(e.title)),e)))}rebuildTemplate(){let e={};void 0!==this.props.template.props&&(e=Object.assign(this.props.template.props,{id:\"__templateProps\",hidden:!1})),this.props.template.props={};const t=[{type:\"view\",props:e,layout:$layout.fill},{type:\"label\",props:{id:\"__title\",hidden:!0,font:this.titleStyle.font},layout:(e,t)=>{e.top.inset(-this.titleStyle.height/4*3),e.height.equalTo(this.titleStyle.height),e.width.equalTo(t.super.safeArea)}}].concat(this.props.template.views);this.props.template.views=t}insert(e,t=!0){return e.indexPath=this.indexPath(e.indexPath,t),$(this.id).insert(e)}delete(e,t=!0){return e=this.indexPath(e,t),$(this.id).delete(e)}object(e,t=!0){return e=this.indexPath(e,t),$(this.id).object(e)}cell(e,t=!0){return e=this.indexPath(e,t),$(this.id).cell(e)}indexPath(e,t){let i=t?0:1;return\"number\"==typeof e&&(e=$indexPath(0,e)),$indexPath(e.section,e.row+i)}update(e){this.props.data=this.rebuildData(e),$(this.id).data=this.props.data}getView(){return this.props.data=this.rebuildData(this.props.data),this.rebuildTemplate(),this.setEvent(\"itemSize\",((e,t)=>{const i=e.object(t)?.__title?.info;if(i?.title)return $size(Math.max($device.info.screen.width,$device.info.screen.height),0);const r=this.props.columns??2,s=this.props.spacing??15,a=this.props.itemWidth??this.props.itemSize?.width??(e.super.frame.width-s*(r+1))/r,n=this.props.itemHeight??this.props.itemSize?.height??100;return $size(a,n)})),this}}$50aa538fe0dbd3b0$exports={Matrix:$50aa538fe0dbd3b0$var$Matrix};var $bb0fea222fc5aea5$require$Matrix=$50aa538fe0dbd3b0$exports.Matrix,$619319e3f3656d3f$exports={};class $619319e3f3656d3f$var$Request{static method={get:\"GET\",post:\"POST\",delete:\"DELETE\",patch:\"PATCH\",head:\"HEAD\"};cacheContainerKey=$addin?.current?.name+\".request.cache\";#D=!1;#O=!1;cacheLife=2592e6;isLogRequest=!1;timeout=5;logger;constructor(e){\"function\"==typeof e&&(this.logger=e)}get cache(){return $cache.get(this.cacheContainerKey)??{}}#N(e){this.isLogRequest&&\"function\"==typeof logger&&this.logger(e)}logRequest(e){return this.isLogRequest=!0,\"function\"==typeof e&&(this.logger=e),this}getCacheKey(e){return $text.MD5(e)}getCache(e,t=null){return this.cache[e]??t}setCache(e,t){if(!t)return;const i=this.cache;i[e]=t,$cache.set(this.cacheContainerKey,i)}removeCache(e){let t=this.cache;delete t[e],$cache.set(this.cacheContainerKey,t)}clearCache(){$cache.remove(this.cacheContainerKey)}useCache(){return this.#D=!0,this}ignoreCacheExp(){this.#O=!0}async request(e,t,i={},r={},s=this.cacheLife){let a;const n=this.#D&&t===$619319e3f3656d3f$var$Request.method.get;if(n){a=this.getCacheKey(e);const t=this.getCache(a);if(t&&(this.#O||t.exp>Date.now()))return this.#N(\"get data from cache: \"+e),t.data}try{this.#N(`sending request [${t}]: ${e}`);const o=await $http.request({header:r,url:e,method:t,body:i,timeout:this.timeout});if(o.error)throw o.error;if(o?.response?.statusCode>=400){let e=o.data;throw\"object\"==typeof e&&(e=JSON.stringify(e)),new Error(\"http error: [\"+o.response.statusCode+\"] \"+e)}return n&&this.setCache(a,{exp:Date.now()+s,data:o}),o}catch(e){throw e.code&&(e=new Error(\"network error: [\"+e.code+\"] \"+e.localizedDescription)),e}}}$619319e3f3656d3f$exports={Request:$619319e3f3656d3f$var$Request};var $bb0fea222fc5aea5$require$Request=$619319e3f3656d3f$exports.Request,$7D8Kb=parcelRequire(\"7D8Kb\"),$bb0fea222fc5aea5$require$Setting=$7D8Kb.Setting,$aXWmO=parcelRequire(\"aXWmO\"),$bb0fea222fc5aea5$require$Sheet=$aXWmO.Sheet,$7dfcabb1e936a92c$exports={},$liCrE=parcelRequire(\"liCrE\"),$7dfcabb1e936a92c$require$View=$liCrE.View,$7dfcabb1e936a92c$require$PageView=$liCrE.PageView,$fYz8N=parcelRequire(\"fYz8N\"),$7dfcabb1e936a92c$require$Controller=$fYz8N.Controller,$45Ip7=parcelRequire(\"45Ip7\"),$7dfcabb1e936a92c$require$UIKit=$45Ip7.UIKit;class $7dfcabb1e936a92c$var$TabBarCellView extends $7dfcabb1e936a92c$require$View{constructor(e={}){super(e),this.setIcon(e.icon),this.setTitle(e.title),void 0!==e.activeStatus&&(this.activeStatus=e.activeStatus)}setIcon(e){return this.icon=e instanceof Array?e:[e,e],this}setTitle(e){return this.title=e,this}active(){$(`${this.props.id}-icon`).image=$image(this.icon[1]),$(`${this.props.id}-icon`).tintColor=$color(\"systemLink\"),$(`${this.props.id}-title`).textColor=$color(\"systemLink\"),this.activeStatus=!0}inactive(){$(`${this.props.id}-icon`).image=$image(this.icon[0]),$(`${this.props.id}-icon`).tintColor=$color(\"lightGray\"),$(`${this.props.id}-title`).textColor=$color(\"lightGray\"),this.activeStatus=!1}getView(){return this.views=[{type:\"image\",props:{id:`${this.props.id}-icon`,image:$image(this.activeStatus?this.icon[1]:this.icon[0]),bgcolor:$color(\"clear\"),tintColor:$color(this.activeStatus?\"systemLink\":\"lightGray\")},layout:(e,t)=>{e.centerX.equalTo(t.super);const i=$7dfcabb1e936a92c$var$TabBarController.tabBarHeight/2;e.size.equalTo(i),e.top.inset(($7dfcabb1e936a92c$var$TabBarController.tabBarHeight-i-13)/2)}},{type:\"label\",props:{id:`${this.props.id}-title`,text:this.title,font:$font(10),textColor:$color(this.activeStatus?\"systemLink\":\"lightGray\")},layout:(e,t)=>{e.centerX.equalTo(t.prev),e.top.equalTo(t.prev.bottom).offset(3)}}],this}}class $7dfcabb1e936a92c$var$TabBarHeaderView extends $7dfcabb1e936a92c$require$View{height=60;getView(){return this.type=\"view\",this.setProp(\"bgcolor\",this.props.bgcolor??$7dfcabb1e936a92c$require$UIKit.primaryViewBackgroundColor),this.layout=(e,t)=>{e.left.right.bottom.equalTo(t.super),e.top.equalTo(t.super.safeAreaBottom).offset(-this.height-$7dfcabb1e936a92c$var$TabBarController.tabBarHeight)},this.views=[$7dfcabb1e936a92c$require$View.create({props:this.props,views:this.views,layout:(e,t)=>{e.left.right.top.equalTo(t.super),e.height.equalTo(this.height)}})],this}}class $7dfcabb1e936a92c$var$TabBarController extends $7dfcabb1e936a92c$require$Controller{static tabBarHeight=50;#L={};#_={};#V;#P;#M=$text.uuid;#F=$text.uuid;bottomSafeAreaInsets=$app.isDebugging?0:$7dfcabb1e936a92c$require$UIKit.bottomSafeAreaInsets;get selected(){return this.#P}set selected(e){this.switchPageTo(e)}get contentOffset(){return $7dfcabb1e936a92c$var$TabBarController.tabBarHeight+(this.#V?.height??0)}setPages(e={}){return Object.keys(e).forEach((t=>this.setPage(t,e[t]))),this}setPage(e,t){return void 0===this.#P&&(this.#P=e),this.#L[e]=t instanceof $7dfcabb1e936a92c$require$PageView?t:$7dfcabb1e936a92c$require$PageView.create(t),this.#P!==e&&(this.#L[e].activeStatus=!1),this}switchPageTo(e){if(this.#L[e]){if(this.#P===e)return;$ui.animate({duration:.4,animation:()=>{this.#_[e].active()}}),this.#_[this.#P].inactive(),this.#L[this.#P].hide(),this.#L[e].show(),this.callEvent(\"onChange\",this.#P,e),this.#P=e,this.initBackground()}}hideBackground(e=!0){$(this.#F).hidden=!0,$ui.animate({duration:e?.2:1e-4,animation:()=>{$(this.#M).alpha=0}})}showBackground(e=!0){$(this.#F).hidden=!1,$ui.animate({duration:e?.2:1e-4,animation:()=>{$(this.#M).alpha=1}})}initBackground(){const e=this.#L[this.selected];e.scrollable&&$delay(0,(()=>{const t=$(e.id).get(e.scrollableView.id),i=t.contentOffset.y;t.contentSize.height+this.bottomSafeAreaInsets-t.frame.height-i<=0?this.hideBackground(!1):this.showBackground(!1)}))}setCells(e={}){return Object.keys(e).forEach((t=>this.setCell(t,e[t]))),this}setCell(e,t){return void 0===this.#P&&(this.#P=e),t instanceof $7dfcabb1e936a92c$var$TabBarCellView||(t=new $7dfcabb1e936a92c$var$TabBarCellView({props:{info:{key:e}},icon:t.icon,title:t.title,activeStatus:this.#P===e})),this.#_[e]=t,this}setHeader(e){return this.#V=e,this}#H(){const e=[];return Object.values(this.#_).forEach((t=>{t.setEvent(\"tapped\",(e=>{const t=e.info.key;this.switchPageTo(t)})),e.push(t.getView())})),e}#U(){return Object.values(this.#L).map((e=>{if(e.scrollable){const t=e.scrollableView;if(t.props.indicatorInsets){const e=t.props.indicatorInsets;t.props.indicatorInsets=$insets(e.top,e.left,e.bottom+this.contentOffset,e.right)}else t.props.indicatorInsets=$insets(0,0,this.contentOffset,0);t.props.footer=Object.assign({props:{}},t.props.footer??{}),t.props.footer.props.height?t.props.footer.props.height+=this.contentOffset:t.props.footer.props.height=this.contentOffset,\"function\"==typeof t.assignEvent&&t.assignEvent(\"didScroll\",(e=>{const t=e.contentOffset.y;e.contentSize.height+this.bottomSafeAreaInsets-e.frame.height-t<=1?this.hideBackground():this.showBackground()}))}return e.definition}))}generateView(){const e={type:\"view\",layout:(e,t)=>{e.centerX.equalTo(t.super),e.width.equalTo(t.super),e.top.equalTo(t.super.safeAreaBottom).offset(-$7dfcabb1e936a92c$var$TabBarController.tabBarHeight),e.bottom.equalTo(t.super)},views:[$7dfcabb1e936a92c$require$UIKit.blurBox({id:this.#M}),{type:\"stack\",layout:$layout.fillSafeArea,props:{axis:$stackViewAxis.horizontal,distribution:$stackViewDistribution.fillEqually,spacing:0,stack:{views:this.#H()}}},$7dfcabb1e936a92c$require$UIKit.separatorLine({id:this.#F},$7dfcabb1e936a92c$require$UIKit.align.top)],events:{ready:()=>this.initBackground()}};return $7dfcabb1e936a92c$require$View.createFromViews(this.#U().concat(this.#V?.definition??[],e))}}$7dfcabb1e936a92c$exports={TabBarCellView:$7dfcabb1e936a92c$var$TabBarCellView,TabBarHeaderView:$7dfcabb1e936a92c$var$TabBarHeaderView,TabBarController:$7dfcabb1e936a92c$var$TabBarController};var $bb0fea222fc5aea5$require$TabBarCellView=$7dfcabb1e936a92c$exports.TabBarCellView,$bb0fea222fc5aea5$require$TabBarHeaderView=$7dfcabb1e936a92c$exports.TabBarHeaderView,$bb0fea222fc5aea5$require$TabBarController=$7dfcabb1e936a92c$exports.TabBarController,$3839e9f9bae78bdd$exports={};class $3839e9f9bae78bdd$var$Tasks{#z={};addTask(e,t=0){const i=$text.uuid;return this.#z[i]=$delay(t,(async()=>{await e(),delete this.#z[i]})),i}cancelTask(e){this.#z[e].cancel()}clearTasks(){Object.values(this.#z).forEach((e=>e.cancel()))}}$3839e9f9bae78bdd$exports={Tasks:$3839e9f9bae78bdd$var$Tasks};var $bb0fea222fc5aea5$require$Tasks=$3839e9f9bae78bdd$exports.Tasks,$895b2d75ea56b5f0$exports={},$45Ip7=parcelRequire(\"45Ip7\"),$895b2d75ea56b5f0$require$UIKit=$45Ip7.UIKit;class $895b2d75ea56b5f0$var$Toast{static type={info:void 0,success:\"checkmark\",warning:\"exclamationmark.triangle\",error:\"xmark.circle\"};static edges=40;static iconSize=100;static labelTopMargin=10;width=Math.min(.6*$895b2d75ea56b5f0$require$UIKit.windowSize.width,260);labelWidth=this.width-2*$895b2d75ea56b5f0$var$Toast.edges;id=$text.uuid;#j=\"\";type=$895b2d75ea56b5f0$var$Toast.type.info;labelLines=2;font=$font(\"default\",26);constructor(e,t=$895b2d75ea56b5f0$var$Toast.type.info,i=2,r=$font(\"default\",26)){this.type=t,this.message=e,this.labelLines=i,this.font=r}get message(){return this.#j}set message(e){this.#j=e,this.fontHeight=$895b2d75ea56b5f0$require$UIKit.getContentSize(this.font,this.message,this.labelWidth,this.labelLines).height,this.height=(this.hasIcon?$895b2d75ea56b5f0$var$Toast.labelTopMargin+$895b2d75ea56b5f0$var$Toast.iconSize:0)+this.fontHeight+2*$895b2d75ea56b5f0$var$Toast.edges}get hasIcon(){return void 0!==this.type}get blurBox(){const e=$895b2d75ea56b5f0$require$UIKit.blurBox({id:this.id,cornerRadius:15,alpha:0},[{type:\"image\",props:{symbol:this.type,hidden:!this.hasIcon,tintColor:$color(\"lightGray\")},layout:(e,t)=>{e.top.inset($895b2d75ea56b5f0$var$Toast.edges),e.size.equalTo($895b2d75ea56b5f0$var$Toast.iconSize),e.centerX.equalTo(t.super)}},{type:\"label\",props:{font:this.font,text:this.message,align:$align.center,lines:this.labelLines,color:$color(\"lightGray\")},layout:(e,t)=>{e.bottom.equalTo(t.supper).offset(-$895b2d75ea56b5f0$var$Toast.edges),e.width.equalTo(this.labelWidth),e.height.equalTo(this.fontHeight),e.centerX.equalTo(t.super)}}]);return e.events={tapped:()=>{this.remove()}},e}show(){$ui.controller.view.insertAtIndex($ui.create(this.blurBox),0);const e=$(this.id);e.layout(((e,t)=>{e.center.equalTo(t.super),e.size.equalTo($size(this.width,this.height))})),e.moveToFront(),$ui.animate({duration:.2,animation:()=>{e.alpha=1}})}remove(){const e=$(this.id);e&&$ui.animate({duration:.2,animation:()=>{e.alpha=0},completion:()=>{e.remove()}})}static toast({message:e,type:t=$895b2d75ea56b5f0$var$Toast.type.info,displayTime:i=2,labelLines:r=2,font:s=$font(\"default\",26)}){const a=new $895b2d75ea56b5f0$var$Toast(e,t,r,s);a.show(),$delay(i,(()=>{a.remove()}))}static info(e,t={}){$895b2d75ea56b5f0$var$Toast.toast(Object.assign({message:e,type:$895b2d75ea56b5f0$var$Toast.type.info},t))}static success(e,t={}){$895b2d75ea56b5f0$var$Toast.toast(Object.assign({message:e,type:$895b2d75ea56b5f0$var$Toast.type.success},t))}static warning(e,t={}){$895b2d75ea56b5f0$var$Toast.toast(Object.assign({message:e,type:$895b2d75ea56b5f0$var$Toast.type.warning},t))}static error(e,t={}){$895b2d75ea56b5f0$var$Toast.toast(Object.assign({message:e,type:$895b2d75ea56b5f0$var$Toast.type.error},t))}}$895b2d75ea56b5f0$exports={Toast:$895b2d75ea56b5f0$var$Toast};var $bb0fea222fc5aea5$require$Toast=$895b2d75ea56b5f0$exports.Toast,$45Ip7=parcelRequire(\"45Ip7\"),$bb0fea222fc5aea5$require$UIKit=$45Ip7.UIKit,$86d2ffde19fb8791$exports={};class $86d2ffde19fb8791$var$UILoading{#K;text=\"\";interval;fullScreen=!1;#Y=()=>{};constructor(){this.#K=$text.uuid}updateText(e){$(this.#K).text=e}setLoop(e){if(\"function\"!=typeof e)throw\"loop must be a function\";this.#Y=e}done(){clearInterval(this.interval)}load(){$ui.render({props:{navBarHidden:this.fullScreen},views:[{type:\"spinner\",props:{loading:!0},layout:(e,t)=>{e.centerY.equalTo(t.super).offset(-15),e.width.equalTo(t.super)}},{type:\"label\",props:{id:this.#K,align:$align.center,text:\"\"},layout:(e,t)=>{e.top.equalTo(t.prev.bottom).offset(10),e.left.right.equalTo(t.super)}}],layout:$layout.fill,events:{appeared:()=>{this.interval=setInterval((()=>{this.#Y()}),100)}}})}}$86d2ffde19fb8791$exports={UILoading:$86d2ffde19fb8791$var$UILoading};var $bb0fea222fc5aea5$require$UILoading=$86d2ffde19fb8791$exports.UILoading,$6Xrbz=parcelRequire(\"6Xrbz\"),$bb0fea222fc5aea5$require$ValidationError=$6Xrbz.ValidationError,$liCrE=parcelRequire(\"liCrE\"),$bb0fea222fc5aea5$require$View=$liCrE.View,$bb0fea222fc5aea5$require$PageView=$liCrE.PageView,$gMc1q=parcelRequire(\"gMc1q\"),$bb0fea222fc5aea5$require$ViewController=$gMc1q.ViewController,$12xzj=parcelRequire(\"12xzj\"),$bb0fea222fc5aea5$require$NavigationView=$12xzj.NavigationView,$dcStC=parcelRequire(\"dcStC\"),$bb0fea222fc5aea5$require$NavigationBar=$dcStC.NavigationBar,$bb0fea222fc5aea5$require$NavigationBarController=$dcStC.NavigationBarController,$gAYmG=parcelRequire(\"gAYmG\"),$bb0fea222fc5aea5$require$NavigationBarItems=$gAYmG.NavigationBarItems,$bb0fea222fc5aea5$require$BarButtonItem=$gAYmG.BarButtonItem,$ee5e1f8d12d987dc$exports={},$fYz8N=parcelRequire(\"fYz8N\"),$ee5e1f8d12d987dc$require$Controller=$fYz8N.Controller,$gAYmG=parcelRequire(\"gAYmG\"),$ee5e1f8d12d987dc$require$BarTitleView=$gAYmG.BarTitleView;class $ee5e1f8d12d987dc$var$SearchBar extends $ee5e1f8d12d987dc$require$BarTitleView{height=35;topOffset=15;bottomOffset=10;kbType=$kbType.search;placeholder=$l10n(\"SEARCH\");inputEvents={};keyboardView;accessoryView;constructor(e){super(e),this.setController(new $ee5e1f8d12d987dc$var$SearchBarController),this.controller.setSearchBar(this)}setEvent(e,t){return this.inputEvents[e]=t,this}setPlaceholder(e){return this.placeholder=e,this}setKbType(e){return this.kbType=e,this}setKeyboardView(e){return this.keyboardView=e,this}setAccessoryView(e){return this.accessoryView=e,this}getView(){return this.props={id:this.id,smoothCorners:!0,cornerRadius:6,bgcolor:$color(\"#EEF1F1\",\"#212121\")},this.views=[{type:\"input\",props:{id:this.id+\"-input\",type:this.kbType,bgcolor:$color(\"clear\"),placeholder:this.placeholder,keyboardView:this.keyboardView,accessoryView:this.accessoryView},layout:$layout.fill,events:Object.assign({changed:e=>this.controller.callEvent(\"onChange\",e.text),returned:e=>this.controller.callEvent(\"onReturn\",e.text)},this.inputEvents)}],this.layout=(e,t)=>{e.height.equalTo(this.height),e.top.equalTo(t.super.safeArea).offset(this.topOffset),e.left.equalTo(t.super.safeArea).offset(15),e.right.equalTo(t.super.safeArea).offset(-15)},this}}class $ee5e1f8d12d987dc$var$SearchBarController extends $ee5e1f8d12d987dc$require$Controller{setSearchBar(e){return this.searchBar=e,this}updateSelector(){this.selector={inputBox:$(this.searchBar.id),input:$(this.searchBar.id+\"-input\")}}hide(){this.updateSelector(),this.selector.inputBox.updateLayout((e=>{e.height.equalTo(0)}))}show(){this.updateSelector(),this.selector.inputBox.updateLayout((e=>{e.height.equalTo(this.searchBar.height)}))}didScroll(e){this.updateSelector();let t=this.searchBar.height-e;if(t=t>0?t>this.searchBar.height?this.searchBar.height:t:0,this.selector.inputBox.updateLayout((e=>{e.height.equalTo(t)})),e>0){const t=(this.searchBar.height/2-5-e)/10;this.selector.input.alpha=t}else this.selector.input.alpha=1}didEndDragging(e,t,i){this.updateSelector(),e>=0&&e<=this.searchBar.height&&i($point(0,e>=this.searchBar.height/2?this.searchBar.height:0))}}$ee5e1f8d12d987dc$exports={SearchBar:$ee5e1f8d12d987dc$var$SearchBar,SearchBarController:$ee5e1f8d12d987dc$var$SearchBarController};var $bb0fea222fc5aea5$require$SearchBar=$ee5e1f8d12d987dc$exports.SearchBar,$bb0fea222fc5aea5$require$SearchBarController=$ee5e1f8d12d987dc$exports.SearchBarController;module.exports={VERSION:$bb0fea222fc5aea5$require$VERSION,Controller:$bb0fea222fc5aea5$require$Controller,FileManager:$bb0fea222fc5aea5$require$FileManager,FileStorageParameterError:$bb0fea222fc5aea5$require$FileStorageParameterError,FileStorageFileNotFoundError:$bb0fea222fc5aea5$require$FileStorageFileNotFoundError,FileStorage:$bb0fea222fc5aea5$require$FileStorage,FixedFooterView:$bb0fea222fc5aea5$require$FixedFooterView,Kernel:$bb0fea222fc5aea5$require$Kernel,Matrix:$bb0fea222fc5aea5$require$Matrix,Request:$bb0fea222fc5aea5$require$Request,Setting:$bb0fea222fc5aea5$require$Setting,Sheet:$bb0fea222fc5aea5$require$Sheet,TabBarCellView:$bb0fea222fc5aea5$require$TabBarCellView,TabBarHeaderView:$bb0fea222fc5aea5$require$TabBarHeaderView,TabBarController:$bb0fea222fc5aea5$require$TabBarController,Tasks:$bb0fea222fc5aea5$require$Tasks,Toast:$bb0fea222fc5aea5$require$Toast,UIKit:$bb0fea222fc5aea5$require$UIKit,UILoading:$bb0fea222fc5aea5$require$UILoading,ValidationError:$bb0fea222fc5aea5$require$ValidationError,View:$bb0fea222fc5aea5$require$View,PageView:$bb0fea222fc5aea5$require$PageView,ViewController:$bb0fea222fc5aea5$require$ViewController,NavigationView:$bb0fea222fc5aea5$require$NavigationView,NavigationBar:$bb0fea222fc5aea5$require$NavigationBar,NavigationBarController:$bb0fea222fc5aea5$require$NavigationBarController,NavigationBarItems:$bb0fea222fc5aea5$require$NavigationBarItems,BarButtonItem:$bb0fea222fc5aea5$require$BarButtonItem,SearchBar:$bb0fea222fc5aea5$require$SearchBar,SearchBarController:$bb0fea222fc5aea5$require$SearchBarController}})),parcelRequire.register(\"hOw2h\",(function(e,t){var i=parcelRequire(\"gxpqj\").Kernel;class r{sqlite;constructor(e){this.kernel=e,this.dbName=\"CAIO.db\",this.localDb=`/${this.dbName}`,this.imagePath=\"/image\",this.imageOriginalPath=`${this.imagePath}/original`,this.imagePreviewPath=`${this.imagePath}/preview`,this.tempPath=\"/temp\",this.tempDbFile=`${this.tempPath}/${this.dbName}`,this.tempImagePath=`${this.tempPath}/image`,this.exportFileName=\"CAIO.zip\",this.init()}init(){this.sqlite=$sqlite.open(this.kernel.fileStorage.filePath(this.localDb)),this.sqlite.update(\"CREATE TABLE IF NOT EXISTS clips(uuid TEXT PRIMARY KEY NOT NULL, text TEXT, md5 TEXT, prev TEXT, next TEXT)\"),this.sqlite.update(\"CREATE TABLE IF NOT EXISTS pin(uuid TEXT PRIMARY KEY NOT NULL, text TEXT, md5 TEXT, prev TEXT, next TEXT)\"),this.sqlite.update(\"CREATE TABLE IF NOT EXISTS tag(uuid TEXT PRIMARY KEY NOT NULL, tag TEXT)\")}rebuild(){const e=this.tempPath+\"/rebuild.db\";this.kernel.fileStorage.delete(e);const t=new r(this.kernel);t.localDb=e,t.init();const i=(e,i)=>{const r=[];e.forEach((e=>{const s={uuid:e.uuid,text:e.text,md5:e.md5,tag:e.tag,image:e.image,prev:null,next:r[0]?.uuid??null};t.beginTransaction();try{t.insert(i,s),s.next&&(r[0].prev=s.uuid,t.update(i,r[0])),t.commit(),r.unshift(s)}catch(e){throw t.rollback(),this.kernel.error(e),e}}))};[\"clips\",\"pin\"].map((e=>{let t=this.all(e);try{const e=this.sort(JSON.parse(JSON.stringify(t)));if(e.length>t.length)throw new Error;t=e.reverse()}catch{}i(t,e)}));const s=this.sqlite.query(\"SELECT * FROM tag\");this.parseTag(s).forEach((e=>{t.beginTransaction();try{t.setTag(e.uuid,e.tag),t.commit()}catch(e){throw t.rollback(),this.kernel.error(e),e}})),this.kernel.fileStorage.copy(e,this.localDb)}deleteAllData(){this.kernel.fileStorage.delete(this.imagePath),this.kernel.fileStorage.delete(this.localDb)}clearTemp(){this.kernel.fileStorage.delete(this.tempPath)}async export(e){this.clearTemp(),this.kernel.fileStorage.copy(this.localDb,this.tempDbFile),this.kernel.fileStorage.copy(this.imagePath,this.tempImagePath);const t=this.tempPath+\"/\"+this.exportFileName;await $archiver.zip({directory:this.kernel.fileStorage.filePath(this.tempPath),dest:this.kernel.fileStorage.filePath(t)}),$share.sheet({items:[{name:this.exportFileName,data:$data({path:this.kernel.fileStorage.filePath(t)})}],handler:i=>{this.kernel.fileStorage.delete(t),e(i)}})}async import(e){if(\"db\"===e.fileName.slice(-2)){if(!this.kernel.fileStorage.writeSync(this.localDb,e))throw new Error(\"WRITE_DB_FILE_FAILED\")}else if(\"zip\"===e.fileName.slice(-3)){if(!await $archiver.unzip({file:e,dest:this.kernel.fileStorage.filePath(this.tempPath)}))throw new Error(\"UNZIP_FAILED\");this.kernel.fileStorage.move(this.tempDbFile,this.localDb),this.kernel.fileStorage.move(this.tempImagePath,this.imagePath)}}sort(e,t=9e3){const i={};let r=0,s=null;e.forEach((e=>{i[e.uuid]=e,null===e.prev&&(s=e.uuid),r++}));const a=[];if(r>0)try{let e=i[s];for(;null!==e.next&&t>0;)t--,a.push(e),e=i[e.next];a.push(e)}catch(e){throw\"Unable to sort: \"+e}return a}parse(e){const t=e.result,i=e.error;if(null!==i)throw new Error(`Code [${i.code}] ${i.domain} ${i.localizedDescription}`);const r=[];for(;t.next();)r.push({uuid:t.get(\"uuid\"),section:t.get(\"section\"),text:t.get(\"text\"),md5:t.get(\"md5\"),tag:t.get(\"tag\")??\"\",prev:t.get(\"prev\")??null,next:t.get(\"next\")??null});return t.close(),r}parseTag(e){if(null!==e.error)throw e.error;const t=[];for(;e.result.next();)t.push({uuid:e.result.get(\"uuid\"),tag:e.result.get(\"tag\")});return e.result.close(),t}beginTransaction(){this.sqlite.beginTransaction()}commit(){this.sqlite.commit()}rollback(){this.sqlite.rollback()}getByUUID(e){e=e.replace(\"'\",\"\");const t=this.sqlite.query({sql:`\\n SELECT *, 'clips' AS section FROM clips WHERE uuid = '${e}'\\n UNION\\n SELECT *, 'pin' AS section FROM pin WHERE uuid = '${e}'\\n `});return this.parse(t)[0]}getByMD5(e){e=e.replace(\"'\",\"\");const t=this.sqlite.query({sql:`\\n SELECT *, 'clips' AS section FROM clips WHERE md5 = '${e}'\\n UNION\\n SELECT *, 'pin' AS section FROM pin WHERE md5 = '${e}'\\n `});return this.parse(t)[0]}search(e){const t=this.sqlite.query({sql:\"SELECT * from\\n (SELECT clips.*, 'clips' AS section FROM clips WHERE text like ?\\n UNION\\n SELECT pin.*, 'pin' AS section FROM pin WHERE text like ?) a\\n LEFT JOIN tag ON a.uuid = tag.uuid\\n \",args:[`%${e}%`,`%${e}%`]});return this.parse(t)}isImage(e){return e?.startsWith(\"@image=\")}pathToKey(e){return`@image=${e=JSON.stringify(e)}`}keyToPath(e){return!!this.isImage(e)&&JSON.parse(e.slice(7))}deleteTable(e){const t=this.sqlite.update(`DELETE FROM ${e}`);if(!t.result)throw t.error}all(e){const t=this.sqlite.query(`SELECT ${e}.*, tag, '${e}' AS section FROM ${e} LEFT JOIN tag ON ${e}.uuid = tag.uuid`);return this.parse(t)}insert(e,t){if(t.image){const e=t.image,r=$text.uuid,s={original:`${this.imageOriginalPath}/${r}.png`,preview:`${this.imagePreviewPath}/${r}.jpg`};this.kernel.fileStorage.write(s.original,e.png),this.kernel.fileStorage.write(s.preview,i.compressImage(e).jpg(.8)),t.text=this.pathToKey(s)}const r=this.sqlite.update({sql:`INSERT INTO ${e} (uuid, text, md5, prev, next) values (?, ?, ?, ?, ?)`,args:[t.uuid,t.text,$text.MD5(t.text),t.prev,t.next]});if(!r.result)throw r.error}update(e,t){if(Object.keys(t).length<4||\"string\"!=typeof t.uuid)return;const i=this.sqlite.update({sql:`UPDATE ${e} SET text = ?, md5 = ?, prev = ?, next = ? WHERE uuid = ?`,args:[t.text,$text.MD5(t.text),t.prev,t.next,t.uuid]});if(!i.result)throw i.error}updateText(e,t,i){if(\"string\"!=typeof t)return;const r=this.sqlite.update({sql:`UPDATE ${e} SET text = ?, md5 = ? WHERE uuid = ?`,args:[i,$text.MD5(i),t]});if(!r.result)throw r.error}delete(e,t){const i=this.getByUUID(t);this.beginTransaction();try{const i=this.sqlite.update({sql:`DELETE FROM ${e} WHERE uuid = ?`,args:[t]});if(!i.result)throw i.error;this.deleteTag(t),this.commit()}catch(e){throw this.rollback(),e}const r=this.keyToPath(i?.text);r&&(this.kernel.fileStorage.delete(r.original),this.kernel.fileStorage.delete(r.preview))}setTag(e,t){const i=this.sqlite.update({sql:\"INSERT OR REPLACE INTO tag (uuid, tag) values (?, ?)\",args:[e,t]});if(!i.result)throw i.error}deleteTag(e){const t=this.sqlite.update({sql:\"DELETE FROM tag WHERE uuid = ?\",args:[e]});if(!t.result)throw t.error}}e.exports=r})),parcelRequire.register(\"imdB1\",(function(e,t){var i=parcelRequire(\"gxpqj\"),r=i.View,s=i.Kernel,a=i.UIKit,n=i.Sheet,o=i.ViewController,l=i.NavigationView,c=i.NavigationBar,h=i.Toast,d=parcelRequire(\"f0nX9\"),p=parcelRequire(\"4ZHFw\"),u=parcelRequire(\"ay4Kj\"),g=parcelRequire(\"9LqeL\"),f=parcelRequire(\"eSp9Z\"),b=f.ActionData,y=f.ActionEnv;e.exports=class extends p{listId=\"clips-list\";#G=!1;#W=-1;left_right=20;top_bottom=20;containerMargin=0;fontSize=16;copiedIndicatorSize=7;imageContentHeight=50;tagFontSize=14;tagContainerHeight=25;menuItemActionMaxCount=5;tabHeight=44;copied=$cache.get(\"clips.copied\")??{};#J={};constructor(e){super(e),this.viewController=new o,this.search=new u(this.kernel),this.search.setCallback((e=>{(new n).setView(this.getListView(this.listId+\"-search-result\",e.map((e=>this.lineData(e))))).addNavBar({title:$l10n(\"SEARCH_RESULT\"),popButton:{title:$l10n(\"DONE\"),tapped:()=>this.search.dismiss()}}).init().present()}))}get singleLineHeight(){return this.#W<0&&(this.#W=$text.sizeThatFits({text:\"A\",width:this.fontSize,font:$font(this.fontSize)}).height),this.#W}setSingleLine(){this.#G=!0,this.imageContentHeight=this.singleLineHeight}getTextHeight(e){return this.#J[e]||(this.#J[e]=this.#G?this.singleLineHeight:Math.min($text.sizeThatFits({text:e,width:a.windowSize.width-2*(this.left_right+this.containerMargin),font:$font(this.fontSize)}).height,2*this.singleLineHeight)),this.#J[e]}appListen(){s.isTaio||$app.listen({resume:()=>{this.loadAllClips(),this.updateList(),$delay(.5,(()=>{this.readClipboard()}))}})}listReady(){this.updateList(),s.isTaio||($delay(.5,(()=>{if($context.query.copy){const e=$context.query.copy,t=this.kernel.storage.getByUUID(e);this.setClipboardText(t.text),this.setCopied(e,this.getRowByUUID(e)),$ui.success($l10n(\"COPIED\"))}else $context.query.add?this.getAddTextView():$context.query.actions&&(this.kernel.isUseJsboxNav?this.kernel.actionManager.present():this.kernel.tabBarController.switchPageTo(\"actions\"))})),$delay(.5,(()=>{this.readClipboard()})),this.appListen())}updateList(){$(this.listId).data=this.clips.map((e=>this.lineData(e,this.copied.uuid===e.uuid))),this.updateListBackground()}updateListBackground(){$(this.listId+\"-empty-list-background\").hidden=this.clips.length>0}updateCopied(e={}){Object.assign(this.copied,e),this.kernel.print(`this.copied: ${JSON.stringify(this.copied,null,2)}`),$cache.set(\"clips.copied\",this.copied)}setCopied(e,t,i=!0){if(!e||e===this.copied.uuid&&this.tabIndex===this.copied?.tabIndex&&t===this.copied?.row)return;let r={};this.copied.uuid!==e&&(r=this.kernel.storage.getByUUID(e)??{}),r.tabIndex=this.tabIndex,r.row=t;const s=this.copied.row;if(this.updateCopied(r),i){const e=$(this.listId);$delay(.3,(()=>{e.cell($indexPath(0,s)).get(\"copied\").hidden=!0,e.cell($indexPath(0,t)).get(\"copied\").hidden=!1}))}}readClipboard(e=!1){if(e||this.kernel.setting.get(\"clipboard.autoSave\")){if(this.kernel.print(\"read clipboard\"),!this.isChanged)return void(e&&$ui.toast($l10n(\"CLIPBOARD_NO_CHANGE\")));if(this.switchTab(1,!0),$clipboard.images?.length>0)return!!e&&($clipboard.images.forEach((e=>{this.add(e)})),!0);const t=$clipboard.text;if(!t||\"\"===t)return!1;if(this.copied.text===t)return!1;const i=$text.MD5(t);if(this.savedClipboardIndex[i]){const e=this.kernel.storage.getByMD5(i);this.setCopied(e.uuid,this.getRowByUUID(e.uuid))}else{const e=this.add(t);this.copy(t,e.uuid,0)}}return!1}add(e,t){try{const i=super.add(e);return\"function\"==typeof t?t(i):($(this.listId).insert({indexPath:$indexPath(0,0),value:this.lineData(i)}),this.copied?.tabIndex===this.tabIndex&&this.setCopied(this.copied.uuid,this.copied?.row+1,!1)),i}catch(e){$ui.alert(e)}}delete(e,t){try{super.delete(e,t),this.copied.uuid===e&&(this.copied={},$clipboard.clear())}catch(e){$ui.alert(e)}}update(e,t,i){return!!super.update(e,t,i)&&(this.updateList(),e===this.copied.uuid&&(this.setClipboardText(t),this.updateCopied({text:t})),!0)}move(e,t,i=!0){if(e!==t)try{if(super.move(e,t),!i)return;const r=$(this.listId);ee&&this.copied.rowt||this.copied.row===t)&&this.setCopied(this.copied.uuid,e{i.text?$share.sheet(i.text):$ui.warning($l10n(\"NONE\"))}}];if(this.kernel.isUseJsboxNav)i.uikitPush(e,(e=>t(e)),r);else{const s=i.getNavigationView(e,(e=>t(e)),r);this.viewController.push(s)}}getAddTextView(){this.edit(\"\",(e=>{\"\"!==e&&this.add(e)}))}menuItems(e=!1){const t=[{inline:!0,items:[{title:$l10n(\"TAG\"),symbol:\"tag\",handler:(e,t)=>{const i=this.clips[t.row].uuid;$input.text({placeholder:$l10n(\"ADD_TAG\"),text:e.text,handler:e=>{(e=e.trim()).length>0?this.kernel.storage.setTag(i,e):this.kernel.storage.deleteTag(i),this.loadAllClips(),this.updateList()}})}}]},{inline:!0,items:[{title:$l10n(\"SHARE\"),symbol:\"square.and.arrow.up\",handler:(e,t)=>{const i=this.clips[t.row].text;let r=i;const s=this.kernel.storage.keyToPath(i);if(s&&this.kernel.fileStorage.exists(s.original)){const e=this.kernel.fileStorage.readSync(s.original)?.image?.png;r={name:e.fileName,data:e}}$share.sheet([r])}},{title:$l10n(\"COPY\"),symbol:\"square.on.square\",handler:(e,t)=>{const i=this.clips[t.row];this.copy(i.text,i.uuid,t.row)}},{title:$l10n(\"DELETE\"),symbol:\"trash\",destructive:!0,handler:(e,t)=>{this.kernel.deleteConfirm($l10n(\"CONFIRM_DELETE_MSG\"),(()=>{const i=this.clips[t.row];this.delete(i.uuid,t.row),e.delete(t)}))}}]}];if(e)return t;const i=e=>{const t=this.kernel.actionManager.getActionHandler(e.type,e.dir);return e.handler=(e,i)=>{const r=this.clips[i.row],s=new b({env:y.clipboard,text:r.text,uuid:r.uuid});t(s)},e.title=e.name,e.symbol=e.icon,e},r=this.kernel.actionManager.getActions(\"clipboard\"),s={inline:!0,items:r.slice(0,this.menuItemActionMaxCount).map(i)};return r.length>this.menuItemActionMaxCount&&s.items.push({title:$l10n(\"MORE_ACTIONS\"),symbol:\"square.grid.2x2\",items:r.slice(this.menuItemActionMaxCount).map(i)}),[s,...t]}switchTab(e,t=!1){this.tabIndex=e,this.updateList(),t&&($(this.listId+\"-tab\").index=this.tabIndex)}tabView(){return{type:\"tab\",props:{id:this.listId+\"-tab\",items:this.tabItems,index:this.tabIndex,dynamicWidth:!0},events:{changed:e=>this.switchTab(e.index)},layout:(e,t)=>{e.centerY.equalTo(t.super),t.prev?e.left.equalTo(t.prev.right).offset(this.left_right):e.left.inset(this.left_right)}}}lineData(e,t=!1){const i={hidden:!0},r={text:\"\"},s=this.kernel.storage.keyToPath(e.text);return s?(i.src=s.preview,i.hidden=!1):r.text=e.text,{copied:{hidden:!t},image:i,tag:{text:e.tag},content:r}}listTemplate(){return{props:{bgcolor:$color(\"clear\")},views:[{type:\"view\",views:[{type:\"view\",props:{id:\"copied\",circular:this.copiedIndicatorSize,hidden:!0,bgcolor:$color(\"green\")},layout:(e,t)=>{e.centerY.equalTo(t.super),e.size.equalTo(this.copiedIndicatorSize),e.left.equalTo(t.super).inset(this.left_right/2-this.copiedIndicatorSize/2)}},{type:\"label\",props:{id:\"content\",lines:this.#G?1:2,font:$font(this.fontSize)},layout:(e,t)=>{e.left.right.equalTo(t.super).inset(this.left_right),this.#G?e.top.inset(this.imageContentHeight/2):e.top.inset(this.top_bottom)}},{type:\"image\",props:{id:\"image\",hidden:!0},layout:$layout.fill}],layout:$layout.fill},{type:\"label\",props:{id:\"tag\",color:$color(\"systemGray2\"),font:$font(this.tagFontSize)},layout:(e,t)=>{e.bottom.width.equalTo(t.super),e.left.inset(this.left_right),e.height.equalTo(this.tagContainerHeight)}}]}}getListView(e=this.listId,t=[]){const i={type:\"list\",props:{id:e,associateWithNavigationBar:!1,bgcolor:$color(\"clear\"),separatorInset:$insets(0,this.left_right,0,0),menu:{items:this.menuItems()},data:t,template:this.listTemplate(),actions:[{title:$l10n(\"COPY\"),color:$color(\"systemLink\"),handler:(e,t)=>{const i=this.clips[t.row];this.copy(i.text,i.uuid,t.row)}},{title:$l10n(\"PIN\"),color:$color(\"orange\"),handler:(e,t)=>{const i=this.clips[t.row];this.pin(i,t.row)}}]},layout:$layout.fill,events:{ready:()=>this.listReady(),rowHeight:(e,t)=>{const i=e.object(t),r=i.tag.text?this.tagContainerHeight:this.top_bottom;return(this.kernel.storage.isImage(i.content.text)?this.imageContentHeight:this.getTextHeight(i.content.text))+this.top_bottom+r},didSelect:(e,t,i)=>{const r=this.clips[t.row],s=r.text,a=this.kernel.storage.keyToPath(s);a&&this.kernel.fileStorage.exists(a.original)?$quicklook.open({image:this.kernel.fileStorage.readSync(a.original)?.image}):this.edit(r.text,(e=>{r.md5!==$text.MD5(e)&&this.update(r.uuid,e,t.row)}))},pulled:e=>{this.loadAllClips(),this.updateList(),$delay(.5,(()=>e.endRefreshing()))}}},s={type:\"label\",props:{id:e+\"-empty-list-background\",color:$color(\"secondaryText\"),hidden:this.clips.length>0,text:$l10n(\"NONE\"),align:$align.center},layout:$layout.center};return r.createFromViews([i,s])}getNavigationView(){const e=this.tabView();e.type=\"menu\",e.layout=(e,t)=>{e.top.left.right.equalTo(t.super),e.height.equalTo(this.tabHeight)};const t=this.getListView();t.views.unshift(e),t.views[1].layout=(e,t)=>{e.bottom.left.right.equalTo(t.super),e.top.equalTo(t.prev.bottom)},t.views.push(this.search.getSearchHistoryView());const i=(new l).navigationBarTitle($l10n(\"CLIPS\")).setView(t);return i.navigationBarItems.setTitleView(this.search.getSearchBarView()).pinTitleView().setRightButtons([{symbol:\"plus.circle\",tapped:()=>this.getAddTextView()}]).setLeftButtons([{title:$l10n(\"EDIT\"),tapped:()=>{new g(this).presentSheet()}},{symbol:\"square.and.arrow.down.on.square\",tapped:e=>{e.start(),this.readClipboard(!0),e.done()}}]),i.navigationBar.setBackgroundColor(a.primaryViewBackgroundColor).setLargeTitleDisplayMode(c.largeTitleDisplayModeNever),this.kernel.isUseJsboxNav&&i.navigationBar.removeTopSafeArea(),i}}})),parcelRequire.register(\"f0nX9\",(function(e,t){var i=parcelRequire(\"gxpqj\"),r=i.UIKit,s=i.NavigationBar,a=i.NavigationView,n=i.Sheet,o=parcelRequire(\"eSp9Z\"),l=o.ActionEnv,c=o.ActionData;e.exports=class{#X=\"\";constructor(e){this.kernel=e,this.id=\"editor\",this.originalContent=void 0}set text(e=\"\"){void 0===this.originalContent&&(this.originalContent=e),this.#X=e}get text(){return this.#X}getActionButton(){return{symbol:\"bolt.circle\",tapped:(e,t)=>{t&&(e=t);const i=$(this.id).selectedRange,r=new c({env:l.editor,editor:{setContent:e=>this.setContent(e)},text:i.length>0?this.text.slice(i.location,i.location+i.length):this.text,selectedRange:i}),s=$ui.popover({sourceView:e,directions:$popoverDirection.up,size:$size(200,300),views:[this.kernel.actionManager.getActionListView((e=>{s.dismiss(),$delay(.5,(()=>e(r)))}))]})}}}setContent(e){this.text=e,$(this.id).text=e}getView(e=\"text\"){return{type:e,layout:$layout.fill,props:{id:this.id,lineNumbers:this.kernel.setting.get(\"editor.code.lineNumbers\"),theme:this.kernel.setting.get($device.isDarkMode?\"editor.code.darkTheme\":\"editor.code.lightTheme\"),text:this.text,insets:$insets(15,15,\"text\"===e?this.kernel.setting.get(\"editor.text.insets\"):15,15)},events:{ready:e=>{\"\"===this.text&&setTimeout((()=>e.focus()),500)},didChange:e=>{this.text=e.text}}}}pageSheet(e=\"\",t,i,r=[],s=\"text\"){this.text=e,r.unshift(this.getActionButton());const a=new n;a.setView(this.getView(s)).addNavBar({title:i,popButton:{title:$l10n(\"DONE\"),tapped:()=>t(this.text)},rightButtons:r}),a.navigationView.navigationBar.contentViewHeightOffset=0,a.init().present()}uikitPush(e=\"\",t,i=[],s=\"text\"){this.text=e,i.unshift(this.getActionButton()),r.push({title:\"\",navButtons:i.map((e=>(e.handler=e.tapped,e.tapped=void 0,e))),views:[this.getView(s)],disappeared:()=>t(this.text)})}getNavigationView(e=\"\",t,i=[],r=\"text\"){this.text=e,i.unshift(this.getActionButton());const n=new a;return n.navigationBar.contentViewHeightOffset=0,n.navigationBar.setLargeTitleDisplayMode(s.largeTitleDisplayModeNever),n.navigationBarItems.setRightButtons(i),n.setView(this.getView(r)).navigationBarTitle(\"\"),n.setEvent(\"onPop\",(()=>t(this.text))),n}}})),parcelRequire.register(\"eSp9Z\",(function(e,t){var i=parcelRequire(\"gxpqj\"),r=i.Kernel,s=i.Sheet;class a{static keyboard=0;static today=0;static editor=1;static clipboard=2;static action=3}e.exports={ActionEnv:a,ActionData:class{env;args;text;originalContent;uuid;selectedRange;textBeforeInput;textAfterInput;editor;constructor({env:e,args:t,text:i,uuid:r=null,selectedRange:s=null,textBeforeInput:a=null,textAfterInput:n=null,editor:o=null}={}){this.env=e,this.args=t,this.text=i,this.originalContent=i,this.uuid=r,this.selectedRange=s,this.textBeforeInput=a,this.textAfterInput=n,this.editor=o}},Action:class{#Q;constructor(e,t,i){this.#Q=e,this.config=t,Object.assign(this,i),this.originalContent=this.text;const s=this.l10n();Object.keys(s).forEach((e=>{r.l10n(e,s[e])}))}l10n(){return{}}pageSheet({view:e,title:t=\"\",done:i,doneText:r=$l10n(\"DONE\"),rightButtons:a=[]}){(new s).setView(e).addNavBar({title:t,popButton:{title:r,tapped:()=>{i&&i()}},rightButtons:a}).init().present()}getAllClips(){return{pin:this.#Q.storage.all(\"pin\").map((e=>e.text)),clips:this.#Q.storage.all(\"clips\").map((e=>e.text))}}async clearAllClips(){if(0!==(await $ui.alert({title:$l10n(\"DELETE_DATA\"),message:$l10n(\"DELETE_TABLE\").replace(\"${table}\",$l10n(\"CLIPS\")),actions:[{title:$l10n(\"DELETE\"),style:$alertActionType.destructive},{title:$l10n(\"CANCEL\")}]})).index)return!1;try{return this.#Q.storage.deleteTable(\"clips\"),!0}catch(e){throw this.#Q.error(e),e}}setContent(e){this.text=e,this.env===a.editor&&this.editor.setContent(e)}getAction(e,t,i){return this.#Q.actionManager.getAction(e,t,i)}async runAction(e,t){const i=this.getAction(e,t);return await i.do()}async request(e,t,i={},r={}){try{this.#Q.print(`sending request [${t}]: ${e}`);const s=await $http.request({header:r,url:e,method:t,body:i,timeout:5});if(s.error)throw s.error;if(s?.response?.statusCode>=400){let e=s.data;throw\"object\"==typeof e&&(e=JSON.stringify(e)),new Error(\"http error: [\"+s.response.statusCode+\"] \"+e)}return s}catch(e){throw e.code&&(e=new Error(\"network error: [\"+e.code+\"] \"+e.localizedDescription)),e}}getUrls(){return(this.text??\"\").match(/(https?:\\/\\/)([\\da-z\\.-]+)\\.([a-z\\.]{2,6})([:0-9])*([\\/\\w\\#\\.\\-\\?\\=\\&])*\\s?/gi)??[]}}}})),parcelRequire.register(\"4ZHFw\",(function(e,t){var i=parcelRequire(\"gxpqj\").UIKit;e.exports=class{kernel;pasteboard=$objc(\"UIPasteboard\").$generalPasteboard();#Z=[];savedClipboardIndex={};tabItems=[$l10n(\"PIN\"),$l10n(\"CLIPS\")];tabItemsIndex=[\"pin\",\"clips\"];constructor(e){this.kernel=e}set tabIndex(e){$cache.set(\"caio.main.tab.index\",e)}get tabIndex(){return $cache.get(\"caio.main.tab.index\")??0}get table(){return this.tabItemsIndex[this.tabIndex]}get tableL10n(){return this.tabItems[this.tabIndex]}get allClips(){return 0===this.#Z.length&&this.loadAllClips(),this.#Z}set allClips(e){this.#Z=e.map((e=>new Proxy(e??[],{set:(e,t,i)=>Reflect.set(e,t,i)})))}get clips(){return this.allClips[this.tabIndex]}get isChanged(){const e=this.pasteboard.$changeCount(),t=$cache.get(\"clipboard.changeCount\");return $cache.set(\"clipboard.changeCount\",e),t!==e}getRowByUUID(e){let t=this.clips.length;for(let i=0;i{const i=JSON.parse(JSON.stringify(e));return Object.assign(i,t)},r=this.table;this.clips[t]||(this.clips[t]={uuid:null,text:\"\",next:null,prev:this.clips[t-1].uuid});try{this.kernel.storage.beginTransaction();const s=i(this.clips[e]),a=i(this.clips[t]);if(this.clips[e-1]){const t=i(this.clips[e-1],{next:this.clips[e].next});this.kernel.storage.update(r,t),this.clips[e-1]=t}if(this.clips[e+1]){const t=i(this.clips[e+1],{prev:this.clips[e].prev});this.kernel.storage.update(r,t),this.clips[e+1]=t}if(this.clips[t-1]){const s=i(this.clips[t-1],{next:this.clips[e].uuid});this.kernel.storage.update(r,s),this.clips[t-1]=s}const n=i(a,{prev:s.uuid,next:this.clips[t].next});this.kernel.storage.update(r,n);const o=i(s,{prev:this.clips[t].prev,next:a.uuid});this.kernel.storage.update(r,o),this.clips[t]=n,this.clips[e]=o,this.clips.splice(t,0,this.clips[e]),this.clips.splice(e>t?e+1:e,1),this.kernel.storage.commit()}catch(e){throw this.kernel.error(e),this.kernel.storage.rollback(),e}finally{null===this.clips[t].uuid&&this.clips.splice(t,1)}}pin(e,t){e.next=this.allClips[0][0]?.uuid??null,e.prev=null;try{this.kernel.storage.beginTransaction(),this.kernel.storage.insert(\"pin\",e),e.next&&(this.allClips[0][0].prev=e.uuid,this.kernel.storage.update(\"pin\",this.allClips[0][0])),this.kernel.storage.commit(),\"pin\"!==e?.section&&(e.section=\"pin\",this.delete(e.uuid,t)),this.allClips[0].unshift(e),this.savedClipboardIndex[e.md5]=1}catch(e){throw this.kernel.error(e),this.kernel.storage.rollback(),e}}loadAllClips(){this.kernel.print(\"load all clips\");const e=e=>{try{return this.kernel.storage.sort(e,this.kernel.setting.get(\"clipboard.maxItemLength\")).map((e=>(this.savedClipboardIndex[e.md5]=1,e)))}catch(e){$ui.alert({title:$l10n(\"REBUILD_DATABASE\"),message:$l10n(\"CLIPS_STRUCTURE_ERROR\"),actions:[{title:$l10n(\"OK\"),handler:()=>{const e=i.loading();e.start(),this.kernel.storage.rebuild(),e.end(),$delay(.8,(()=>$addin.restart()))}},{title:$l10n(\"CANCEL\")}]}),this.kernel.error(e)}};this.allClips=[e(this.kernel.storage.all(this.tabItemsIndex[0])),e(this.kernel.storage.all(this.tabItemsIndex[1]))]}}})),parcelRequire.register(\"ay4Kj\",(function(e,t){var i=parcelRequire(\"gxpqj\"),r=i.UIKit,s=i.SearchBar;e.exports=class{listId=\"clips-list-search\";kernel;callback=()=>{};onBegin=()=>{};onDismiss=()=>{};constructor(e){this.kernel=e,this.searchBar=new s,this.searchBarId=this.searchBar.id+\"-input\"}get searchHistoryView(){return{hide:()=>$(this.listId+\"-history\").hidden=!0,show:()=>$(this.listId+\"-history\").hidden=!1}}get searchHistory(){return[{title:$l10n(\"SEARCH_HISTORY\"),rows:$cache.get(\"caio.search.history\")?.reverse()??[]}]}getAccessoryView(){return r.blurBox({height:50},[{type:\"button\",props:{bgcolor:$color(\"clear\"),tintColor:$color(\"primaryText\"),symbol:\"xmark.circle\"},layout:(e,t)=>{e.right.inset(0),e.height.equalTo(t.super),e.width.equalTo(t.super.height)},events:{tapped:()=>this.dismiss()}},{type:\"button\",props:{bgcolor:$color(\"clear\"),tintColor:$color(\"primaryText\"),symbol:\"keyboard.chevron.compact.down\"},layout:(e,t)=>{e.right.equalTo(t.prev.left),e.height.equalTo(t.super),e.width.equalTo(t.super.height)},events:{tapped:()=>$(this.searchBarId).blur()}}])}getSearchHistoryView(){return{type:\"list\",props:{id:this.listId+\"-history\",hidden:!0,stickyHeader:!0,data:this.searchHistory,separatorInset:$insets(0,13,0,0),actions:[{title:$l10n(\"DELETE\"),handler:(e,t)=>{const i=e.data;this.updateSearchHistory(i[0].rows.reverse())}}]},events:{didSelect:(e,t,i)=>{this.searchAction(i),$(this.searchBarId).text=i}},layout:$layout.fill}}setCallback(e){this.callback=e}setOnBegin(e){this.onBegin=e}setOnDismiss(e){this.onDismiss=e}begin(){this.searchHistoryView.show(),this.onBegin()}dismiss(){$(this.searchBarId).blur(),$(this.searchBarId).text=\"\",this.searchHistoryView.hide(),this.onDismiss()}searchAction(e){try{if(\"\"!==e){const t=this.kernel.storage.search(e);t&&t.length>0?($(this.searchBarId).blur(),this.callback(t)):$ui.toast($l10n(\"NO_SEARCH_RESULT\")),this.pushSearchHistory(e)}}catch(e){throw e}}pushSearchHistory(e){let t=$cache.get(\"caio.search.history\")??[];-1===t.indexOf(e)&&(t.push(e),t.length>20&&(t=t.slice(-20)),$(this.listId+\"-history\").data=this.searchHistory,$cache.set(\"caio.search.history\",t))}updateSearchHistory(e=[]){$cache.set(\"caio.search.history\",e)}getSearchBarView(){return this.searchBar.controller.setEvent(\"onReturn\",(e=>{\"\"!==e?this.searchAction(e):this.searchHistoryView.show()})),this.searchBar.controller.setEvent(\"onChange\",(e=>{\"\"===e&&this.searchHistoryView.show()})),this.searchBar.setEvent(\"didBeginEditing\",(e=>{\"\"===e.text&&this.begin()})),this.searchBar.setAccessoryView(this.getAccessoryView()),this.searchBar}}})),parcelRequire.register(\"9LqeL\",(function(e,t){var i=parcelRequire(\"gxpqj\"),r=i.View,s=i.UIKit,a=i.Sheet;class n{static symbol={selected:\"checkmark.circle.fill\",unselected:\"circle\"};listId=\"clips-list-editor\";reorder={};toolBarHeight=44;#ee=void 0;#te={};constructor(e){this.clipsInstance=e,this.kernel=e.kernel}get editorSelectedIsEmpty(){let e=!0;const t=this.editorSelected;for(const i of Object.keys(t))if(t[i]){e=!1;break}return e}get editorSelectedIsFull(){let e=0,t=0;const i=this.editorSelected;for(const r of Object.keys(i))++t,i[r]&&++e;return t===e}get editorSelected(){return void 0===this.#ee&&(Array(this.clipsInstance.clips.length).fill(0).map(((e,t)=>this.#te[t]=!1)),this.#ee=new Proxy(this.#te,{set:(e,t,i,r)=>{Reflect.set(e,t,i,r),t=Number(t);const s=this.editorSelectedIsEmpty,a=$(this.listId+\"-select-button\"),o=$(this.listId+\"-delete-button\");a.title=this.editorSelectedIsFull?$l10n(\"DESELECT_ALL\"):$l10n(\"SELECT_ALL\"),o.hidden=s;const l=$(this.listId);return l.data=this.clipsInstance.clips.map(((t,i)=>{const r=this.lineData(t);return r.checkmark={symbol:e[i]?n.symbol.selected:n.symbol.unselected},r})),l.reorder=s,!0}})),this.#ee}set editorSelected(e){this.#ee=e}selectAll(){const e=this.editorSelectedIsFull;this.clipsInstance.clips.forEach(((t,i)=>{this.editorSelected[i]=!e}))}deleteSelected(){this.kernel.deleteConfirm($l10n(\"CONFIRM_DELETE_MSG\"),(()=>{const e=$(this.listId),t=$(this.clipsInstance.listId);Object.keys(this.editorSelected).reverse().forEach((i=>{if(this.editorSelected[i]){i=Number(i);const r=this.clipsInstance.clips[i];this.kernel.print(`delete selected: [${i}]\\n${r.text}`),this.clipsInstance.delete(r.uuid,i),t.delete(i),e.delete(i)}}))}))}getToolBarView(){return s.blurBox({},[s.separatorLine(),{type:\"view\",views:[{type:\"button\",props:{id:this.listId+\"-select-button\",title:$l10n(\"SELECT_ALL\"),titleColor:$color(\"tint\"),bgcolor:$color(\"clear\")},layout:(e,t)=>{e.left.inset(this.clipsInstance.left_right),e.centerY.equalTo(t.super)},events:{tapped:()=>this.selectAll()}},{type:\"button\",props:{id:this.listId+\"-delete-button\",symbol:\"trash\",hidden:!0,tintColor:$color(\"red\"),bgcolor:$color(\"clear\")},layout:(e,t)=>{e.right.inset(this.clipsInstance.left_right),e.centerY.equalTo(t.super)},events:{tapped:()=>this.deleteSelected()}}],layout:(e,t)=>{e.left.right.top.equalTo(t.super),e.bottom.equalTo(t.super.safeAreaBottom)}}],((e,t)=>{e.left.right.bottom.equalTo(t.super),e.top.equalTo(t.super.safeAreaBottom).offset(-this.toolBarHeight)}))}lineData(e){const t=this.clipsInstance.lineData(e);return t.checkmark={symbol:n.symbol.unselected},t}listTemplate(){const e=this.clipsInstance.listTemplate();return e.views[0].layout=(e,t)=>{e.height.right.equalTo(t.super),e.left.inset(30)},e.views.push({type:\"image\",props:{id:\"checkmark\",symbol:n.symbol.unselected,contentMode:$contentMode.scaleAspectFit},layout:(e,t)=>{e.centerY.equalTo(t.super),e.left.inset(15),e.size.equalTo($size(25,25))}}),e}getListEditerView(){return{type:\"list\",props:{id:this.listId,bgcolor:s.primaryViewBackgroundColor,separatorInset:$insets(0,this.clipsInstance.left_right,0,0),indicatorInsets:$insets(0,0,this.toolBarHeight,0),data:this.clipsInstance.clips.map((e=>this.lineData(e))),template:this.listTemplate(),reorder:!0,footer:{height:this.toolBarHeight},crossSections:!1},events:{rowHeight:(e,t)=>{const i=this.clipsInstance.clips[t.row].text;return(this.kernel.storage.isImage(i)?this.imageContentHeight:this.clipsInstance.getTextHeight(i))+2*this.clipsInstance.top_bottom},reorderBegan:e=>{this.reorder.began=!0,this.reorder.from=e.row,this.reorder.to=void 0},reorderMoved:(e,t)=>{this.reorder.to=t.row},reorderFinished:()=>{this.reorder.began=!1,void 0!==this.reorder.to&&this.clipsInstance.move(this.reorder.from,this.reorder.to)},didSelect:(e,t,i)=>{this.editorSelected[t.row]=!this.editorSelected[t.row]}},layout:$layout.fill}}presentSheet(){const e=new a;e.setView(r.createFromViews([this.getListEditerView(),this.getToolBarView()])).addNavBar({title:\"\",popButton:{title:$l10n(\"CLOSE\")},rightButtons:[{title:$l10n(\"CLEAR\"),color:$color(\"red\"),tapped:async()=>{if(0===(await $ui.alert({title:$l10n(\"DELETE_DATA\"),message:$l10n(\"DELETE_TABLE\").replace(\"${table}\",this.clipsInstance.tableL10n),actions:[{title:$l10n(\"DELETE\"),style:$alertActionType.destructive},{title:$l10n(\"CANCEL\")}]})).index)try{this.kernel.storage.deleteTable(this.clipsInstance.table),e.dismiss(),this.clipsInstance.loadAllClips(),this.clipsInstance.updateList()}catch(e){this.kernel.error(e),$ui.error(e)}}}]}).init().present()}}e.exports=n})),parcelRequire.register(\"44eiF\",(function(e,t){var i=parcelRequire(\"gxpqj\"),r=i.Matrix,s=i.Setting,a=i.NavigationView,n=i.BarButtonItem,o=i.Sheet,l=i.UIKit,c=parcelRequire(\"f0nX9\"),h=parcelRequire(\"eSp9Z\"),d=h.ActionEnv,p=h.ActionData,u=h.Action;e.exports=class{matrixId=\"actions\";matrix;reorder={};constructor(e){this.kernel=e,this.actionPath=\"scripts/action\",this.actionOrderFile=\"order.json\",this.userActionPath=`${this.kernel.fileStorage.basePath}/user_action`,this.typeNameMap={},this.checkUserAction()}importExampleAction(){try{Object.keys(__ACTIONS__).forEach((e=>{const t=`${this.userActionPath}/${e}`;Object.keys(__ACTIONS__[e]).forEach((i=>{$file.exists(`${t}/${i}/main.js`)||($file.mkdir(t),$file.mkdir(`${t}/${i}`),$file.write({data:$data({string:__ACTIONS__[e][i][\"main.js\"]}),path:`${t}/${i}/main.js`}),$file.write({data:$data({string:__ACTIONS__[e][i][\"config.json\"]}),path:`${t}/${i}/config.json`}),$file.write({data:$data({string:__ACTIONS__[e][i][\"README.md\"]}),path:`${t}/${i}/README.md`}))}))}))}catch{$file.list(this.actionPath).forEach((e=>{const t=`${this.actionPath}/${e}`;if($file.isDirectory(t)){const i=`${this.userActionPath}/${e}`;$file.list(t).forEach((e=>{$file.exists(`${i}/${e}/main.js`)||($file.mkdir(i),$file.copy({src:`${t}/${e}`,dst:`${i}/${e}`}))}))}}))}}checkUserAction(){$file.exists(this.userActionPath)&&0!==$file.list(this.userActionPath).length||($file.mkdir(this.userActionPath),this.importExampleAction())}getActionTypes(){const e=[\"clipboard\",\"editor\"];return e.concat($file.list(this.userActionPath).filter((t=>{if($file.isDirectory(`${this.userActionPath}/${t}`)&&e.indexOf(t)<0)return t})))}getActionOrder(e){const t=`${this.userActionPath}/${e}/${this.actionOrderFile}`;return $file.exists(t)?JSON.parse($file.read(t).string):[]}getActionPath(e,t){return`${this.userActionPath}/${e}/${t}`}getAction(e,t,i){const r=this.getActionPath(e,t),s=JSON.parse($file.read(`${r}/config.json`).string);try{const e=$file.read(`${r}/main.js`).string,t=new Function(\"Action\",\"ActionEnv\",\"ActionData\",`${e}\\n return MyAction`)(u,d,p);return new t(this.kernel,s,i)}catch(e){$ui.error(e),this.kernel.error(e)}}getActionHandler(e,t){return async i=>{try{const r=this.getAction(e,t,i);return await r.do()}catch(e){$ui.error(e),this.kernel.error(e)}}}getActions(e){const t=[],i=`${this.userActionPath}/${e}`;if(!$file.exists(i))return[];const r=r=>{const s=`${i}/${r}/`;if($file.isDirectory(s)){const i=JSON.parse($file.read(s+\"config.json\").string);t.push(Object.assign(i,{dir:r,type:e,name:i.name??r,icon:i.icon}))}},s=this.getActionOrder(e);return s.forEach((e=>r(e))),$file.list(i).forEach((e=>{-1===s.indexOf(e)&&r(e)})),t}getTypeName(e){const t=e.toUpperCase(),i=$l10n(t),r=i===t?e:i;return this.typeNameMap[r]=e,r}getTypeDir(e){return this.typeNameMap[e]??e}editActionInfoPageSheet(e,t){const i=this.getActionTypes(),r={};i.forEach(((e,t)=>{r[e]=t})),this.editingActionInfo=e??{type:\"clipboard\",name:\"MyAction\",color:\"#CC00CC\",icon:\"icon_062.png\",description:\"\"};const a=new s({structure:{},set:(e,t)=>(this.editingActionInfo[e]=\"type\"===e?t[1]:t,!0),get:(e,t=null)=>\"type\"===e?r[this.editingActionInfo.type]:Object.prototype.hasOwnProperty.call(this.editingActionInfo,e)?this.editingActionInfo[e]:t}),n=a.createInput(\"name\",[\"pencil.circle\",\"#FF3366\"],$l10n(\"NAME\")),l=a.createColor(\"color\",[\"pencil.tip.crop.circle\",\"#0066CC\"],$l10n(\"COLOR\")),c=a.createIcon(\"icon\",[\"star.circle\",\"#FF9933\"],$l10n(\"ICON\"),this.kernel.setting.getColor(this.editingActionInfo.color)),h=a.createMenu(\"type\",[\"tag.circle\",\"#33CC33\"],$l10n(\"TYPE\"),i,!0),d={type:\"view\",views:[{type:\"text\",props:{id:\"action-text\",textColor:$color(\"#000000\",\"secondaryText\"),bgcolor:$color(\"systemBackground\"),text:this.editingActionInfo.description,insets:$insets(10,10,10,10)},layout:$layout.fill,events:{tapped:t=>{$(\"actionInfoPageSheetList\").scrollToOffset($point(0,e?230:280)),setTimeout((()=>t.focus()),200)},didChange:e=>{this.editingActionInfo.description=e.text}}}],layout:$layout.fill},p=[{title:$l10n(\"INFORMATION\"),rows:[n,l,c]},{title:$l10n(\"DESCRIPTION\"),rows:[d]}];e||(p[0].rows=p[0].rows.concat(h));(new o).setView({type:\"list\",props:{id:\"actionInfoPageSheetList\",bgcolor:$color(\"insetGroupedBackground\"),style:2,separatorInset:$insets(0,50,0,10),data:p},layout:$layout.fill,events:{rowHeight:(e,t)=>1===t.section?120:50}}).addNavBar({title:\"\",popButton:{title:$l10n(\"DONE\"),tapped:()=>{this.editingActionInfo.dir||(this.editingActionInfo.dir=$text.MD5(this.editingActionInfo.name)),this.saveActionInfo(this.editingActionInfo),t&&t(this.editingActionInfo)}}}).init().present()}editActionMainJs(e=\"\",t){new c(this.kernel).pageSheet(e,(e=>{this.saveMainJs(t,e)}),t.name,[{symbol:\"book.circle\",tapped:()=>{const e=$file.read(\"scripts/action/README.md\").string;(new o).setView({type:\"markdown\",props:{content:e},layout:(e,t)=>{e.size.equalTo(t.super)}}).init().present()}}],\"code\")}saveActionInfo(e){const t=`${this.userActionPath}/${e.type}/${e.dir}`;$file.exists(t)||$file.mkdir(t),$file.write({data:$data({string:JSON.stringify({icon:e.icon,color:e.color,name:e.name,description:e.description})}),path:`${t}/config.json`})}saveMainJs(e,t){const i=`${this.userActionPath}/${e.type}/${e.dir}`,r=`${i}/main.js`;$file.exists(i)||$file.mkdir(i),$text.MD5(t)!==$text.MD5($file.read(r)?.string??\"\")&&$file.write({data:$data({string:t}),path:r})}saveOrder(e,t){$file.write({data:$data({string:JSON.stringify(t)}),path:`${this.userActionPath}/${e}/${this.actionOrderFile}`})}move(e,t,i){if(e.section===t.section&&e.row===t.row)return;const r=(i=i.map((e=>(e.rows=e.rows.map((e=>e.info.info)),e))))[e.section],s=i[t.section],a=e=>{const t=[];return i[e].rows.forEach((e=>t.push(e.dir))),t},n=this.getTypeDir(r.title),o=this.getTypeDir(s.title);e.section===t.section?this.saveOrder(n,a(e.section)):(this.saveOrder(n,a(e.section)),this.saveOrder(o,a(t.section)),$file.move({src:`${this.userActionPath}/${n}/${s.rows[t.row].dir}`,dst:`${this.userActionPath}/${o}/${s.rows[t.row].dir}`})),((i=!0,r)=>{const a=this.matrix,n=this.actionToData(Object.assign(s.rows[t.row],{type:r}));i?(a.insert({indexPath:$indexPath(t.section,t.row+1),value:n},!1),a.delete(e,!1)):(a.delete(e,!1),a.insert({indexPath:t,value:n},!1))})(e.row{const i=e.cell(t),r=i.get(\"info\").info;this.editActionInfoPageSheet(r,(e=>{i.get(\"info\").info=e,i.get(\"color\").bgcolor=this.kernel.setting.getColor(e.color),i.get(\"name\").text=e.name,\"icon_\"===e.icon.slice(0,5)?i.get(\"icon\").icon=$icon(e.icon.slice(5,e.icon.indexOf(\".\")),$color(\"#ffffff\")):i.get(\"icon\").image=$image(e.icon)}))}},{title:$l10n(\"EDIT_SCRIPT\"),symbol:\"square.and.pencil\",handler:(e,t,i)=>{const r=i.info.info;if(!r)return;const s=`${this.userActionPath}/${r.type}/${r.dir}/main.js`,a=$file.read(s).string;this.editActionMainJs(a,r)}},{inline:!0,items:[{title:\"README\",symbol:\"book\",handler:(e,t)=>{const i=e.cell(t).get(\"info\").info;let r;try{r=__ACTIONS__[i.type][i.dir][\"README.md\"]}catch{const e=this.getActionPath(i.type,i.dir);r=$file.read(e+\"/README.md\").string}(new o).setView({type:\"markdown\",props:{content:r},layout:(e,t)=>{e.size.equalTo(t.super)}}).init().present()}}]},{inline:!0,items:[{title:$l10n(\"DELETE\"),symbol:\"trash\",destructive:!0,handler:(e,t,i)=>{this.kernel.deleteConfirm($l10n(\"CONFIRM_DELETE_MSG\"),(()=>{this.delete(i.info.info),e.delete(t)}))}}]}]}getNavButtons(){return[{symbol:\"plus.circle\",menu:{pullDown:!0,asPrimary:!0,items:[{title:$l10n(\"CREATE_NEW_ACTION\"),handler:()=>{this.editActionInfoPageSheet(null,(e=>{this.matrix.insert({indexPath:$indexPath(this.getActionTypes().indexOf(e.type),0),value:this.actionToData(e)});const t=$file.read(`${this.actionPath}/template.js`).string;this.saveMainJs(e,t),this.editActionMainJs(t,e)}))}},{title:$l10n(\"CREATE_NEW_TYPE\"),handler:()=>{$input.text({text:\"\",placeholder:$l10n(\"CREATE_NEW_TYPE\"),handler:e=>{if(\"\"===(e=e.trim()))return void $ui.toast($l10n(\"INVALID_VALUE\"));const t=`${this.userActionPath}/${e}`;$file.isDirectory(t)?$ui.warning($l10n(\"TYPE_ALREADY_EXISTS\")):($file.mkdir(t),$ui.success($l10n(\"SUCCESS\")))}})}}]}},{symbol:\"arrow.up.arrow.down.circle\",tapped:(e,t)=>{$ui.popover({sourceView:t,directions:$popoverDirection.up,size:$size(200,300),views:[this.getActionListView(void 0,{reorder:!0,actions:[{title:\"delete\",handler:(e,t)=>{const i=this.matrix,r=i.object(t,!1).info.info;this.delete(r),i.delete(t,!1)}}]},{reorderBegan:e=>{this.reorder.from=e,this.reorder.to=void 0},reorderMoved:(e,t)=>{this.reorder.to=t},reorderFinished:e=>{void 0!==this.reorder.to&&this.move(this.reorder.from,this.reorder.to,e)}})]})}}]}actionToData(e){return{name:{text:e.name},icon:\"icon_\"===e.icon.slice(0,5)?{icon:$icon(e.icon.slice(5,e.icon.indexOf(\".\")),$color(\"#ffffff\"))}:{image:$image(e.icon)},color:{bgcolor:this.kernel.setting.getColor(e.color)},info:{info:e}}}actionsToData(){return this.getActionTypes().map((e=>{const t=[];return this.getActions(e).forEach((e=>{t.push(this.actionToData(e))})),{title:this.getTypeName(e),items:t,rows:t}}))}getActionListView(e,t={},i={}){return e&&(i.didSelect=(t,i,r)=>{const s=r.info.info,a=this.kernel.actionManager.getActionHandler(s.type,s.dir);e(a)}),{type:\"list\",layout:(e,t)=>{e.top.width.equalTo(t.super.safeArea),e.bottom.inset(0)},events:i,props:Object.assign({reorder:!1,bgcolor:$color(\"clear\"),rowHeight:60,sectionTitleHeight:30,stickyHeader:!0,data:this.actionsToData(),template:{props:{bgcolor:$color(\"clear\")},views:[{type:\"image\",props:{id:\"color\",cornerRadius:8,smoothCorners:!0},layout:(e,t)=>{e.centerY.equalTo(t.super),e.left.inset(15),e.size.equalTo($size(30,30))}},{type:\"image\",props:{id:\"icon\",tintColor:$color(\"#ffffff\")},layout:(e,t)=>{e.centerY.equalTo(t.super),e.left.inset(20),e.size.equalTo($size(20,20))}},{type:\"label\",props:{id:\"name\",lines:1,font:$font(16)},layout:(e,t)=>{e.height.equalTo(30),e.centerY.equalTo(t.super),e.left.equalTo(t.prev.right).offset(15)}},{type:\"label\",props:{id:\"info\"}}]}},t)}}getMatrixView({columns:e=2,spacing:t=15,itemHeight:i=100}={}){return this.matrix=r.create({type:\"matrix\",props:{id:this.matrixId,columns:e,itemHeight:i,spacing:t,bgcolor:l.scrollViewBackgroundColor,menu:{items:this.menuItems()},data:this.actionsToData(),template:{props:{smoothCorners:!0,cornerRadius:10,bgcolor:$color(\"#ffffff\",\"#242424\")},views:[{type:\"image\",props:{id:\"color\",cornerRadius:8,smoothCorners:!0},layout:e=>{e.top.left.inset(10),e.size.equalTo($size(30,30))}},{type:\"image\",props:{id:\"icon\",tintColor:$color(\"#ffffff\")},layout:e=>{e.top.left.inset(15),e.size.equalTo($size(20,20))}},{type:\"button\",props:{bgcolor:$color(\"clear\"),tintColor:l.textColor,titleColor:l.textColor,contentEdgeInsets:$insets(0,0,0,0),titleEdgeInsets:$insets(0,0,0,0),imageEdgeInsets:$insets(0,0,0,0)},views:[{type:\"image\",props:{symbol:\"ellipsis.circle\"},layout:(e,t)=>{e.center.equalTo(t.super),e.size.equalTo(n.style.iconSize)}}],events:{tapped:e=>{const t=e.next.info;if(!t)return;const i=`${this.userActionPath}/${t.type}/${t.dir}/main.js`,r=$file.read(i).string;this.editActionMainJs(r,t)}},layout:e=>{e.top.right.inset(0),e.size.equalTo(n.style.width)}},{type:\"view\",props:{id:\"info\",hidden:!0}},{type:\"label\",props:{id:\"name\",font:$font(16)},layout:(e,t)=>{e.bottom.left.inset(10),e.width.equalTo(t.super)}}]}},layout:$layout.fill,events:{didSelect:(e,t,i)=>{const r=i.info.info,s=new p({env:d.action,text:\"clipboard\"===r.type||\"uncategorized\"===r.type?$clipboard.text:null});this.getActionHandler(r.type,r.dir)(s)},pulled:e=>{$delay(.5,(()=>{e.endRefreshing(),this.matrix.update(this.actionsToData())}))}}}),this.matrix.definition}getPage(){const e=new a;return e.navigationBarItems.setRightButtons(this.getNavButtons()),e.setView(this.getMatrixView()).navigationBarTitle($l10n(\"ACTIONS\")),e.getPage()}present(){(new o).setView(this.getMatrixView()).addNavBar({title:$l10n(\"ACTIONS\"),popButton:{symbol:\"xmark.circle\"},rightButtons:this.getNavButtons()}).init().present()}}})),parcelRequire.register(\"gYDdO\",(function(e,t){async function i(e){!function(e,t=[]){t.forEach((t=>{$file.exists(t)&&(e.print(`delete file: ${t}`),$file.delete(t))}))}(e,[\"scripts/action/clipboard/ClearClipboard\",\"scripts/ui/clipboard.js\",\"scripts/ui/clipboard-data.js\",\"scripts/ui/clipboard-search.js\"]),function(e){const t=e.storage.sqlite.query('SELECT count(*), name FROM sqlite_master WHERE type = \"table\" AND name = \"clipboard\"');if(null!==t.error)throw new Error(`Code [${t.error.code}] ${t.error.domain} ${t.error.localizedDescription}`);t.result.next();const i=t.result.get(0);t.result.close(),i>0&&(e.print(\"copy data from old table: clipboard\"),e.storage.sqlite.update(\"INSERT INTO clips SELECT * FROM clipboard\"),e.print(\"drop table: clipboard\"),e.storage.sqlite.update(\"DROP TABLE clipboard\"))}(e),await async function(e,t={}){const i=\"scripts/action\",r=`${e.fileStorage.basePath}/user_action`,s=[];for(let e of Object.keys(t))t[e].forEach((t=>{const r=JSON.parse($file.read(`${i}/${e}/${t}/config.json`).string);s.push(r.name)}));if(1!==(await $ui.alert({title:$l10n(\"compatibility.rebuildUserAction.alert.title\"),message:$l10n(\"compatibility.rebuildUserAction.alert.message\")+\"\\n\"+JSON.stringify(s,null,2)+\"\\n\"+$l10n(\"compatibility.rebuildUserAction.alert.message2\"),actions:[{title:$l10n(\"OK\")},{title:$l10n(\"CANCEL\")}]})).index)for(let s of Object.keys(t))t[s].forEach((t=>{$file.exists(`${r}/${s}/${t}`)&&(e.print(`rebuild user action: ${s}/${t}`),$file.copy({src:`${i}/${s}/${t}/main.js`,dst:`${r}/${s}/${t}/main.js`}))}))}(e,{uncategorized:[\"ExportAllContent\",\"DisplayClipboard\"],clipboard:[\"B23Clean\"]}),$cache.get(\"caio.keyboard.height\")&&(e.setting.set(\"keyboard.previewAndHeight\",$cache.get(\"caio.keyboard.height\")),$cache.remove(\"caio.keyboard.height\"))}e.exports=async function(e){if(!e)return;const t=$cache.get(\"compatibility.version\")??0;try{t<1&&(e.print(`compatibility: userVersion [${t}] lower than [1], start action`),await i(e))}catch(t){throw e.error(t),t}$cache.set(\"compatibility.version\",1)}})),parcelRequire.register(\"9RsVy\",(function(e,t){var i=parcelRequire(\"gxpqj\"),r=i.Kernel,s=i.UIKit,a=parcelRequire(\"2aNLD\"),n=parcelRequire(\"ilpYs\");let o;function l(){o.setting.method.exportClipboard=e=>{e.actionStart(),o.storage.export((t=>{t?e.actionDone():e.actionCancel()}))},o.setting.method.importClipboard=e=>{e.actionStart(),$ui.alert({title:$l10n(\"ALERT_INFO\"),message:$l10n(\"OVERWRITE_ALERT\"),actions:[{title:$l10n(\"OK\"),handler:()=>{$drive.open({handler:t=>{void 0!==t?\"db\"===t.fileName.slice(-2)||\"zip\"===t.fileName.slice(-3)?o.storage.import(t).then((()=>{e.actionDone(),$delay(.3,(()=>{$addin.restart()}))})).catch((t=>{$ui.error(t),o.print(t),e.actionCancel()})):($ui.warning($l10n(\"FILE_TYPE_ERROR\")),e.actionCancel()):e.actionCancel()}})}},{title:$l10n(\"CANCEL\"),handler:()=>e.actionCancel()}]})},o.setting.method.rebuildDatabase=e=>{e.actionStart();$ui.alert({title:$l10n(\"REBUILD_DATABASE_ALERT\"),actions:[{title:$l10n(\"REBUILD\"),style:$alertActionType.destructive,handler:()=>{(()=>{try{o.storage.rebuild(),e.actionDone(),$delay(.8,(()=>$addin.restart()))}catch(t){e.actionCancel(),$ui.alert(t)}})()}},{title:$l10n(\"CANCEL\"),handler:()=>{e.actionCancel()}}]})},o.setting.method.deleteAllData=e=>{e.actionStart(),$ui.alert({title:$l10n(\"DELETE_ALL_DATA_ALERT\"),actions:[{title:$l10n(\"DELETE\"),style:$alertActionType.destructive,handler:()=>{o.storage.deleteAllData(),e.actionDone(),$delay(.5,(()=>$addin.restart()))}},{title:$l10n(\"CANCEL\"),handler:()=>{e.actionCancel()}}]})}}e.exports=function(e){o=e,o.setting.method.checkUpdate=async e=>{e.actionStart();const t=\"scripts/libs/easy-jsbox.js\";if($file.exists(t))try{const e=await o.checkUpdate();e&&($file.write({data:$data({string:e}),path:t}),$ui.toast(\"The framework has been updated.\"))}catch{}$http.get({url:\"https://raw.githubusercontent.com/ipuppet/CAIO/master/config.json\",handler:t=>{const i=t.data?.info.version;let s;try{s=__INFO__}catch{s=JSON.parse($file.read(\"config.json\").string).info}r.versionCompare(i,s.version)>0?$ui.alert({title:\"New Version\",message:`New version found: ${i}\\nUpdate via Github or click the button to open Erots.`,actions:[{title:$l10n(\"CANCEL\")},{title:\"Erots\",handler:()=>{$addin.run({name:\"Erots\",query:{q:\"show\",objectId:\"603e6eaaca0dd64fcef93e2d\"}})}}]}):$ui.toast(\"No need to update\"),e.actionDone()}})},o.setting.method.previewWidget=e=>{const{Widget:t}=parcelRequire(\"8Makm\"),i={};try{JSON.parse($file.read(\"widget-options.json\").string).forEach((e=>{i[e.name]=e.value}))}catch(e){return void $ui.error(e)}$ui.menu({items:Object.keys(i),handler:e=>{t.render(i[e])}})},o.setting.method.fileManager=()=>{o.fileManager.push(\"storage\")},l(),o.setting.method.exportAction=e=>{e.actionStart();const t=\"actions.zip\",i=\"/actions.zip\",r=o.fileStorage.filePath(i);$archiver.zip({directory:o.actionManager.userActionPath,dest:r,handler:()=>{$share.sheet({items:[{name:t,data:$data({path:r})}],handler:t=>{t?e.actionDone():e.actionCancel(),o.fileStorage.delete(i)}})}})},o.setting.method.importAction=e=>{e.actionStart(),$drive.open({handler:t=>{if(void 0!==t)if(\"zip\"===t.fileName.slice(-3)){const i=`${o.fileStorage.basePath}/action_import`;$archiver.unzip({file:t,dest:i,handler:()=>{$file.list(i).forEach((e=>{$file.isDirectory(`${i}/${e}`)&&$file.copy({src:`${i}/${e}`,dst:`${o.actionManager.userActionPath}/${e}`})})),$file.delete(i),e.actionDone()}})}else $ui.warning($l10n(\"FILE_TYPE_ERROR\")),e.actionCancel();else e.actionCancel()}})},o.setting.method.importExampleAction=e=>{e.actionStart(),o.actionManager.importExampleAction(),e.actionDone()},o.setting.method.rebuildAction=e=>{e.actionStart(),$ui.alert({title:$l10n(\"REBUILD_ACTION_DATABASE_ALERT\"),actions:[{title:$l10n(\"REBUILD\"),style:$alertActionType.destructive,handler:()=>{$file.delete(o.actionManager.userActionPath),e.actionDone(),$delay(.8,(()=>$addin.restart()))}},{title:$l10n(\"CANCEL\")}]})},function(){const e=parcelRequire(\"7eNYp\"),t=200;o.setting.method.previewKeyboard=()=>{const i=new e(o),r=$text.uuid,s=e=>{$(r).updateLayout((t=>{t.height.equalTo(e)})),i.keyboardHeight=e},a=e=>(e-t)/200;return{views:[{type:\"label\",layout:(e,t)=>{e.top.inset(20),e.centerX.equalTo(t.super)},events:{ready:e=>e.text=i.keyboardHeight,tapped:e=>{$input.text({type:$kbType.number,text:i.keyboardHeight,handler:i=>{if(/^[0-9]+$/.test(i)){let r=Number(i);r=Math.min(r,400),r=Math.max(r,t),e.text=r,e.next.value=a(r),s(r)}else $ui.toast(\"Only integers can be entered.\")}})}}},{type:\"slider\",props:{max:1,min:0},layout:(e,t)=>{e.top.equalTo(t.prev.bottom),e.right.inset(20),e.width.equalTo(t.super).offset(-40)},events:{ready:e=>e.value=a(i.keyboardHeight),changed:e=>{const i=Math.floor(200*e.value+t);e.prev.text=i,s(i)}}},{type:\"view\",props:{id:r},views:[i.getView()],layout:(e,t)=>{e.width.equalTo(t.super),e.height.equalTo(i.keyboardHeight),e.bottom.inset(0)}}],layout:$layout.fill}},o.setting.method.setKeyboardQuickStart=()=>a.sheet()}(),o.setting.method.previewTodayWidget=e=>{e.touchHighlightStart();const t=new(parcelRequire(\"49je6\"))(o).getView();s.push({views:[t],disappeared:()=>e.touchHighlightEnd()})},o.setting.method.setTodayWidgetActions=e=>{n.sheet(o)}}})),parcelRequire.register(\"2aNLD\",(function(e,t){var i=parcelRequire(\"gxpqj\").Sheet;class r{constructor(){this.listId=\"keyboard-script-list\"}static getAddins(){const e=$cache.get(\"keyboard.addins\");return void 0===e?(this.setAddins(),[]):JSON.parse(e)}static setAddins(e=[]){e.map(((t,i)=>{null===t&&e.splice(i,1)})),$cache.set(\"keyboard.addins\",JSON.stringify(e))}getUnsetAddins(){const e=$addin.current.name,t=r.getAddins(),i=[];return $addin.list?.forEach((r=>{const s=r.displayName;-1===t.indexOf(s)&&e!==s&&i.push(s)})),i}add(){const e={type:\"list\",props:{data:this.getUnsetAddins()},events:{didSelect:(e,t,i)=>{const s=r.getAddins();s.unshift(i),r.setAddins(s),$(this.listId).insert({indexPath:$indexPath(0,0),value:i}),e.delete(t)}},layout:$layout.fill};(new i).setView(e).addNavBar({title:$l10n(\"ADD\")}).init().present()}getNavButtons(){return[{symbol:\"plus\",tapped:()=>this.add()}]}getListView(){return{type:\"list\",props:{id:this.listId,reorder:!0,data:r.getAddins(),actions:[{title:\"delete\",handler:(e,t)=>{r.setAddins(e.data)}}]},events:{reorderFinished:e=>{r.setAddins(e)}},layout:$layout.fill}}static sheet(){const e=new i,t=new r;e.setView(t.getListView()).addNavBar({title:$l10n(\"QUICK_START_SCRIPTS\"),popButton:{title:$l10n(\"CLOSE\")},rightButtons:t.getNavButtons()}),e.init().present()}}e.exports=r})),parcelRequire.register(\"ilpYs\",(function(e,t){var i=parcelRequire(\"gxpqj\").Sheet;class r{constructor(e){this.listId=\"today-action-list\",this.kernel=e}getActions(){let e=$cache.get(\"today.actions\")??[];\"string\"==typeof e&&(e=JSON.parse(e),this.setActions(e));const t={};this.kernel.actionManager.getActionTypes().forEach((e=>{this.kernel.actionManager.getActions(e).forEach((e=>{t[e.type+e.dir]=e}))}));const i=[];let r=!1;return e.forEach((e=>{const s=t[e.type+e.dir];s?i.push(s):r=!0})),r&&this.setActions(i),i}setActions(e=[]){e.map(((t,i)=>{t||e.splice(i,1)})),$cache.set(\"today.actions\",e)}getAllActions(){let e=[];return this.kernel.actionManager.getActionTypes().forEach((t=>{e=e.concat(this.kernel.actionManager.getActions(t))})),e}getUnsetActions(){const e=this.getActions().map((e=>e.name)),t=[];return this.getAllActions().forEach((i=>{const r=i.name;-1===e.indexOf(r)&&t.push(i)})),t}getListData(e){return e.map((e=>({action:{text:e.name,info:e},icon:\"icon_\"===e.icon.slice(0,5)?{icon:$icon(e.icon.slice(5,e.icon.indexOf(\".\")),$color(\"#ffffff\"))}:{image:$image(e.icon)},color:{bgcolor:this.kernel.setting.getColor(e.color)}})))}getListTemplate(){return{views:[{type:\"image\",props:{id:\"color\",cornerRadius:8,smoothCorners:!0},layout:e=>{e.top.left.inset(10),e.size.equalTo($size(30,30))}},{type:\"image\",props:{id:\"icon\",tintColor:$color(\"#ffffff\")},layout:e=>{e.top.left.inset(15),e.size.equalTo($size(20,20))}},{type:\"label\",props:{id:\"action\"},layout:(e,t)=>{e.bottom.top.inset(10),e.left.equalTo(t.prev.prev.right).offset(10),e.right.inset(10)}}]}}add(){const e={type:\"list\",props:{data:this.getListData(this.getUnsetActions()),template:this.getListTemplate(),rowHeight:50},events:{didSelect:(e,t,i)=>{const r=i.action.info,s=this.getActions();s.unshift(r),this.setActions(s),$(this.listId).insert({indexPath:$indexPath(0,0),value:this.getListData([r])[0]}),e.delete(t)}},layout:$layout.fill};(new i).setView(e).addNavBar({title:$l10n(\"ADD\"),popButton:{title:$l10n(\"CLOSE\")}}).init().present()}getNavButtons(){return[{symbol:\"plus\",tapped:()=>this.add()}]}getListView(){return{type:\"list\",props:{id:this.listId,data:this.getListData(this.getActions()),template:this.getListTemplate(),rowHeight:50,reorder:!0,actions:[{title:\"delete\",handler:(e,t)=>{this.setActions(e.data.map((e=>e.action.info)))}}]},events:{reorderFinished:e=>{const t=[];e.forEach((e=>{t.push(e.action.info)})),this.setActions(t)}},layout:$layout.fill}}static sheet(e){const t=new i,s=new r(e);t.setView(s.getListView()).addNavBar({title:$l10n(\"ACTIONS\"),popButton:{title:$l10n(\"CLOSE\")},rightButtons:s.getNavButtons()}),t.init().present()}}e.exports=r})),parcelRequire.register(\"7eNYp\",(function(e,t){var i=parcelRequire(\"eSp9Z\"),r=i.ActionData,s=i.ActionEnv,a=parcelRequire(\"gxpqj\"),n=a.UIKit,o=a.BarButtonItem,l=parcelRequire(\"imdB1\"),c=parcelRequire(\"2aNLD\");e.exports=class extends l{#ie;deleteTimer=void 0;continuousDeleteTimer=void 0;deleteDelay=this.kernel.setting.get(\"keyboard.deleteDelay\");continuousDeleteDelay=.5;left_right=15;top_bottom=10;containerMargin=5;fontSize=14;navHeight=50;menuItemActionMaxCount=3;constructor(e){super(e),this.listId=\"keyboard-clips-list\",this.keyboardSwitchLockId=\"keyboard-switch-lock\",this.keyboardSwitchLockKey=\"caio.keyboard.switch.lock\",this.backgroundImage=this.kernel.setting.getImage(\"keyboard.background.image\"),this.backgroundColor=this.kernel.setting.getColor(this.kernel.setting.get(\"keyboard.background.color\")),this.backgroundColorDark=this.kernel.setting.getColor(this.kernel.setting.get(\"keyboard.background.color.dark\")),this.keyboardSetting(),\"boolean\"!=typeof $cache.get(this.keyboardSwitchLockKey)&&$cache.set(this.keyboardSwitchLockKey,!1)}get keyboardHeight(){return this.kernel.setting.get(\"keyboard.previewAndHeight\")}set keyboardHeight(e){this.kernel.setting.set(\"keyboard.previewAndHeight\",e)}getKeyboardSwitchLock(){const e=$cache.get(this.keyboardSwitchLockKey);return\"boolean\"!=typeof e&&$cache.set(this.keyboardSwitchLockKey,!0),e}switchKeyboardSwitchLock(){const e=$cache.get(this.keyboardSwitchLockKey);$cache.set(this.keyboardSwitchLockKey,!e),$(this.keyboardSwitchLockId).symbol=e?\"lock.open\":\"lock\"}listReady(){this.updateList(),this.appListen(),this.kernel.setting.get(\"clipboard.autoSave\")&&$app.env===$env.keyboard&&(this.#ie=$timer.schedule({interval:1,handler:()=>{this.kernel.setting.get(\"clipboard.autoSave\")?this.readClipboard():this.#ie.invalidate()}}))}keyboardSetting(){if($app.env!==$env.keyboard)return;const e=$timer.schedule({interval:0,handler:()=>{$keyboard.height!==this.keyboardHeight?$keyboard.height=this.keyboardHeight:e.invalidate()}});this.kernel.setting.get(\"keyboard.showJSBoxToolbar\")||($keyboard.barHidden=!0)}keyboardTapped(e,t=!0,i=1){return(...r)=>{t&&this.kernel.setting.get(\"keyboard.tapticEngine\")&&$device.taptic(i),e(...r)}}getTopButtons(){const e=[{symbol:\"keyboard.chevron.compact.down\",tapped:this.keyboardTapped((()=>$keyboard.dismiss()))},{symbol:\"square.and.arrow.down.on.square\",tapped:this.keyboardTapped((e=>{e.start(),this.readClipboard(!0),e.done()}))},{symbol:\"bolt.circle\",tapped:this.keyboardTapped(((e,t)=>{const i=$ui.popover({sourceView:t,directions:$popoverDirection.up,size:$size(200,300),views:[this.kernel.actionManager.getActionListView((e=>{i.dismiss(),$delay(.5,(async()=>{const t=new r({env:s.keyboard,textBeforeInput:$keyboard.textBeforeInput,textAfterInput:$keyboard.textAfterInput,text:$keyboard.selectedText??await $keyboard.getAllText()});e(t)}))}))]})}))}];return{type:\"view\",views:e.map(((e,t)=>(new o).setAlign(n.align.right).setSymbol(e.symbol).setEvent(\"tapped\",e.tapped).definition)),layout:(t,i)=>{const r=new o;t.height.equalTo(i.super),t.right.inset(this.containerMargin-r.edges),t.width.equalTo(r.width*e.length+r.edges)}}}getTopBarView(){return{type:\"view\",views:[{type:\"view\",layout:$layout.fill,views:[{type:\"label\",props:{text:$l10n(\"CAIO\"),font:$font(\"bold\",20)},events:{tapped:()=>this.kernel.openInJsbox(),ready:e=>{$cache.get(\"tips.keyboard.title\")||($cache.set(\"tips.keyboard.title\",!0),$ui.popover({sourceView:e,size:$size(200,60),directions:$popoverDirection.up,views:[{type:\"label\",props:{lines:0,text:$l10n(\"CLICK_TO_OPEN_JSBOX\"),align:$align.center},layout:$layout.fillSafeArea}]}))}},layout:(e,t)=>{e.centerY.equalTo(t.super),e.left.equalTo(t.super).offset(this.containerMargin)}}].concat(this.tabView(),this.getTopButtons())}],layout:(e,t)=>{e.top.width.equalTo(t.super),e.height.equalTo(this.navHeight)}}}getButtonView(e,t){const i=$size(38,38),r=this.containerMargin;return n.blurBox({info:{align:t},smoothCorners:!0,cornerRadius:5},[{type:\"button\",props:Object.assign({symbol:e.symbol,title:e.title,id:e.id??$text.uuid,font:$font(16),bgcolor:this.backgroundImage?$color($rgba(172,176,184,.3),$rgba(71,71,73,.3)):$color(\"#ACB0B8\",\"#474749\"),tintColor:n.textColor,titleColor:n.textColor,info:{align:t}},e.menu?{menu:e.menu}:{}),events:Object.assign({},e.tapped?{tapped:e.tapped}:{},e.events),layout:$layout.fill}],((s,a)=>{if(e.title){const t=$text.sizeThatFits({text:e.title,width:n.windowSize.width,font:$font(16)}),a=Math.ceil(t.width)+2*r;s.size.equalTo($size(a,i.height))}else s.size.equalTo(i);s.centerY.equalTo(a.super),a.prev&&a.prev.info.align===t?t===n.align.right?s.right.equalTo(a.prev.left).offset(-r):s.left.equalTo(a.prev.right).offset(r):t===n.align.right?s.right.inset(r):s.left.inset(r)}))}getBottomBarView(){const e=[],t=[];return $device.hasFaceID&&!$device.isIpadPro||e.push({symbol:\"globe\",tapped:this.keyboardTapped((()=>$keyboard.next())),menu:{pullDown:!0,items:[{title:$l10n(\"SWITCH_KEYBOARD\"),handler:this.keyboardTapped((()=>$keyboard.next()))},{title:$l10n(\"OPEN_IN_JSBOX\"),handler:()=>this.kernel.openInJsbox()}]}}),this.kernel.setting.get(\"keyboard.switchAfterInsert\")&&e.push({symbol:this.getKeyboardSwitchLock()?\"lock\":\"lock.open\",id:this.keyboardSwitchLockId,tapped:this.keyboardTapped((()=>this.switchKeyboardSwitchLock()))}),e.push({symbol:\"paperplane\",menu:{pullDown:!0,asPrimary:!0,items:c.getAddins().reverse().map((e=>({title:e,handler:this.keyboardTapped((()=>$addin.run(e)))})))}}),t.push({title:$l10n(\"SEND\"),tapped:this.keyboardTapped((()=>$keyboard.send()))},{symbol:\"delete.left\",events:{touchesBegan:this.keyboardTapped((()=>{$keyboard.delete(),this.continuousDeleteTimer=$delay(this.continuousDeleteDelay,(()=>{this.deleteTimer=$timer.schedule({interval:this.deleteDelay,handler:this.keyboardTapped((()=>$keyboard.delete()),this.kernel.setting.get(\"keyboard.tapticEngineForDelete\"),0)})}))})),touchesEnded:()=>{this.deleteTimer?.invalidate(),this.continuousDeleteTimer?.cancel(),this.deleteTimer=void 0,this.continuousDeleteTimer=void 0}}}),{type:\"view\",views:[...e.map((e=>this.getButtonView(e,n.align.left))),...t.map((e=>this.getButtonView(e,n.align.right)))],layout:(e,t)=>{e.bottom.left.right.equalTo(t.super.safeArea),e.top.equalTo(t.prev.bottom)}}}menuItems(){const e=super.menuItems();return[e[0],e[2]]}getListView(){const e=super.getListView();e.layout=(e,t)=>{e.top.equalTo(this.navHeight),e.width.equalTo(t.super),e.bottom.equalTo(t.super.safeAreaBottom).offset(-this.navHeight)};const t=e.views[0];t.events.didSelect=(e,t)=>{const i=this.clips[t.row],r=this.kernel.storage.keyToPath(i.text);r&&this.kernel.fileStorage.exists(r.original)?$quicklook.open({image:this.kernel.fileStorage.readSync(r.original)?.image}):($keyboard.insert(i.text),this.kernel.setting.get(\"keyboard.switchAfterInsert\")&&!this.getKeyboardSwitchLock()&&$keyboard.next())},t.props.separatorInset=$insets(0,this.left_right,0,this.left_right);const i=n.blurBox({style:$blurStyle.ultraThinMaterial,smoothCorners:!0,cornerRadius:2*this.containerMargin},[t],((e,t)=>{e.bottom.top.equalTo(t.super),e.left.right.inset(this.containerMargin)}));return e.views[0]=i,e}getView(){return{type:\"view\",props:{id:\"keyboard.main\",bgcolor:$color(this.backgroundColor,this.backgroundColorDark)},views:[{type:\"image\",props:{image:this.backgroundImage,hidden:null===this.backgroundImage},layout:$layout.fill},this.getTopBarView(),this.getListView(),this.getBottomBarView()],layout:$layout.fill}}}})),parcelRequire.register(\"49je6\",(function(e,t){var i=parcelRequire(\"eSp9Z\"),r=i.ActionData,s=i.ActionEnv,a=parcelRequire(\"gxpqj\"),n=a.View,o=a.UIKit,l=a.BarButtonItem,c=a.NavigationBarItems,h=a.NavigationBar,d=parcelRequire(\"imdB1\"),p=parcelRequire(\"ilpYs\");e.exports=class extends d{left_right=8;top_bottom=10;fontSize=14;navHeight=38;taptic=1;tagFontSize=10;tagContainerHeight=12;matrixItemHeight=50;tabItems=[$l10n(\"PIN\"),$l10n(\"CLIPS\"),$l10n(\"ACTIONS\")];inLauncher=$app.env===$env.today&&-1===$app.widgetIndex;launcherNavHeight=44;constructor(e){super(e),this.actionsId=\"today-list-actions\",this.listContainerId=\"today-list-container\",this.readClipboardButtonId=\"today-nav-readClipboard\",this.listId=\"today-list\",this.navigationBarItems=new c,this.bottomBar=new h,this.bottomBar.navigationBarItems=this.navigationBarItems,this.todayActions=new p(this.kernel),this.setClipboarPageSize($widget.mode),this.listPageNow=[0,0],this.listSection=Math.min(this.tabIndex,1),this.setSingleLine()}get isActionPage(){return 2===this.tabIndex}set tabIndex(e){$cache.set(\"caio.today.tab.index\",e)}get tabIndex(){return $cache.get(\"caio.today.tab.index\")??0}listReady(){$widget.modeChanged=e=>{this.setClipboarPageSize(e),this.updateList()},this.setClipboarPageSize($widget.mode),this.loadAllClips(),this.updateList(),this.appListen(),$delay(.5,(()=>this.readClipboard()))}readClipboard(e=!1){return!this.isActionPage&&$app.env===$env.today&&(super.readClipboard(e),!0)}setClipboarPageSize(e){if(0===e)this.listPageSize=1;else{const e=(($app.env===$env.app?o.windowSize.height:$widget.height)-2*this.navHeight-(this.inLauncher?this.launcherNavHeight:0))/(this.singleLineHeight+2*this.top_bottom),t=Math.floor(e);this.listPageSize=t,e-t>=.6&&this.listPageSize++}}buttonTapped(e,t=!0){return(...i)=>{t&&this.kernel.setting.get(\"keyboard.tapticEngine\")&&$device.taptic(this.taptic),e(...i)}}navButtons(){return[{symbol:\"square.and.arrow.down.on.square\",props:{id:this.readClipboardButtonId,hidden:this.isActionPage},tapped:this.buttonTapped((e=>{e.start(),this.readClipboard(!0)?e.done():e.cancel()}))}].map((e=>{const t=new l;return t.setAlign(o.align.right).setSymbol(e.symbol).setEvent(\"tapped\",e.tapped).setProps(e.props??{}),t.definition}))}switchTab(e){this.tabIndex=e,2===e?($(this.listContainerId).hidden=!0,$(this.actionsId).hidden=!1,$(this.readClipboardButtonId).hidden=!0):(this.listSection=e,$(this.actionsId).hidden=!0,$(this.listContainerId).hidden=!1,$(this.readClipboardButtonId).hidden=!1,this.updateList())}getNavBarView(){return{type:\"view\",views:[{type:\"view\",layout:$layout.fill,views:[this.tabView(),{type:\"label\"},...this.navButtons()]}],layout:(e,t)=>{e.top.width.equalTo(t.super),e.height.equalTo(this.navHeight)}}}getBottomBarView(){this.navigationBarItems.setLeftButtons([{symbol:\"chevron.backward.circle\",tapped:this.buttonTapped((()=>{this.clipboardPrevPage()}))}]).setRightButtons([{symbol:\"chevron.forward.circle\",tapped:this.buttonTapped((()=>{this.clipboardNextPage()}))}]),this.bottomBar.setTitle(this.listPageNow[this.listSection]+1).setLargeTitleDisplayMode(h.largeTitleDisplayModeNever);const e=this.bottomBar.getNavigationBarView();return e.layout=(e,t)=>{e.bottom.left.right.equalTo(t.super.safeArea),e.top.equalTo(t.prev.bottom)},e}updateList(){const e=this.listPageNow[this.listSection]*this.listPageSize,t=e+this.listPageSize;$(this.listId).data=this.allClips[this.listSection].slice(e,t).map((e=>this.lineData(e))),$(this.bottomBar.id+\"-small-title\").text=this.listPageNow[this.listSection]+1}clipboardPrevPage(){this.listPageNow[this.listSection]>0&&(this.listPageNow[this.listSection]--,this.updateList())}clipboardNextPage(){const e=Math.ceil(this.allClips[this.listSection].length/this.listPageSize);this.listPageNow[this.listSection]this.listReady(),rowHeight:(e,t)=>{const i=e.object(t).tag.text?this.tagContainerHeight:this.top_bottom;return this.singleLineHeight+this.top_bottom+i},didSelect:this.buttonTapped(((e,t)=>{const i=this.clips[t.row],r=this.kernel.storage.keyToPath(i.text);r&&this.kernel.fileStorage.exists(r.original)?$clipboard.image=this.kernel.fileStorage.readSync(r.original).image:(this.setClipboardText(i.text),this.setCopied(i.uuid,t.row)),$ui.toast($l10n(\"COPIED\"))}))},layout:(e,t)=>{e.top.width.equalTo(t.super),e.bottom.equalTo(t.super).offset(-this.navHeight)}},this.getBottomBarView()],layout:(e,t)=>{e.top.equalTo(this.navHeight),e.bottom.left.right.equalTo(t.super.safeArea)}}}getActionView(){let e=this.todayActions.getActions();0===e.length&&(e=this.todayActions.getAllActions());const t={type:\"matrix\",props:{id:this.matrixId,bgcolor:$color(\"clear\"),columns:2,itemHeight:this.matrixItemHeight,spacing:this.left_right,data:e.map((e=>this.kernel.actionManager.actionToData(e))),template:{props:{smoothCorners:!0,cornerRadius:10,bgcolor:$color($rgba(255,255,255,.3),$rgba(0,0,0,.3))},views:[{type:\"image\",props:{id:\"color\",cornerRadius:this.left_right,smoothCorners:!0},layout:e=>{const t=this.matrixItemHeight-20;e.top.left.inset((this.matrixItemHeight-t)/2),e.size.equalTo($size(t,t))}},{type:\"image\",props:{id:\"icon\",tintColor:$color(\"#ffffff\")},layout:(e,t)=>{e.edges.equalTo(t.prev).insets(5)}},{type:\"label\",props:{id:\"name\",font:$font(14)},layout:(e,t)=>{e.bottom.top.inset(10),e.left.equalTo(t.prev.prev.right).offset(10),e.right.inset(10)}},{type:\"view\",props:{id:\"info\",hidden:!0}}]}},layout:$layout.fill,events:{didSelect:(e,t,i)=>{const a=i.info.info,n=new r({env:s.today,text:\"clipboard\"===a.type||\"uncategorized\"===a.type?$clipboard.text:null});this.kernel.actionManager.getActionHandler(a.type,a.dir)(n)}}};return{type:\"view\",props:{id:this.actionsId,hidden:2!==this.tabIndex},views:[t],layout:(e,t)=>{e.top.equalTo(this.navHeight),e.bottom.left.right.equalTo(t.super.safeArea)}}}getView(){return n.create({props:{titleColor:o.textColor,barColor:o.primaryViewBackgroundColor},views:[{type:\"view\",views:[this.getNavBarView(),this.getListView(),this.getActionView()],layout:$layout.fill}],events:{appeared:async()=>{if($app.env!==$env.today)return;const e=$timer.schedule({interval:0,handler:()=>{$ui.animate({duration:.3,animation:()=>{$ui.vc.ocValue().$view().$setBackgroundColor($color(\"clear\"))},completion:()=>{e.invalidate()}})}})}}})}}})),$app.strings={en:{ALERT_INFO:\"Alert\",NONE:\"Nothing\",DONE:\"Done\",CLOSE:\"Close\",FAILED_TO_LOAD_VIEW:\"Faild to load view\",VIEW_NOT_PROVIDED:\"The view is not provided\",UNCATEGORIZED:\"Uncategorized\",SHARE:\"Share\",CLICK_TO_OPEN_JSBOX:\"Click the title to open the main app.\",CLIPS:\"Clips\",CLIPBOARD:\"Clipboard\",UNIVERSAL_CLIPBOARD:\"Universal Clipboard\",UNIVERSAL_CLIPBOARD_TIPS:\"Universal Clipboard allows you to copy something on your iPhone, and paste it on your Mac–or vice-versa–using iCloud.\",CLIPS_STRUCTURE_ERROR:\"Clips data structure is abnormal\",CLIPBOARD_NO_CHANGE:\"Clipboard no change\",ADD:\"Add\",TAG:\"Tag\",ADD_TAG:\"Add Tag\",EDIT:\"Edit\",SEARCH:\"Search\",SEARCH_HISTORY:\"Search History\",SEARCH_RESULT:\"Search Result\",NO_SEARCH_RESULT:\"No item found.\",PIN:\"Pin\",COPY:\"Copy\",COPIED:\"Copied\",SORT:\"Sort\",ACTIONS:\"Actions\",MORE_ACTIONS:\"More Actions\",PREVIEW:\"Preview\",MAX_ITEM_LENGTH:\"Line Limit\",TEXT_MAX_LENGTH:\"Display Character Length\",AUTO_SAVE:\"Auto Save\",AUTO_SYNC:\"Auto Sync\",SYNC_NOW:\"Sync Now\",UNZIP_FAILED:\"Unzip file failed\",SYNC_ALERT_INFO:\"If it has not been synced locally, the iCloud data will be pulled directly. \\\\nDo you want to continue?\",DELETE_ICLOUD_DATA:\"Delete iCloud Data\",REBUILD:\"Rebuild\",REBUILD_DATABASE:\"Rebuild Database\",REBUILD_DATABASE_ALERT:\"Rebuilding the database will lose the order information, do you want to confirm the rebuild?\",DELETE_ALL_DATA:\"Delete All Data\",DELETE_ALL_DATA_ALERT:\"Are you sure you want to delete all your data?\",DELETE_DATA:\"Delete Data\",DELETE_TABLE:\"Delete all data from ${table}?\",SELECT_ALL:\"Select All\",DESELECT_ALL:\"Deselect All\",EDITOR:\"Editor\",CREATE_NEW:\"Create New\",CREATE_NEW_ACTION:\"New Action\",CREATE_NEW_TYPE:\"New Category\",TYPE_ALREADY_EXISTS:\"This category already exists\",EDIT_DETAILS:\"Edit Details\",EDIT_SCRIPT:\"Edit Script\",INFORMATION:\"Information\",NAME:\"Name\",ICON:\"Icon\",TYPE:\"Category\",DESCRIPTION:\"Description\",CODE:\"Code\",TEXT_INSETS:\"Text bottom margin\",SHOW_LINE_NUMBER:\"Show line number\",LIGHT_MODE_THEME:\"Light Mode Theme\",DARK_MODE_THEME:\"Dark Mode Theme\",SAVE:\"Save\",SAVE_SUCCESS:\"Save success\",SAVE_ERROR:\"Save failed\",DELETE:\"Delete\",CONFIRM_DELETE_TITLE:\"Delete Confirmation\",CONFIRM_DELETE_MSG:\"Are you sure you want to delete?\",DELETE_SUCCESS:\"Delete success\",DELETE_ERROR:\"Delete failed\",IMPORT_EXAMPLE_ACTIONS:\"Import example actions\",REBUILD_ACTION_DATABASE:\"Rebuild Action Database\",REBUILD_ACTION_DATABASE_ALERT:\"Are you sure you want to rebuild?\",EXPORT:\"Export\",IMPORT:\"Import\",FILE_TYPE_ERROR:\"File type does not match\",OVERWRITE_ALERT:\"This operation will overwrite the current data. Do you want to continue?\",KEYBOARD:\"Keyboard\",KEYBOARD_HEIGHT:\"Keyboard Height\",BACKGROUND_COLOR:\"Background Color\",BACKGROUND_COLOR_DARK:\"Dark Background Color\",BACKGROUND_IMAGE:\"Background Image\",DELETE_DELAY:\"Delete Delay\",SWITCH_AFTER_INSERT:\"Switch After Insert\",JSBOX_TOOLBAR:\"JSBox Toolbar\",QUICK_START_SCRIPTS:\"Quick Start Scripts\",SEND:\"Send\",OPEN_IN_JSBOX:\"Open in JSBox\",SWITCH_KEYBOARD:\"Switch Keyboard\",TAPTIC_ENGINE:\"Taptic Engine\",TAPTIC_ENGINE_FOR_DELETE:\"Taptic Engine For Delete\",CHECK_UPDATE:\"Check Update\",UPDATE:\"Update\",WIDGET:\"Widget\",RECENT:\"Recent\",CLICK_ACTION:\"Click Action\",TODAY_WIDGET:\"Today Widget\",PREV_PAGE:\"Prev\",NEXT_PAGE:\"Next\",DISPLAY_MODE:\"Display Mode\",CLASSIC:\"Classic\",MODERN:\"Modern\",FILE_MANAGEMENT:\"File Management\",\"compatibility.rebuildUserAction.alert.title\":\"We need to rebuild some of the action!\",\"compatibility.rebuildUserAction.alert.message\":\"If you tap the OK button, the following actions will be rebuilt:\",\"compatibility.rebuildUserAction.alert.message2\":\"Only the action logic will be changed, and the name and icon will remain as it is.\"},\"zh-Hans\":{ALERT_INFO:\"提示\",NONE:\"什么都没有\",DONE:\"完成\",CLOSE:\"关闭\",FAILED_TO_LOAD_VIEW:\"加载视图失败\",VIEW_NOT_PROVIDED:\"未提供该视图\",UNCATEGORIZED:\"未分类\",SHARE:\"分享\",CLICK_TO_OPEN_JSBOX:\"点击标题打开主应用。\",CLIPS:\"剪切板\",CLIPBOARD:\"剪切板\",UNIVERSAL_CLIPBOARD:\"通用剪贴板\",UNIVERSAL_CLIPBOARD_TIPS:\"用剪贴板允许您在iPhone上复制某些内容,然后使用iCloud将其粘贴到Mac上(反之亦然)。\",CLIPS_STRUCTURE_ERROR:\"剪切板数据结构异常\",CLIPBOARD_NO_CHANGE:\"剪切板无变化\",ADD:\"添加\",TAG:\"标签\",ADD_TAG:\"添加标签\",EDIT:\"编辑\",SEARCH:\"搜索\",SEARCH_HISTORY:\"搜索历史\",SEARCH_RESULT:\"搜索结果\",NO_SEARCH_RESULT:\"搜索无结果\",PIN:\"置顶\",COPY:\"复制\",COPIED:\"已复制\",SORT:\"排序\",ACTIONS:\"动作\",MORE_ACTIONS:\"更多动作\",PREVIEW:\"预览\",MAX_ITEM_LENGTH:\"行数限制\",TEXT_MAX_LENGTH:\"显示字符长度\",AUTO_SAVE:\"自动保存\",AUTO_SYNC:\"自动同步\",SYNC_NOW:\"立即同步\",UNZIP_FAILED:\"解压文件失败\",SYNC_ALERT_INFO:\"若未在本机进行过同步则会直接拉取 iCloud 数据。\\\\n是否继续?\",DELETE_ICLOUD_DATA:\"删除 iCloud 数据\",REBUILD:\"重建\",REBUILD_DATABASE:\"重建数据库\",REBUILD_DATABASE_ALERT:\"重建数据库将会丢失顺序信息,是否确认重建?\",DELETE_ALL_DATA:\"删除所有数据\",DELETE_ALL_DATA_ALERT:\"确定要删除所有数据吗?\",DELETE_DATA:\"删除数据\",DELETE_TABLE:\"删除${table}的所有数据?\",SELECT_ALL:\"全选\",DESELECT_ALL:\"取消全选\",EDITOR:\"编辑器\",CREATE_NEW:\"新建\",CREATE_NEW_ACTION:\"新建动作\",CREATE_NEW_TYPE:\"新建分类\",TYPE_ALREADY_EXISTS:\"该类别已经存在\",EDIT_DETAILS:\"编辑信息\",EDIT_SCRIPT:\"编辑脚本\",INFORMATION:\"信息\",NAME:\"名称\",ICON:\"图标\",TYPE:\"分类\",DESCRIPTION:\"描述\",CODE:\"代码\",TEXT_INSETS:\"文本下边距\",SHOW_LINE_NUMBER:\"显示行号\",LIGHT_MODE_THEME:\"浅色模式主题\",DARK_MODE_THEME:\"深色模式主题\",SAVE:\"保存\",SAVE_SUCCESS:\"保存成功\",SAVE_ERROR:\"保存失败\",DELETE:\"删除\",CONFIRM_DELETE_TITLE:\"删除前确认\",CONFIRM_DELETE_MSG:\"确认要删除吗?\",DELETE_SUCCESS:\"删除成功\",DELETE_ERROR:\"删除失败\",IMPORT_EXAMPLE_ACTIONS:\"导入示例动作\",REBUILD_ACTION_DATABASE:\"重建动作库\",REBUILD_ACTION_DATABASE_ALERT:\"您确认要重建?\",EXPORT:\"导出\",IMPORT:\"导入\",FILE_TYPE_ERROR:\"文件类型不符\",OVERWRITE_ALERT:\"该操作将会覆盖当前数据,是否继续?\",KEYBOARD:\"键盘\",KEYBOARD_HEIGHT:\"键盘高度\",BACKGROUND_COLOR:\"背景色\",BACKGROUND_COLOR_DARK:\"深色模式背景色\",BACKGROUND_IMAGE:\"背景图片\",DELETE_DELAY:\"删除延时\",SWITCH_AFTER_INSERT:\"输入后切换\",JSBOX_TOOLBAR:\"JSBox 工具栏\",QUICK_START_SCRIPTS:\"快速启动脚本\",SEND:\"发送\",OPEN_IN_JSBOX:\"在 JSBox 中打开\",SWITCH_KEYBOARD:\"切换键盘\",TAPTIC_ENGINE:\"触感反馈\",TAPTIC_ENGINE_FOR_DELETE:\"删除按钮触感反馈\",CHECK_UPDATE:\"检查更新\",UPDATE:\"更新\",WIDGET:\"小组件\",RECENT:\"最近内容\",CLICK_ACTION:\"点击事件\",TODAY_WIDGET:\"通知中心小组件\",PREV_PAGE:\"上一页\",NEXT_PAGE:\"下一页\",DISPLAY_MODE:\"显示模式\",CLASSIC:\"经典\",MODERN:\"现代\",FILE_MANAGEMENT:\"文件管理\",\"compatibility.rebuildUserAction.alert.title\":\"我们需要重建部分动作!\",\"compatibility.rebuildUserAction.alert.message\":\"如果您点击 好,以下动作将会被重建:\",\"compatibility.rebuildUserAction.alert.message2\":\"只有动作逻辑会被更改,名称和图标将维持现状。\"}},$app.theme=\"auto\",$app.minSDKVer=\"2.19.0\",$app.minOSVer=\"14.0.0\",$app.idleTimerDisabled=!1,$app.keyboardToolbarEnabled=!0,$app.rotateDisabled=!1,__INFO__={name:\"CAIO\",version:\"1.8.0\",author:\"ipuppet\",module:!1},__README__={\"README.md\":\"# CAIO\\r\\n\\r\\n> Clipboard all in one.\\r\\n> \\r\\n> A Clipboard tool based on JSBox.\\r\\n\\r\\nSupport for home widget and notification center widgets.\\r\\n\\r\\n## Build Taio Action\\r\\n\\r\\nBuild script depend on [Parcel](https://parceljs.org/).\\r\\n\\r\\n```shell\\r\\nnpm i -g parcel\\r\\nnpm run build\\r\\n```\\r\\n\\r\\nYou can also use the packaged files directly [dist/CAIO-en.json](./dist/CAIO-en.json).\\r\\n\\r\\n## Actions\\r\\n\\r\\n> For details on how to write, see `scripts/action/README.md` or the book button in the upper right corner of the `Action` edit page in the app.\\r\\n\\r\\n### `Action` data difference in different environments\\r\\n\\r\\n- The data processed by the `Action` button at the top of the home page is the currently copied content.\\r\\n- The data processed by the `Action` menu that pops up by long-pressing the list is the selected content.\\r\\n- The data processed by the `Action` button in the editor is whatever is being edited.\\r\\n\\r\\n\\r\\n## Today Widget\\r\\n\\r\\n> Click to copy, long press to trigger the action.\\r\\n\\r\\nPlease try to avoid using the Today Widget when JSBox is running CAIO.\",\"README_CN.md\":\"# CAIO\\r\\n\\r\\n> Clipboard all in one.\\r\\n> \\r\\n> A Clipboard tool based on JSBox.\\r\\n\\r\\n支持桌面小组件和通知中心小组件\\r\\n\\r\\n## 构建 Taio 动作\\r\\n\\r\\n构建脚本依赖 [Parcel](https://parceljs.org/)\\r\\n\\r\\n```shell\\r\\nnpm i -g parcel\\r\\nnpm run build\\r\\n```\\r\\n\\r\\n您也可以直接使用已打包好的文件 [dist/CAIO-zh-Hans.json](./dist/CAIO-zh-Hans.json)\\r\\n\\r\\n## Actions\\r\\n\\r\\n> 编写方式详见 `scripts/action/README.md` 或应用内 `Action` 编辑页面右上角图书按钮。\\r\\n\\r\\n### 不同环境中 `Action` 数据区别\\r\\n\\r\\n- 首页顶部 `Action` 按钮处理的数据为当前复制的内容\\r\\n- 长按列表弹出的 `Action` 菜单处理的数据为被选中的内容\\r\\n- 编辑器中顶部 `Action` 按钮(闪电图形按钮)处理的数据为正在编辑的所有内容\\r\\n\\r\\n\\r\\n## Today Widget\\r\\n\\r\\n> 点击复制,长按触发动作。\\r\\n\\r\\n请尽量避免在 JSBox 运行 CAIO 时使用 Today Widget\"},__SETTING__=[{items:[{icon:[\"doc.on.clipboard\",\"#FFCC66\"],type:\"child\",title:\"CLIPS\",key:\"clipboard\",children:[{items:[{icon:[\"link\",\"#FF6633\"],title:\"UNIVERSAL_CLIPBOARD\",type:\"switch\",key:\"clipboard.universal\",value:!0},{icon:[\"cursorarrow.rays\",\"#FF6633\"],title:\"Tips\",type:\"script\",key:\"clipboard.tips.universal\",value:\"$ui.alert({title:$l10n('UNIVERSAL_CLIPBOARD'),message:$l10n('UNIVERSAL_CLIPBOARD_TIPS')})\"}]},{items:[{icon:[\"text.alignleft\",\"#FFCC66\"],title:\"MAX_ITEM_LENGTH\",type:\"number\",key:\"clipboard.maxItemLength\",value:100},{icon:[\"square.and.arrow.down.on.square\",\"#FF6633\"],title:\"AUTO_SAVE\",type:\"switch\",key:\"clipboard.autoSave\",value:!0}]},{items:[{icon:[\"square.and.arrow.up\"],title:\"EXPORT\",type:\"script\",key:\"clipboard.export\",value:\"this.method.exportClipboard\"},{icon:[\"square.and.arrow.down\",\"#FFCC33\"],title:\"IMPORT\",type:\"script\",key:\"clipboard.import\",value:\"this.method.importClipboard\"}]},{items:[{icon:[\"arrow.2.circlepath\",\"red\"],title:\"REBUILD_DATABASE\",type:\"script\",key:\"clipboard.rebuildDatabase\",value:\"this.method.rebuildDatabase\"},{icon:[\"trash\",\"red\"],title:\"DELETE_ALL_DATA\",type:\"script\",key:\"clipboard.deleteAllData\",value:\"this.method.deleteAllData\"}]}]},{icon:[\"bolt.circle\",\"#FF6633\"],type:\"child\",title:\"ACTIONS\",key:\"action\",children:[{items:[{icon:[\"bolt.circle\",\"#FF6633\"],title:\"IMPORT_EXAMPLE_ACTIONS\",type:\"script\",key:\"action.importExampleAction\",value:\"this.method.importExampleAction\"}]},{items:[{icon:[\"square.and.arrow.up\"],title:\"EXPORT\",type:\"script\",key:\"action.export\",value:\"this.method.exportAction\"},{icon:[\"square.and.arrow.down\",\"#FFCC33\"],title:\"IMPORT\",type:\"script\",key:\"action.import\",value:\"this.method.importAction\"}]},{items:[{icon:[\"arrow.2.circlepath\",\"red\"],title:\"REBUILD_ACTION_DATABASE\",type:\"script\",key:\"action.rebuildAction\",value:\"this.method.rebuildAction\"}]}]},{icon:[\"pencil.circle\",\"#CC0099\"],type:\"child\",title:\"EDITOR\",key:\"editor\",children:[{title:\"CLIPS\",items:[{icon:[\"wand.and.stars\",\"#FF6633\"],title:\"TEXT_INSETS\",type:\"number\",key:\"editor.text.insets\",value:300}]},{title:\"CODE\",items:[{icon:[\"list.number\",\"#6699CC\"],title:\"SHOW_LINE_NUMBER\",type:\"switch\",key:\"editor.code.lineNumbers\",value:!1},{icon:[\"wand.and.stars\",\"#FF6633\"],title:\"LIGHT_MODE_THEME\",type:\"input\",key:\"editor.code.lightTheme\",value:\"atom-one-light\"},{icon:[\"wand.and.stars\",\"#FF6633\"],title:\"DARK_MODE_THEME\",type:\"input\",key:\"editor.code.darkTheme\",value:\"atom-one-dark\"}]}]},{icon:[\"keyboard\",\"#a2a5a6\"],type:\"child\",title:\"KEYBOARD\",key:\"keyboard\",children:[{items:[{icon:[\"rectangle.3.offgrid.fill\"],title:\"PREVIEW\",type:\"push\",key:\"keyboard.previewAndHeight\",view:\"this.method.previewKeyboard\",value:267}]},{items:[{icon:[\"sun.min\",\"#A569BD\"],title:\"BACKGROUND_COLOR\",type:\"color\",key:\"keyboard.background.color\",value:\"#D1D3D9\"},{icon:[\"sun.min\",\"#A569BD\"],title:\"BACKGROUND_COLOR_DARK\",type:\"color\",key:\"keyboard.background.color.dark\",value:\"#313131\"},{icon:[\"photo\",\"#FFCC66\"],title:\"BACKGROUND_IMAGE\",type:\"image\",key:\"keyboard.background.image\"}]},{items:[{icon:[\"globe\",\"#1899c4\"],title:\"SWITCH_AFTER_INSERT\",type:\"switch\",key:\"keyboard.switchAfterInsert\",value:!1},{icon:[\"cursor.rays\",\"#FF8C00\"],title:\"TAPTIC_ENGINE\",type:\"switch\",key:\"keyboard.tapticEngine\",value:!0},{icon:[\"option\",\"#157EFB\"],title:\"JSBOX_TOOLBAR\",type:\"switch\",key:\"keyboard.showJSBoxToolbar\",value:!1},{icon:[\"paperplane\"],title:\"QUICK_START_SCRIPTS\",type:\"script\",key:\"keyboard.setKeyboardQuickStart\",value:\"this.method.setKeyboardQuickStart\"}]},{items:[{icon:[\"cursor.rays\",\"#FF8C00\"],title:\"TAPTIC_ENGINE_FOR_DELETE\",type:\"switch\",key:\"keyboard.tapticEngineForDelete\",value:!0},{icon:[\"rays\",\"#FFCC33\"],title:\"DELETE_DELAY\",type:\"number\",key:\"keyboard.deleteDelay\",value:.05}]}]},{icon:[\"rectangle.3.offgrid.fill\",\"#1899c4\"],type:\"child\",title:\"WIDGET\",key:\"widget\",children:[{items:[{icon:[\"rectangle.3.offgrid.fill\"],title:\"PREVIEW\",type:\"script\",key:\"previewWidget\",value:\"this.method.previewWidget\"}]},{title:\"2x2\",items:[{icon:[\"link\"],title:\"CLICK_ACTION\",type:\"menu\",key:\"widget.2x2.widgetURL\",items:[\"ADD\",\"ACTIONS\",\"CLIPS\"],value:2}]}]},{icon:[\"filemenu.and.selection\",\"#ebcc34\"],type:\"child\",title:\"TODAY_WIDGET\",key:\"todayWidget\",children:[{items:[{icon:[\"rectangle.3.offgrid.fill\"],title:\"PREVIEW\",type:\"script\",key:\"todayWidget.preview\",value:\"this.method.previewTodayWidget\"}]},{items:[{icon:[\"bolt.circle\"],title:\"ACTIONS\",type:\"script\",key:\"todayWidget.setTodayWidgetActions\",value:\"this.method.setTodayWidgetActions\"}]}]}]},{items:[{icon:[\"rectangle.topthird.inset.filled\",\"#A569BD\"],title:\"DISPLAY_MODE\",type:\"tab\",key:\"mainUIDisplayMode\",items:[\"CLASSIC\",\"MODERN\"],value:0},{icon:[\"folder.fill\",\"#FF9900\"],title:\"FILE_MANAGEMENT\",type:\"script\",key:\"fileManager\",value:\"this.method.fileManager\"}]},{items:[{icon:[\"/assets/icon/github.com.jpeg\",\"white\"],title:\"Github\",type:\"info\",key:\"github\",value:[\"ipuppet/CAIO\",\"https://github.com/ipuppet/CAIO\"]},{icon:[\"/assets/icon/telegram.png\",\"white\"],title:\"Telegram\",type:\"info\",key:\"telegram\",value:[\"JSBoxTG\",\"https://t.me/JSBoxTG\"]},{icon:[\"person.fill\",\"#FF9900\"],title:\"AUTHOR\",type:\"info\",key:\"author\",value:[\"ipuppet\",\"https://blog.ultagic.com\"]},{icon:[\"arrow.2.circlepath\"],title:\"CHECK_UPDATE\",type:\"script\",key:\"checkUpdate\",value:\"this.method.checkUpdate\"},{icon:[\"book.fill\",\"#A569BD\"],title:\"README\",type:\"script\",key:\"readme\",value:\"this.method.readme\"}]}],__ACTIONS__={clipboard:{B23Clean:{\"config.json\":'{\\r\\n \"icon\": \"trash\",\\r\\n \"color\": \"#FF0000\",\\r\\n \"name\": \"b23 清除追踪\",\\r\\n \"description\": \"清除 b23.tv 分享链接中的追踪参数,转换为 BV 视频链接。\"\\r\\n}',\"main.js\":'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n */\\r\\nclass MyAction extends Action {\\r\\n l10n() {\\r\\n return {\\r\\n \"zh-Hans\": {\\r\\n \"b23clean.converting\": \"正在转换...\",\\r\\n \"b23clean.noUrl\": \"未检测到链接\",\\r\\n \"b23clean.noBiliUrl\": \"未检测到 bilibili 链接\",\\r\\n \"b23clean.success\": \"已转换为 BV 视频链接\",\\r\\n \"b23clean.noChange\": \"无变化\",\\r\\n \"b23clean.multipleLinks\": \"多条链接仅在编辑模式下可用。\"\\r\\n },\\r\\n en: {\\r\\n \"b23clean.converting\": \"Converting...\",\\r\\n \"b23clean.noUrl\": \"No link detected\",\\r\\n \"b23clean.noBiliUrl\": \"bilibili link not detected\",\\r\\n \"b23clean.success\": \"Converted to BV video link\",\\r\\n \"b23clean.noChange\": \"No change\",\\r\\n \"b23clean.multipleLinks\": \"Multiple links are only available in edit mode.\"\\r\\n }\\r\\n }\\r\\n }\\r\\n\\r\\n async cleanUrl(b23url) {\\r\\n if (b23url.indexOf(\"bilibili.com\") === -1 && b23url.indexOf(\"b23.tv\") === -1) {\\r\\n throw new Error($l10n(\"b23clean.noBiliUrl\"))\\r\\n }\\r\\n\\r\\n let url = b23url\\r\\n if (b23url.indexOf(\"b23.tv\") >= 0) {\\r\\n const resp = await $http.get(b23url)\\r\\n url = resp.response.url\\r\\n }\\r\\n\\r\\n const queryStart = url.indexOf(\"?\")\\r\\n if (queryStart > -1) {\\r\\n url = url.substring(0, queryStart - 1)\\r\\n }\\r\\n\\r\\n return url\\r\\n }\\r\\n\\r\\n /**\\r\\n * 系统会调用 do() 方法\\r\\n */\\r\\n async do() {\\r\\n $ui.toast($l10n(\"b23clean.converting\"), 1000)\\r\\n\\r\\n try {\\r\\n const b23url = this.getUrls()\\r\\n if (b23url.length === 0) {\\r\\n throw new Error($l10n(\"b23clean.noUrl\"))\\r\\n }\\r\\n\\r\\n if (b23url.length === 1) {\\r\\n let url = await this.cleanUrl(b23url[0])\\r\\n $ui.clearToast()\\r\\n $ui.alert({\\r\\n title: $l10n(\"b23clean.success\"),\\r\\n message: url,\\r\\n actions: [\\r\\n { title: $l10n(\"OK\") },\\r\\n {\\r\\n title: $l10n(\"COPY\"),\\r\\n handler: () => {\\r\\n $clipboard.text = url\\r\\n $ui.success($l10n(\"COPIED\"))\\r\\n }\\r\\n }\\r\\n ]\\r\\n })\\r\\n } else {\\r\\n if (this.env !== ActionEnv.editor) {\\r\\n $ui.toast($l10n(\"b23clean.multipleLinks\"))\\r\\n return\\r\\n }\\r\\n let flag = false\\r\\n for (let i = 0; i < b23url.length; i++) {\\r\\n try {\\r\\n const url = b23url[i].trim()\\r\\n const replacedUrl = await this.cleanUrl(url)\\r\\n flag = true\\r\\n\\r\\n if (url !== replacedUrl) {\\r\\n const newText = this.text.replace(url, replacedUrl)\\r\\n this.setContent(newText)\\r\\n }\\r\\n } catch {}\\r\\n }\\r\\n if (!flag) {\\r\\n throw new Error($l10n(\"b23clean.noBiliUrl\"))\\r\\n } else {\\r\\n $ui.toast($l10n(\"b23clean.noChange\"))\\r\\n }\\r\\n }\\r\\n } catch (error) {\\r\\n $ui.clearToast()\\r\\n $delay(0.5, () => $ui.error(error))\\r\\n }\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## B23Clean\\r\\n\\r\\n清除 b23.tv 分享链接中的追踪参数,转换为 BV 视频链接。\"},CleanClipboard:{\"config.json\":'{\\r\\n \"icon\": \"trash\",\\r\\n \"color\": \"#FF0000\",\\r\\n \"name\": \"清除剪切板\",\\r\\n \"description\": \"清除剪切板内容\"\\r\\n}',\"main.js\":'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n */\\r\\nclass MyAction extends Action {\\r\\n l10n() {\\r\\n return {\\r\\n \"zh-Hans\": {\\r\\n \"clipboard.clean.success\": \"剪切板已清空\"\\r\\n },\\r\\n en: {\\r\\n \"clipboard.clean.success\": \"Clipboard is cleaned\"\\r\\n }\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * 系统会调用 do() 方法\\r\\n */\\r\\n do() {\\r\\n $clipboard.clear()\\r\\n $ui.success($l10n(\"clipboard.clean.success\"))\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## CleanClipboard\"},DownloadFromUrl:{\"config.json\":'{\\r\\n \"icon\": \"square.and.arrow.down\",\\r\\n \"color\": \"#FF0099\",\\r\\n \"name\": \"从链接下载\",\\r\\n \"description\": \"从链接下载内容,如 js 文件内容等\"\\r\\n}',\"main.js\":'class MyAction extends Action {\\r\\n async downloadContent(url) {\\r\\n const response = await $http.get({\\r\\n url,\\r\\n showsProgress: true\\r\\n })\\r\\n if (response.error) {\\r\\n $ui.alert(response.error.localizedDescription)\\r\\n } else {\\r\\n return response\\r\\n }\\r\\n }\\r\\n\\r\\n async do() {\\r\\n const url = this.getUrls()\\r\\n let response = undefined\\r\\n if (url.length > 1) {\\r\\n $ui.menu({\\r\\n items: url,\\r\\n handler: async (title, index) => {\\r\\n response = await this.downloadContent(url[index])\\r\\n }\\r\\n })\\r\\n } else if (url.length === 1) {\\r\\n response = await this.downloadContent(url[0])\\r\\n } else {\\r\\n $ui.warning(\"未检测到链接\")\\r\\n return\\r\\n }\\r\\n $share.sheet([\\r\\n {\\r\\n name: response.response.suggestedFilename,\\r\\n data: response.data\\r\\n }\\r\\n ])\\r\\n return response\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## DownloadFromUrl\\r\\n\\r\\n从链接下载内容,如 js 文件内容等\"},GetFromWin:{\"config.json\":'{\\r\\n \"icon\": \"square.and.arrow.down\",\\r\\n \"color\": \"#33CC33\",\\r\\n \"name\": \"读取 clipsync\",\\r\\n \"description\": \"通 clipsync 读取 PC 剪切板。\"\\r\\n}',\"main.js\":'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n */\\r\\nclass MyAction extends Action {\\r\\n async getIp(refresh = false) {\\r\\n let address = $cache.get(\"caio.action.clipsync.address\")\\r\\n if (refresh || !address) {\\r\\n address = await $input.text({\\r\\n placeholder: \"Address\",\\r\\n text: $cache.get(\"caio.action.clipsync.address\")\\r\\n })\\r\\n }\\r\\n\\r\\n $cache.set(\"caio.action.clipsync.address\", address)\\r\\n\\r\\n if (!address.startsWith(\"http\")) {\\r\\n address = \"http://\" + address\\r\\n }\\r\\n\\r\\n return address\\r\\n }\\r\\n\\r\\n async do() {\\r\\n let address = await this.getIp()\\r\\n\\r\\n $ui.toast(\"Loading...\", 5)\\r\\n try {\\r\\n const resp = await this.request(address + \"/api/clip\", \"GET\")\\r\\n if (resp.data.status) {\\r\\n $ui.success(\"success\")\\r\\n $clipboard.text = resp.data.data\\r\\n }\\r\\n } catch (error) {\\r\\n $ui.clearToast()\\r\\n $ui.alert({\\r\\n title: \"Error\",\\r\\n message: String(error),\\r\\n actions: [\\r\\n { title: \"OK\" },\\r\\n {\\r\\n title: \"Reset Adress\",\\r\\n handler: () => this.getIp(true)\\r\\n }\\r\\n ]\\r\\n })\\r\\n }\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## GetFromWin\\r\\n\\r\\n通 clipsync 读取 PC 剪切板。\\r\\n\\r\\n服务端:[clipsync](https://github.com/ipuppet/clipsync)\\r\\n\"},OpenUrl:{\"config.json\":'{\\r\\n \"icon\": \"link\",\\r\\n \"color\": \"#FF0099\",\\r\\n \"name\": \"打开链接\",\\r\\n \"description\": \"提取文本中的链接并打开\"\\r\\n}',\"main.js\":'class MyAction extends Action {\\r\\n l10n() {\\r\\n return {\\r\\n \"zh-Hans\": {\\r\\n \"openLink.nourl\": \"未检测到链接\"\\r\\n },\\r\\n en: {\\r\\n \"openLink.nourl\": \"No link detected\"\\r\\n }\\r\\n }\\r\\n }\\r\\n\\r\\n openUrl(url) {\\r\\n $app.openURL(url.trim())\\r\\n }\\r\\n\\r\\n do() {\\r\\n const url = this.getUrls()\\r\\n if (url.length > 1) {\\r\\n $ui.menu({\\r\\n items: url,\\r\\n handler: (title, index) => {\\r\\n this.openUrl(url[index])\\r\\n }\\r\\n })\\r\\n } else if (url.length === 1) {\\r\\n this.openUrl(url[0])\\r\\n } else {\\r\\n $ui.warning($l10n(\"openLink.nourl\"))\\r\\n }\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## OpenUrl\\r\\n\\r\\n提取文本中的URL并打开\"},SendToWin:{\"config.json\":'{\\r\\n \"icon\": \"square.and.arrow.up\",\\r\\n \"color\": \"#33CC33\",\\r\\n \"name\": \"推送 clipsync\",\\r\\n \"description\": \"通 clipsync 推送剪切板至 PC。\"\\r\\n}',\"main.js\":'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n */\\r\\nclass MyAction extends Action {\\r\\n async getIp(refresh = false) {\\r\\n let address = $cache.get(\"caio.action.clipsync.address\")\\r\\n if (refresh || !address) {\\r\\n address = await $input.text({\\r\\n placeholder: \"Address\",\\r\\n text: $cache.get(\"caio.action.clipsync.address\")\\r\\n })\\r\\n }\\r\\n\\r\\n $cache.set(\"caio.action.clipsync.address\", address)\\r\\n\\r\\n if (!address.startsWith(\"http\")) {\\r\\n address = \"http://\" + address\\r\\n }\\r\\n\\r\\n return address\\r\\n }\\r\\n\\r\\n async do() {\\r\\n let address = await this.getIp()\\r\\n\\r\\n $ui.toast(\"Loading...\", 5)\\r\\n try {\\r\\n const resp = await this.request(address + \"/api/clip\", \"POST\", {\\r\\n data: $clipboard.text\\r\\n })\\r\\n if (resp.data.status) {\\r\\n $ui.success(\"success\")\\r\\n }\\r\\n } catch (error) {\\r\\n $ui.clearToast()\\r\\n $ui.alert({\\r\\n title: \"Error\",\\r\\n message: String(error),\\r\\n actions: [\\r\\n { title: \"OK\" },\\r\\n {\\r\\n title: \"Reset Adress\",\\r\\n handler: () => this.getIp(true)\\r\\n }\\r\\n ]\\r\\n })\\r\\n }\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## SendToWin\\r\\n\\r\\n通 clipsync 推送剪切板至 PC。\\r\\n\\r\\n服务端:[clipsync](https://github.com/ipuppet/clipsync)\\r\\n\"},Tokenize:{\"config.json\":'{\\r\\n \"icon\": \"pencil.and.ellipsis.rectangle\",\\r\\n \"color\": \"#0099FF\",\\r\\n \"name\": \"分词复制\",\\r\\n \"description\": \"将文本分词处理后复制\"\\r\\n}',\"main.js\":'class MyAction extends Action {\\r\\n getView() {\\r\\n const color = {\\r\\n background: {\\r\\n normal: $color(\"#E7F2FF\", \"#E7F2FF\"),\\r\\n highlight: $color(\"##074FF\", \"#BBDAFF\")\\r\\n },\\r\\n text: {\\r\\n normal: $color(\"##074FF\", \"##074FF\"),\\r\\n highlight: $color(\"#FFFFFF\", \"#ADADAD\")\\r\\n }\\r\\n }\\r\\n const fontSize = 16\\r\\n const edges = 10\\r\\n return {\\r\\n type: \"matrix\",\\r\\n layout: $layout.fill,\\r\\n props: {\\r\\n spacing: edges,\\r\\n data: this.results.map(item => ({ label: { text: item } })),\\r\\n template: {\\r\\n views: [{\\r\\n type: \"label\",\\r\\n props: {\\r\\n id: \"label\",\\r\\n align: $align.center,\\r\\n cornerRadius: edges,\\r\\n bgcolor: color.background.normal,\\r\\n font: $font(fontSize),\\r\\n textColor: color.text.normal\\r\\n },\\r\\n layout: $layout.fill\\r\\n }]\\r\\n }\\r\\n },\\r\\n events: {\\r\\n highlighted: () => { },\\r\\n itemSize: (sender, indexPath) => {\\r\\n const width = fontSize * this.results[indexPath.item].length + 1\\r\\n if (this.maxtrixItemHeight === undefined)\\r\\n this.maxtrixItemHeight = fontSize + edges * 2\\r\\n return $size(width + edges * 2, this.maxtrixItemHeight)\\r\\n },\\r\\n didSelect: (sender, indexPath) => {\\r\\n const index = this.selected.indexOf(indexPath.item)\\r\\n const label = sender.cell(indexPath).get(\"label\")\\r\\n if (index === -1) {\\r\\n this.selected.push(indexPath.item)\\r\\n label.bgcolor = color.background.highlight\\r\\n label.textColor = color.text.highlight\\r\\n } else {\\r\\n this.selected.splice(index, 1)\\r\\n label.bgcolor = color.background.normal\\r\\n label.textColor = color.text.normal\\r\\n }\\r\\n }\\r\\n }\\r\\n }\\r\\n }\\r\\n /**\\r\\n * 系统会调用 do() 方法\\r\\n */\\r\\n do() {\\r\\n this.selected = []\\r\\n this.results = []\\r\\n $text.tokenize({\\r\\n text: this.text,\\r\\n handler: results => {\\r\\n this.results = results\\r\\n this.pageSheet({\\r\\n view: this.getView(),\\r\\n done: () => {\\r\\n const result = []\\r\\n this.selected.sort().forEach(i => {\\r\\n result.push(this.results[i])\\r\\n })\\r\\n if (result.length > 0) {\\r\\n const text = result.join(\"\")\\r\\n $clipboard.text = text\\r\\n $ui.alert({\\r\\n title: \"完成\",\\r\\n message: `已复制内容:${text}`\\r\\n })\\r\\n }\\r\\n }\\r\\n })\\r\\n }\\r\\n })\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## Tokenize\\r\\n\\r\\n> 将文本分词处理后复制\"}},editor:{PreviewMarkdown:{\"config.json\":'{\\r\\n \"icon\": \"book\",\\r\\n \"color\": \"#9900CC\",\\r\\n \"name\": \"预览Markdown\",\\r\\n \"description\": \"预览Markdown\"\\r\\n}',\"main.js\":'class MyAction extends Action {\\r\\n do() {\\r\\n this.pageSheet({\\r\\n view: {\\r\\n type: \"markdown\",\\r\\n props: { content: this.text },\\r\\n layout: $layout.fill\\r\\n }\\r\\n })\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## PreviewMarkdown\\r\\n\\r\\n> 预览Markdown\"},SelectedText:{\"config.json\":'{\\r\\n \"icon\": \"crop\",\\r\\n \"color\": \"#6699CC\",\\r\\n \"name\": \"选中的文本\",\\r\\n \"description\": \"这是个测试 Action, 将在控制台输出当前选中的文本\"\\r\\n}',\"main.js\":\"class MyAction extends Action {\\r\\n do() {\\r\\n if (this.selectedRange.length > 0) {\\r\\n const selectedText = this.text\\r\\n $ui.alert(selectedText)\\r\\n }\\r\\n }\\r\\n}\\r\\n\",\"README.md\":\"## SelectedText\\r\\n\\r\\n> 显示选中的文本\"}},uncategorized:{DeleteClips:{\"config.json\":'{\\r\\n \"icon\": \"trash\",\\r\\n \"color\": \"#FF0000\",\\r\\n \"name\": \"删除所有剪切板\",\\r\\n \"description\": \"删除所有保存的剪切板(不包括置顶)\"\\r\\n}',\"main.js\":'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n */\\r\\n\\r\\nclass MyAction extends Action {\\r\\n async do() {\\r\\n try {\\r\\n const action = await this.clearAllClips()\\r\\n if (action) {\\r\\n $ui.success($l10n(\"DONE\"))\\r\\n }\\r\\n } catch (error) {\\r\\n $ui.error(error)\\r\\n }\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## DeleteClips\"},DisplayClipboard:{\"config.json\":'{\\r\\n \"icon\": \"option\",\\r\\n \"color\": \"#FF6633\",\\r\\n \"name\": \"显示剪切板\",\\r\\n \"description\": \"显示剪切板内容\"\\r\\n}',\"main.js\":'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n */\\r\\n\\r\\nclass MyAction extends Action {\\r\\n do() {\\r\\n this.pageSheet({\\r\\n view: {\\r\\n type: \"label\",\\r\\n props: {\\r\\n lines: 0,\\r\\n text: $clipboard.text,\\r\\n align: $align.center\\r\\n },\\r\\n layout: $layout.fill\\r\\n }\\r\\n })\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## DisplayClipboard\"},ExportAllContent:{\"config.json\":'{\\r\\n \"icon\": \"square.and.arrow.up\",\\r\\n \"color\": \"#FF3300\",\\r\\n \"name\": \"导出数据\",\\r\\n \"description\": \"导出所有保存的数据\"\\r\\n}',\"main.js\":'class MyAction extends Action {\\r\\n do() {\\r\\n const data = this.getAllClips()\\r\\n if (data.clips.length > 0 || data.pin.length > 0) {\\r\\n $share.sheet(JSON.stringify(data, null, 2))\\r\\n } else {\\r\\n $ui.alert(\"无数据\")\\r\\n }\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## ExportAllContent\\r\\n\\r\\n导出所有保存的数据\"},Replace:{\"config.json\":'{\\r\\n \"icon\": \"square.and.arrow.up\",\\r\\n \"color\": \"#FF3300\",\\r\\n \"name\": \"查找替换\",\\r\\n \"description\": \"查找替换\"\\r\\n}',\"main.js\":'function HtmlTemplate(html) {\\r\\n return `\\r\\n\\r\\n\\r\\n \\r\\n\\r\\n\\r\\n${html}\\r\\n\\r\\n\\r\\n`\\r\\n}\\r\\n\\r\\nclass MyAction extends Action {\\r\\n do() {\\r\\n $ui.menu({\\r\\n items: [\"忽略大小写\", \"大小写敏感\", \"正则表达式\"],\\r\\n handler: async (title, idx) => {\\r\\n const patternText = await $input.text({\\r\\n placeholder: \"查找内容\"\\r\\n })\\r\\n const replaceString = await $input.text({\\r\\n placeholder: \"替换内容\"\\r\\n })\\r\\n let pattern = undefined\\r\\n if (idx === 0) {\\r\\n pattern = new RegExp(`(${patternText})+`, \"gi\")\\r\\n } else if (idx === 1) {\\r\\n pattern = new RegExp(`(${patternText})+`, \"g\")\\r\\n } else if (idx === 2) {\\r\\n pattern = new RegExp(patternText, \"g\")\\r\\n }\\r\\n\\r\\n const matchResultPreview = this.text.replace(pattern, `${replaceString}`)\\r\\n const matchResult = this.text.replace(pattern, replaceString)\\r\\n this.pageSheet({\\r\\n title: \"替换预览\",\\r\\n doneText: \"替换\",\\r\\n view: {\\r\\n type: \"web\",\\r\\n props: {\\r\\n html: HtmlTemplate(matchResultPreview)\\r\\n },\\r\\n layout: $layout.fill\\r\\n },\\r\\n done: () => {\\r\\n this.setContent(matchResult)\\r\\n }\\r\\n })\\r\\n }\\r\\n })\\r\\n // this.setContent(\"Hello world!\")\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## Replace\\r\\n\\r\\n查找替换\"}}};var $8Makm=parcelRequire(\"8Makm\");$8Makm.run()})();" + "value": "(()=>{var $parcel$global=\"undefined\"!=typeof globalThis?globalThis:\"undefined\"!=typeof self?self:\"undefined\"!=typeof window?window:\"undefined\"!=typeof global?global:{},$parcel$modules={},$parcel$inits={},parcelRequire=$parcel$global.parcelRequire94c2;null==parcelRequire&&(parcelRequire=function(e){if(e in $parcel$modules)return $parcel$modules[e].exports;if(e in $parcel$inits){var t=$parcel$inits[e];delete $parcel$inits[e];var i={id:e,exports:{}};return $parcel$modules[e]=i,t.call(i.exports,i,i.exports),i.exports}var r=new Error(\"Cannot find module '\"+e+\"'\");throw r.code=\"MODULE_NOT_FOUND\",r},parcelRequire.register=function(e,t){$parcel$inits[e]=t},$parcel$global.parcelRequire94c2=parcelRequire),parcelRequire.register(\"8Makm\",(function(e,t){var i=parcelRequire(\"gxpqj\"),r=i.UIKit,s=i.ViewController,a=i.TabBarController,n=i.Kernel,o=i.FileStorage,l=i.Setting,c=i.FileManager,h=parcelRequire(\"jEwwi\"),d=parcelRequire(\"imdB1\"),p=parcelRequire(\"44eiF\"),u=parcelRequire(\"gYDdO\"),g=parcelRequire(\"9RsVy\");const $=new o;class f extends n{constructor(){let e;super(),this.query=$context.query,this.fileStorage=$;try{e=__SETTING__}catch{}this.setting=new l({fileStorage:this.fileStorage,structure:e}),this.setting.loadConfig(),this.storage=new h(this),this.initComponents(),g(this)}addOpenInJsboxButton(){this.useJsboxNav(),this.setNavButtons([{image:$image(\"assets/icon.png\"),handler:()=>this.openInJsbox()}])}initComponents(){this.clips=new d(this),this.actionManager=new p(this),this.fileManager=new c}deleteConfirm(e,t){$ui.alert({title:$l10n(\"CONFIRM_DELETE_TITLE\"),message:e,actions:[{title:$l10n(\"DELETE\"),style:$alertActionType.destructive,handler:()=>{t()}},{title:$l10n(\"CANCEL\")}]})}}class y{static kernel=$app.env!==$env.widget?new f:void 0;static renderMainUI(){const e={clips:{icon:\"doc.on.clipboard\",title:$l10n(\"CLIPS\")},actions:{icon:\"command\",title:$l10n(\"ACTIONS\")},setting:{icon:\"gear\",title:$l10n(\"SETTING\")}};if(this.kernel.setting.setEvent(\"onSet\",(e=>{\"mainUIDisplayMode\"===e&&$delay(.3,(()=>$addin.restart()))})),0===this.kernel.setting.get(\"mainUIDisplayMode\"))this.kernel.useJsboxNav(),this.kernel.setting.useJsboxNav(),this.kernel.setNavButtons([{symbol:e.setting.icon,title:e.setting.title,handler:()=>{r.push({title:e.setting.title,views:[this.kernel.setting.getListView()]})}},{symbol:e.actions.icon,title:e.actions.title,handler:()=>{this.kernel.actionManager.present()}}]),this.kernel.UIRender(this.kernel.clips.getNavigationView().getPage());else{this.kernel.fileManager.setViewController(new s),this.kernel.tabBarController=new a;const t=this.kernel.clips.getNavigationView();this.kernel.tabBarController.setPages({clips:t.getPage(),actions:this.kernel.actionManager.getPage(),setting:this.kernel.setting.getPage()}).setCells({clips:e.clips,actions:e.actions,setting:e.setting}),this.kernel.UIRender(this.kernel.tabBarController.generateView().definition)}}static renderKeyboardUI(){this.kernel.addOpenInJsboxButton();const e=new(parcelRequire(\"7eNYp\"))(this.kernel);this.kernel.UIRender(e.getView())}static renderTodayUI(){this.kernel.addOpenInJsboxButton();const e=new(parcelRequire(\"49je6\"))(this.kernel);this.kernel.UIRender(e.getView())}static renderUnsupported(){$intents.finish(\"不支持在此环境中运行\"),$ui.render({views:[{type:\"label\",props:{text:\"不支持在此环境中运行\",align:$align.center},layout:$layout.fill}]})}}class b{static widgetInstance(e,...t){if($file.exists(`/scripts/widget/${e}.js`)){const{Widget:i}=require(`./widget/${e}.js`);return new i(...t)}return!1}static renderError(){$widget.setTimeline({render:()=>({type:\"text\",props:{text:\"Invalid argument\"}})})}static renderClipboard(){const e=new l;e.loadConfig().setReadonly();b.widgetInstance(\"Clipboard\",e,new h({fileStorage:$})).render()}static render(e=$widget.inputValue){\"Clipboard\"===(e=e??\"Clipboard\")?b.renderClipboard():b.renderError()}}e.exports={Widget:b,run:()=>{u(y.kernel),$app.env===$env.app||$app.env===$env.action?y.renderMainUI():$app.env===$env.keyboard?y.renderKeyboardUI():$app.env===$env.widget?b.render():$app.env===$env.today?y.renderTodayUI():y.renderUnsupported()}}})),parcelRequire.register(\"gxpqj\",(function(module,exports){var $parcel$global=\"undefined\"!=typeof globalThis?globalThis:\"undefined\"!=typeof self?self:\"undefined\"!=typeof window?window:void 0!==$parcel$global?$parcel$global:{},$parcel$modules={},$parcel$inits={},parcelRequire=$parcel$global.parcelRequire94c2;null==parcelRequire&&(parcelRequire=function(e){if(e in $parcel$modules)return $parcel$modules[e].exports;if(e in $parcel$inits){var t=$parcel$inits[e];delete $parcel$inits[e];var i={id:e,exports:{}};return $parcel$modules[e]=i,t.call(i.exports,i,i.exports),i.exports}var r=new Error(\"Cannot find module '\"+e+\"'\");throw r.code=\"MODULE_NOT_FOUND\",r},parcelRequire.register=function(e,t){$parcel$inits[e]=t},$parcel$global.parcelRequire94c2=parcelRequire),parcelRequire.register(\"45Ip7\",(function(e,t){class i{static#e=$objc(\"UIApplication\").$sharedApplication();static#t=$objc(\"UINotificationFeedbackGenerator\").$new();static feedbackSuccess(){i.#t.$notificationOccurred(0)}static feedbackError(){i.#t.$notificationOccurred(2)}static align={left:0,right:1,top:2,bottom:3};static textColor=$color(\"primaryText\");static linkColor=$color(\"systemLink\");static primaryViewBackgroundColor=$color(\"primarySurface\");static scrollViewBackgroundColor=$color(\"insetGroupedBackground\");static scrollViewList=[\"list\",\"matrix\"];static isLargeScreen=$device.isIpad||$device.isIpadPro;static get windowSize(){return $objc(\"UIWindow\").$keyWindow().jsValue().size}static NavigationBarNormalHeight=$objc(\"UINavigationController\").invoke(\"alloc.init\").$navigationBar().jsValue().frame.height;static NavigationBarLargeTitleHeight=$objc(\"UITabBarController\").invoke(\"alloc.init\").$tabBar().jsValue().frame.height+i.NavigationBarNormalHeight;static get isSplitScreenMode(){return i.isLargeScreen&&$device.info.screen.width!==i.windowSize.width}static get topSafeAreaInsets(){return i.#e?.$keyWindow()?.$safeAreaInsets()?.top??0}static get bottomSafeAreaInsets(){return i.#e?.$keyWindow()?.$safeAreaInsets()?.bottom??0}static get statusBarOrientation(){return i.#e.$statusBarOrientation()}static get consoleBarHeight(){if($app.isDebugging){let e=i.#e.$statusBarFrame().height+26;return $device.isIphoneX&&(e+=30),e}return 0}static get isHorizontal(){return 3===i.statusBarOrientation||4===i.statusBarOrientation}static loading(){const e=$ui.create(i.blurBox({cornerRadius:15},[{type:\"spinner\",props:{loading:!0,style:0},layout:(e,t)=>{e.size.equalTo(t.prev),e.center.equalTo(t.super)}}]));return{start:()=>{$ui.controller.view.insertAtIndex(e,0),e.layout(((e,t)=>{e.center.equalTo(t.super);const r=Math.min(.6*Math.min(i.windowSize.width,i.windowSize.height),260);e.size.equalTo($size(r,r))})),e.moveToFront()},end:()=>{e.remove()}}}static defaultBackgroundColor(e){return i.scrollViewList.indexOf(e)>-1?i.scrollViewBackgroundColor:i.primaryViewBackgroundColor}static separatorLine(e={},t=i.align.bottom){return{type:\"canvas\",props:e,layout:(e,r)=>{void 0===r.prev?e.top.equalTo(r.super):t===i.align.bottom?e.top.equalTo(r.prev.bottom):e.top.equalTo(r.prev.top),e.height.equalTo(1/$device.info.screen.scale),e.left.right.inset(0)},events:{draw:(t,i)=>{i.strokeColor=e.bgcolor??$color(\"separatorColor\"),i.setLineWidth(1),i.moveToPoint(0,0),i.addLineToPoint(t.frame.width,0),i.strokePath()}}}}static blurBox(e={},t=[],i=$layout.fill){return{type:\"blur\",props:Object.assign({style:$blurStyle.thinMaterial},e),views:t,layout:i}}static getContentSize(e,t=\"A\",r=i.windowSize.width,s){const a={text:t,width:r,font:e};return void 0!==s&&(a.lineSpacing=s),$text.sizeThatFits(a)}static push({views:e,statusBarStyle:t=0,title:i=\"\",navButtons:r=[{title:\"\"}],bgcolor:s=e[0]?.props?.bgcolor??\"primarySurface\",disappeared:a}={}){$ui.push({props:{statusBarStyle:t,navButtons:r,title:i,bgcolor:\"string\"==typeof s?$color(s):s},events:{disappeared:()=>{void 0!==a&&a()}},views:[{type:\"view\",views:e,layout:(e,t)=>{e.top.equalTo(t.super.safeArea),e.bottom.equalTo(t.super),e.left.right.equalTo(t.super.safeArea)}}]})}}e.exports={UIKit:i}})),parcelRequire.register(\"7D8Kb\",(function(module,exports){var $fYz8N=parcelRequire(\"fYz8N\"),$58e2f5443faff7c0$require$Controller=$fYz8N.Controller,$8aDdQ=parcelRequire(\"8aDdQ\"),$58e2f5443faff7c0$require$FileStorageFileNotFoundError=$8aDdQ.FileStorageFileNotFoundError,$58e2f5443faff7c0$require$FileStorage=$8aDdQ.FileStorage,$cgaQ6=parcelRequire(\"cgaQ6\"),$58e2f5443faff7c0$require$Kernel=$cgaQ6.Kernel,$45Ip7=parcelRequire(\"45Ip7\"),$58e2f5443faff7c0$require$UIKit=$45Ip7.UIKit,$aXWmO=parcelRequire(\"aXWmO\"),$58e2f5443faff7c0$require$Sheet=$aXWmO.Sheet,$12xzj=parcelRequire(\"12xzj\"),$58e2f5443faff7c0$require$NavigationView=$12xzj.NavigationView,$dcStC=parcelRequire(\"dcStC\"),$58e2f5443faff7c0$require$NavigationBar=$dcStC.NavigationBar,$gMc1q=parcelRequire(\"gMc1q\"),$58e2f5443faff7c0$require$ViewController=$gMc1q.ViewController;class SettingLoadConfigError extends Error{constructor(){super(\"Call loadConfig() first.\"),this.name=\"SettingLoadConfigError\"}}class SettingReadonlyError extends Error{constructor(){super(\"Attempted to assign to readonly property.\"),this.name=\"SettingReadonlyError\"}}class Setting extends $58e2f5443faff7c0$require$Controller{name;setting={};userData;fileStorage;imagePath;viewController=new $58e2f5443faff7c0$require$ViewController;method={readme:()=>{const e=(()=>{const e=$device.info?.language?.startsWith(\"zh\")?\"README_CN.md\":\"README.md\";try{return __README__[e]??__README__[\"README.md\"]}catch{return $file.read(e)?.string??$file.read(\"README.md\")?.string}})();(new $58e2f5443faff7c0$require$Sheet).setView({type:\"markdown\",props:{content:e},layout:(e,t)=>{e.size.equalTo(t.super)}}).init().present()}};rowHeight=50;edgeOffset=10;iconSize=30;#i={};#r=!1;#s=!1;#a;constructor(e={}){super(),\"function\"==typeof e.set&&\"function\"==typeof e.get?(this.set=e.set,this.get=e.get,this.userData=e.userData):(this.fileStorage=e.fileStorage??new $58e2f5443faff7c0$require$FileStorage,this.dataFile=e.dataFile??\"setting.json\"),e.structure?this.setStructure(e.structure):this.setStructurePath(e.structurePath??\"setting.json\"),this.isUseJsboxNav=e.isUseJsboxNav??!1,this.imagePath=(e.name??\"default\")+\".image/\",this.setName(e.name??$text.uuid),this.loadL10n()}useJsboxNav(){return this.isUseJsboxNav=!0,this}#n(){if(!this.#s)throw new SettingLoadConfigError}loadConfig(){const e=[\"script\",\"info\"],t=this.userData??this.fileStorage.readAsJSON(this.dataFile,{});return this.setting=function i(r){const s={};for(let a of r)for(let r of a.items)if(\"child\"===r.type){const e=i(r.children);Object.assign(s,e)}else-1===e.indexOf(r.type)?s[r.key]=r.key in t?t[r.key]:r.value:s[r.key]=r.value;return s}(this.structure),this.#s=!0,this}hasSectionTitle(e){return this.#n(),!!e[0]?.title}loadL10n(){$58e2f5443faff7c0$require$Kernel.l10n(\"zh-Hans\",{OK:\"好\",DONE:\"完成\",CANCEL:\"取消\",CLEAR:\"清除\",BACK:\"返回\",ERROR:\"发生错误\",SUCCESS:\"成功\",LOADING:\"加载中\",INVALID_VALUE:\"非法参数\",CONFIRM_CHANGES:\"数据已变化,确认修改?\",SETTING:\"设置\",GENERAL:\"一般\",ADVANCED:\"高级\",TIPS:\"小贴士\",COLOR:\"颜色\",COPY:\"复制\",COPIED:\"复制成功\",JSBOX_ICON:\"JSBox 内置图标\",SF_SYMBOLS:\"SF Symbols\",IMAGE_BASE64:\"图片 / base64\",PREVIEW:\"预览\",SELECT_IMAGE:\"选择图片\",CLEAR_IMAGE:\"清除图片\",NO_IMAGE:\"无图片\",ABOUT:\"关于\",VERSION:\"Version\",AUTHOR:\"作者\",AT_BOTTOM:\"已经到底啦~\"},!1),$58e2f5443faff7c0$require$Kernel.l10n(\"en\",{OK:\"OK\",DONE:\"Done\",CANCEL:\"Cancel\",CLEAR:\"Clear\",BACK:\"Back\",ERROR:\"Error\",SUCCESS:\"Success\",LOADING:\"Loading\",INVALID_VALUE:\"Invalid value\",CONFIRM_CHANGES:\"The data has changed, confirm the modification?\",SETTING:\"Setting\",GENERAL:\"General\",ADVANCED:\"Advanced\",TIPS:\"Tips\",COLOR:\"Color\",COPY:\"Copy\",COPIED:\"Copide\",JSBOX_ICON:\"JSBox in app icon\",SF_SYMBOLS:\"SF Symbols\",IMAGE_BASE64:\"Image / base64\",PREVIEW:\"Preview\",SELECT_IMAGE:\"Select Image\",CLEAR_IMAGE:\"Clear Image\",NO_IMAGE:\"No Image\",ABOUT:\"About\",VERSION:\"Version\",AUTHOR:\"Author\",AT_BOTTOM:\"It's the end~\"},!1)}setUserData(e){this.userData=e}setStructure(e){return this.structure=e,this}setStructurePath(e){return this.structure||this.setStructure($58e2f5443faff7c0$require$FileStorage.readFromRootAsJSON(e)),this}setName(e){return this.name=e,this}setFooter(e){return this.#a=e,this}set footer(e){this.#a=e}get footer(){if(void 0===this.#a){let e=$58e2f5443faff7c0$require$FileStorage.readFromRootAsJSON(\"config.json\",{}).info??{};if(!e.version||!e.author)try{e=__INFO__}catch{}this.#a={},e.version&&e.author&&(this.#a={type:\"view\",props:{height:70},views:[{type:\"label\",props:{font:$font(14),text:`${$l10n(\"VERSION\")} ${e.version} ♥ ${e.author}`,textColor:$color({light:\"#C0C0C0\",dark:\"#545454\"}),align:$align.center},layout:e=>{e.left.right.inset(0),e.top.inset(10)}}]})}return this.#a}setReadonly(){return this.#r=!0,this}set(e,t){if(this.#r)throw new SettingReadonlyError;return this.#n(),this.setting[e]=t,this.fileStorage.write(this.dataFile,$data({string:JSON.stringify(this.setting)})),this.callEvent(\"onSet\",e,t),!0}get(e,t=null){return this.#n(),Object.prototype.hasOwnProperty.call(this.setting,e)?this.setting[e]:t}getColor(e){return\"string\"==typeof e?$color(e):$rgba(e.red,e.green,e.blue,e.alpha)}getImagePath(e,t=!1){let i=$text.MD5(e)+\".jpg\";return t&&(i=\"compress.\"+i),this.imagePath+i}getImage(e,t=!1){try{return this.fileStorage.readSync(this.getImagePath(e,t)).image}catch(e){if(e instanceof $58e2f5443faff7c0$require$FileStorageFileNotFoundError)return null;throw e}}getId(e){return`setting-${this.name}-${e}`}#o(e){$(e).bgcolor=$color(\"systemFill\")}#l(e,t=.3){0===t?$(e).bgcolor=$color(\"clear\"):$ui.animate({duration:t,animation:()=>{$(e).bgcolor=$color(\"clear\")}})}#c(e,t,i=!1,r=0){if(t=Object.assign(t,{touchesBegan:()=>{this.#o(e),this.#i[e]=$delay(1,(()=>this.#l(e,0)))},touchesMoved:()=>{this.#i[e]?.cancel(),this.#l(e,0)}}),i){const i=t.tapped;t.tapped=()=>{this.#o(e),setTimeout((()=>this.#l(e)),1e3*r),\"function\"==typeof i&&i()}}return t}createLineLabel(e,t){return t[1]||(t[1]=\"#00CC00\"),\"object\"!=typeof t[1]&&(t[1]=[t[1],t[1]]),\"object\"!=typeof t[0]&&(t[0]=[t[0],t[0]]),{type:\"view\",views:[{type:\"view\",props:{bgcolor:$color(t[1][0],t[1][1]),cornerRadius:5,smoothCorners:!0},views:[{type:\"image\",props:{tintColor:$color(\"white\"),image:$image(t[0][0],t[0][1])},layout:(e,t)=>{e.center.equalTo(t.super),e.size.equalTo(20)}}],layout:(e,t)=>{e.centerY.equalTo(t.super),e.size.equalTo(this.iconSize),e.left.inset(this.edgeOffset)}},{type:\"label\",props:{text:e,lines:1,textColor:this.textColor,align:$align.left},layout:(e,t)=>{e.centerY.equalTo(t.super),e.height.equalTo(t.super),e.left.equalTo(t.prev.right).offset(this.edgeOffset),e.width.greaterThanOrEqualTo(10)}}],layout:(e,t)=>{e.height.centerY.equalTo(t.super),e.left.inset(0)}}}createInfo(e,t,i){const r=Array.isArray(i),s=r?i[0]:i,a=r?i[1]:i;return{type:\"view\",props:{selectable:!0},views:[this.createLineLabel(t,e),{type:\"label\",props:{text:s,align:$align.right,textColor:$color(\"darkGray\")},layout:(e,t)=>{e.centerY.equalTo(t.prev),e.right.inset(this.edgeOffset),e.width.equalTo(180)}},{type:\"view\",events:{tapped:()=>{$ui.alert({title:t,message:a,actions:[{title:$l10n(\"COPY\"),handler:()=>{$clipboard.text=a,$ui.toast($l10n(\"COPIED\"))}},{title:$l10n(\"OK\")}]})}},layout:(e,t)=>{e.right.inset(0),e.size.equalTo(t.super)}}],layout:$layout.fill}}createSwitch(e,t,i){return{type:\"view\",props:{id:this.getId(e),selectable:!0},views:[this.createLineLabel(i,t),{type:\"switch\",props:{on:this.get(e),onColor:$color(\"#00CC00\")},events:{changed:t=>{try{this.set(e,t.on)}catch(e){throw t.on=!t.on,e}}},layout:(e,t)=>{e.centerY.equalTo(t.prev),e.right.inset(this.edgeOffset)}}],layout:$layout.fill}}createString(e,t,i){return{type:\"view\",props:{id:this.getId(e),selectable:!0},views:[this.createLineLabel(i,t),{type:\"button\",props:{symbol:\"square.and.pencil\",bgcolor:$color(\"clear\"),tintColor:$color(\"primaryText\")},events:{tapped:t=>{const i=$ui.popover({sourceView:t,sourceRect:t.bounds,directions:$popoverDirection.down,size:$size(320,150),views:[{type:\"text\",props:{id:`${this.name}-string-${e}`,align:$align.left,text:this.get(e)},layout:e=>{e.left.right.inset(10),e.top.inset(20),e.height.equalTo(90)}},{type:\"button\",props:{symbol:\"checkmark\",bgcolor:$color(\"clear\"),titleEdgeInsets:10,contentEdgeInsets:0},layout:e=>{e.right.inset(10),e.bottom.inset(25),e.size.equalTo(30)},events:{tapped:()=>{this.set(e,$(`${this.name}-string-${e}`).text),i.dismiss()}}}]})}},layout:(e,t)=>{e.centerY.equalTo(t.prev),e.right.inset(0),e.size.equalTo(50)}}],layout:$layout.fill}}createStepper(e,t,i,r,s){const a=this.getId(e),n=`${a}-label`;return{type:\"view\",props:{id:a,selectable:!0},views:[this.createLineLabel(i,t),{type:\"label\",props:{id:n,text:this.get(e),textColor:this.textColor,align:$align.left},layout:(e,t)=>{e.height.equalTo(t.super),e.right.inset(120)}},{type:\"stepper\",props:{min:r,max:s,value:this.get(e)},events:{changed:t=>{$(n).text=t.value;try{this.set(e,t.value)}catch(t){throw $(n).text=this.get(e),t}}},layout:(e,t)=>{e.centerY.equalTo(t.prev),e.right.inset(this.edgeOffset)}}],layout:$layout.fill}}createScript(key,icon,title,script){const id=this.getId(key),buttonId=`${id}-button`,actionStart=()=>{$(buttonId).alpha=0,$(`${buttonId}-spinner`).alpha=1,this.#o(id)},actionCancel=()=>{$(buttonId).alpha=1,$(`${buttonId}-spinner`).alpha=0,this.#l(id)},actionDone=(e=!0,t=$l10n(\"ERROR\"))=>{$(`${buttonId}-spinner`).alpha=0,this.#l(id);const i=$(buttonId);if(!e)return $ui.toast(t),void(i.alpha=1);i.symbol=\"checkmark\",$ui.animate({duration:.6,animation:()=>{i.alpha=1},completion:()=>{setTimeout((()=>{$ui.animate({duration:.4,animation:()=>{i.alpha=0},completion:()=>{i.symbol=\"chevron.right\",$ui.animate({duration:.4,animation:()=>{i.alpha=1},completion:()=>{i.alpha=1}})}})}),600)}})};return{type:\"view\",props:{id:id},views:[this.createLineLabel(title,icon),{type:\"view\",views:[{type:\"image\",props:{id:buttonId,symbol:\"chevron.right\",tintColor:$color(\"secondaryText\")},layout:(e,t)=>{e.centerY.equalTo(t.super),e.right.inset(0),e.size.equalTo(15)}},{type:\"spinner\",props:{id:`${buttonId}-spinner`,loading:!0,alpha:0},layout:(e,t)=>{e.size.equalTo(t.prev),e.left.top.equalTo(t.prev)}}],layout:(e,t)=>{e.right.inset(this.edgeOffset),e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],events:this.#c(id,{tapped:()=>{const animate={actionStart:actionStart,actionCancel:actionCancel,actionDone:actionDone,touchHighlightStart:()=>this.#o(id),touchHighlightEnd:()=>this.#l(id)};\"function\"==typeof script?script(animate):script.startsWith(\"this\")?eval(`(()=>{return ${script}(animate)})()`):eval(script)}}),layout:$layout.fill}}createTab(key,icon,title,items,values){\"string\"==typeof items?items=eval(`(()=>{return ${items}()})()`):\"function\"==typeof items&&(items=items()),\"string\"==typeof values?values=eval(`(()=>{return ${values}()})()`):\"function\"==typeof values&&(values=values());const id=this.getId(key),isCustomizeValues=items?.length>0&&values?.length===items?.length;return{type:\"view\",props:{id:id,selectable:!0},views:[this.createLineLabel(title,icon),{type:\"tab\",props:{items:items??[],index:isCustomizeValues?values.indexOf(this.get(key)):this.get(key),dynamicWidth:!0},layout:(e,t)=>{e.right.inset(this.edgeOffset),e.centerY.equalTo(t.prev)},events:{changed:e=>{isCustomizeValues?this.set(key,values[e.index]):this.set(key,e.index)}}}],layout:$layout.fill}}createMenu(key,icon,title,items,values){const id=this.getId(key),labelId=`${id}-label`,getItems=()=>{let res;return res=\"string\"==typeof items?eval(`(()=>{return ${items}()})()`):\"function\"==typeof items?items():items??[],res},getValues=()=>{let res;return res=\"string\"==typeof values?eval(`(()=>{return ${values}()})()`):\"function\"==typeof values?values():values,res},tmpItems=getItems(),tmpValues=getValues(),isCustomizeValues=tmpItems?.length>0&&tmpValues?.length===tmpItems?.length;return{type:\"view\",props:{id:id,selectable:!0},views:[this.createLineLabel(title,icon),{type:\"view\",views:[{type:\"label\",props:{text:isCustomizeValues?tmpItems[tmpValues.indexOf(this.get(key))]:tmpItems[this.get(key)],color:$color(\"secondaryText\"),id:labelId},layout:(e,t)=>{e.right.inset(0),e.height.equalTo(t.super)}}],layout:(e,t)=>{e.right.inset(this.edgeOffset),e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],events:{tapped:()=>{const e=getItems(),t=getValues();$ui.menu({items:e,handler:(e,i)=>{isCustomizeValues?this.set(key,t[i]):this.set(key,i),$(labelId).text=$l10n(e)}})}},layout:$layout.fill}}createColor(e,t,i){const r=this.getId(e),s=`${r}-color`;return{type:\"view\",props:{id:r,selectable:!0},views:[this.createLineLabel(i,t),{type:\"view\",views:[{type:\"view\",props:{id:s,bgcolor:this.getColor(this.get(e)),circular:!0,borderWidth:1,borderColor:$color(\"#e3e3e3\")},layout:(e,t)=>{e.centerY.equalTo(t.super),e.right.inset(this.edgeOffset),e.size.equalTo(20)}},{type:\"view\",events:{tapped:async()=>{const t=await $picker.color({color:this.getColor(this.get(e))});this.set(e,t.components),$(s).bgcolor=$rgba(t.components.red,t.components.green,t.components.blue,t.components.alpha)}},layout:(e,t)=>{e.right.inset(0),e.height.width.equalTo(t.super.height)}}],layout:(e,t)=>{e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],layout:$layout.fill}}createDate(e,t,i,r=2){const s=this.getId(e),a=e=>{let t=\"\";switch(\"number\"==typeof e&&(e=new Date(e)),r){case 0:t=e.toLocaleTimeString();break;case 1:t=e.toLocaleDateString();break;case 2:t=e.toLocaleString()}return t};return{type:\"view\",props:{id:s,selectable:!0},views:[this.createLineLabel(i,t),{type:\"view\",views:[{type:\"label\",props:{id:`${s}-label`,color:$color(\"secondaryText\"),text:this.get(e)?a(this.get(e)):\"None\"},layout:(e,t)=>{e.right.inset(0),e.height.equalTo(t.super)}}],events:{tapped:async()=>{const t=this.get(e),i=await $picker.date({props:{mode:r,date:t||Date.now()}});this.set(e,i.getTime()),$(`${s}-label`).text=a(i)}},layout:(e,t)=>{e.right.inset(this.edgeOffset),e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],layout:$layout.fill}}createNumber(e,t,i){return this.createInput(e,t,i,!1,$kbType.decimal,(t=>\"\"!==t&&/^[0-9]+.?[0-9]*$/.test(t)?this.set(e,Number(t)):($ui.toast($l10n(\"INVALID_VALUE\")),!1)))}createInput(e,t,i,r=!1,s=$kbType.default,a){void 0===a&&(a=t=>this.set(e,t));const n=this.getId(e),o=n+\"-input\";return{type:\"view\",props:{id:n,selectable:!0},views:[this.createLineLabel(i,t),{type:\"input\",props:{id:o,type:s,align:$align.right,bgcolor:$color(\"clear\"),textColor:$color(\"secondaryText\"),text:this.get(e),font:$font(16),secure:r,accessoryView:$58e2f5443faff7c0$require$UIKit.blurBox({height:44},[$58e2f5443faff7c0$require$UIKit.separatorLine({},$58e2f5443faff7c0$require$UIKit.align.top),{type:\"button\",props:{title:$l10n(\"DONE\"),bgcolor:$color(\"clear\"),titleColor:$color(\"primaryText\")},layout:(e,t)=>{e.right.inset(this.edgeOffset),e.centerY.equalTo(t.super)},events:{tapped:()=>{$(o).blur()}}},{type:\"button\",props:{title:$l10n(\"CANCEL\"),bgcolor:$color(\"clear\"),titleColor:$color(\"primaryText\")},layout:(e,t)=>{e.left.inset(this.edgeOffset),e.centerY.equalTo(t.super)},events:{tapped:()=>{const t=$(o),i=this.get(e,\"\");t.text!==i&&(t.text=i),t.blur()}}}])},layout:(t,i)=>{t.left.equalTo(i.prev.get(\"label\").right).offset(this.edgeOffset),t.right.inset(this.edgeOffset);const r=$58e2f5443faff7c0$require$UIKit.getContentSize($font(16),this.get(e)).width;t.width.greaterThanOrEqualTo(r+30),t.height.equalTo(i.super)},events:{didBeginEditing:e=>{e.secure=!1,$app.autoKeyboardEnabled||($app.autoKeyboardEnabled=!0)},returned:e=>{e.blur()},didEndEditing:async t=>{const i=this.get(e,\"\");a(t.text)||(t.text=i),r&&(t.secure=r)}}}],layout:$layout.fill}}createIcon(e,t,i,r=\"#000000\"){const s=this.getId(e),a=`${s}-image`;return{type:\"view\",props:{id:s,selectable:!0},views:[this.createLineLabel(i,t),{type:\"view\",views:[{type:\"image\",props:{cornerRadius:8,bgcolor:\"string\"==typeof r?$color(r):r,smoothCorners:!0},layout:(e,t)=>{e.right.inset(this.edgeOffset),e.centerY.equalTo(t.super),e.size.equalTo($size(30,30))}},{type:\"image\",props:{id:a,image:$image(this.get(e)),icon:$icon(this.get(e).slice(5,this.get(e).indexOf(\".\")),$color(\"#ffffff\")),tintColor:$color(\"#ffffff\")},layout:(e,t)=>{e.right.equalTo(t.prev).offset(-5),e.centerY.equalTo(t.super),e.size.equalTo($size(20,20))}}],events:{tapped:()=>{$ui.menu({items:[$l10n(\"JSBOX_ICON\"),$l10n(\"SF_SYMBOLS\"),$l10n(\"IMAGE_BASE64\")],handler:async(t,i)=>{if(0===i){const t=await $ui.selectIcon();this.set(e,t),$(a).icon=$icon(t.slice(5,t.indexOf(\".\")),$color(\"#ffffff\"))}else 1!==i&&2!==i||$input.text({text:\"\",placeholder:t,handler:t=>{\"\"!==t?(this.set(e,t),1===i?$(a).symbol=t:$(a).image=$image(t)):$ui.toast($l10n(\"INVALID_VALUE\"))}})}})}},layout:(e,t)=>{e.right.inset(0),e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],layout:$layout.fill}}createPush(key,icon,title,view,tapped){const id=this.getId(key);return{type:\"view\",layout:$layout.fill,props:{id:id,selectable:!0},views:[this.createLineLabel(title,icon),{type:\"image\",props:{symbol:\"chevron.right\",tintColor:$color(\"secondaryText\")},layout:(e,t)=>{e.centerY.equalTo(t.super),e.right.inset(this.edgeOffset),e.size.equalTo(15)}}],events:{tapped:()=>{const push=view=>{if(\"string\"==typeof view&&view.startsWith(\"this.method\")?view=eval(`(()=>{return ${view}()})()`):\"function\"==typeof view&&(view=view()),this.isUseJsboxNav)$58e2f5443faff7c0$require$UIKit.push({title:title,props:view.props??{},views:[view]});else{const e=new $58e2f5443faff7c0$require$NavigationView;e.setView(view).navigationBarTitle(title),e.navigationBarItems.addPopButton(),e.navigationBar.setLargeTitleDisplayMode($58e2f5443faff7c0$require$NavigationBar.largeTitleDisplayModeNever),this.hasSectionTitle(view)&&e.navigationBar.setContentViewHeightOffset(-10),this.viewController.push(e)}};\"function\"==typeof tapped?tapped(push):push(view)}}}}createChild(e,t,i,r){return this.createPush(e,t,i,void 0,(e=>{this.events?.onChildPush?this.callEvent(\"onChildPush\",this.getListView(r,{}),i):e(this.getListView(r,{}))}))}createImage(e,t,i){const r=this.getId(e),s=`${r}-image`,a=$image(\"questionmark.square.dashed\");return{type:\"view\",props:{id:r,selectable:!0},views:[this.createLineLabel(i,t),{type:\"view\",views:[{type:\"image\",props:{id:s,image:this.getImage(e,!0)??a},layout:(e,t)=>{e.right.inset(this.edgeOffset),e.centerY.equalTo(t.super),e.size.equalTo($size(30,30))}}],events:{tapped:()=>{this.#o(r),$ui.menu({items:[$l10n(\"PREVIEW\"),$l10n(\"SELECT_IMAGE\"),$l10n(\"CLEAR_IMAGE\")],handler:(t,i)=>{if(0===i){const t=this.getImage(e);t?$quicklook.open({image:t}):$ui.toast($l10n(\"NO_IMAGE\"))}else 1===i?$photo.pick({format:\"data\"}).then((t=>{if($ui.toast($l10n(\"LOADING\")),!t.status||!t.data)return void(\"canceled\"!==t?.error?.description&&$ui.toast($l10n(\"ERROR\")));const i=$58e2f5443faff7c0$require$Kernel.compressImage(t.data.image);this.fileStorage.write(this.getImagePath(e,!0),i.jpg(.8)),this.fileStorage.write(this.getImagePath(e),t.data),$(s).image=i,$ui.success($l10n(\"SUCCESS\"))})):2===i&&(this.fileStorage.delete(this.getImagePath(e,!0)),this.fileStorage.delete(this.getImagePath(e)),$(s).image=a,$ui.success($l10n(\"SUCCESS\")))},finished:()=>{this.#l(r)}})}},layout:(e,t)=>{e.right.inset(0),e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],layout:$layout.fill}}#h(e){const t=[];for(let i of e){const e=[];for(let t of i.items){const i=this.get(t.key);let r=null;switch(t.icon||(t.icon=[\"square.grid.2x2.fill\",\"#00CC00\"]),\"object\"==typeof t.items&&(t.items=t.items.map((e=>$l10n(e)))),t.title=$l10n(t.title),t.type){case\"switch\":r=this.createSwitch(t.key,t.icon,t.title);break;case\"stepper\":r=this.createStepper(t.key,t.icon,t.title,t.min??1,t.max??12);break;case\"string\":r=this.createString(t.key,t.icon,t.title);break;case\"info\":r=this.createInfo(t.icon,t.title,i);break;case\"script\":r=this.createScript(t.key,t.icon,t.title,i);break;case\"tab\":r=this.createTab(t.key,t.icon,t.title,t.items,t.values);break;case\"menu\":r=this.createMenu(t.key,t.icon,t.title,t.items,t.values);break;case\"color\":r=this.createColor(t.key,t.icon,t.title);break;case\"date\":r=this.createDate(t.key,t.icon,t.title,t.mode);break;case\"number\":r=this.createNumber(t.key,t.icon,t.title);break;case\"input\":r=this.createInput(t.key,t.icon,t.title,t.secure);break;case\"icon\":r=this.createIcon(t.key,t.icon,t.title,t.bgcolor);break;case\"push\":r=this.createPush(t.key,t.icon,t.title,t.view);break;case\"child\":r=this.createChild(t.key,t.icon,t.title,t.children);break;case\"image\":r=this.createImage(t.key,t.icon,t.title);break;default:continue}e.push(r)}t.push({title:$l10n(i.title??\"\"),rows:e})}return t}getListView(e,t=this.footer){return{type:\"list\",props:{id:this.name,style:2,separatorInset:$insets(0,this.iconSize+2*this.edgeOffset,0,this.edgeOffset),bgcolor:$58e2f5443faff7c0$require$UIKit.scrollViewBackgroundColor,footer:t,data:this.#h(e??this.structure)},layout:$layout.fill,events:{rowHeight:(e,t)=>(e.object(t)?.props?.info??{}).rowHeight??this.rowHeight}}}getNavigationView(){const e=new $58e2f5443faff7c0$require$NavigationView;return e.setView(this.getListView(this.structure)).navigationBarTitle($l10n(\"SETTING\")),this.hasSectionTitle(this.structure)&&e.navigationBar.setContentViewHeightOffset(-10),e}getPage(){return this.getNavigationView().getPage()}}module.exports={Setting:Setting}})),parcelRequire.register(\"fYz8N\",(function(e,t){e.exports={Controller:class{events={};setEvents(e){return Object.keys(e).forEach((t=>this.setEvent(t,e[t]))),this}setEvent(e,t){return this.events[e]=t,this}callEvent(e,...t){\"function\"==typeof this.events[e]&&this.events[e](...t)}}}})),parcelRequire.register(\"8aDdQ\",(function(e,t){class i extends Error{constructor(e){super(`Parameter [${e}] is required.`),this.name=\"FileStorageParameterError\"}}class r extends Error{constructor(e){super(`File not found: ${e}`),this.name=\"FileStorageFileNotFoundError\"}}class s{basePath;constructor({basePath:e=\"storage\"}={}){this.basePath=e,this.#d(this.basePath)}#d(e){$file.isDirectory(e)||$file.mkdir(e)}filePath(e=\"\",t=!0){e.startsWith(\"/\")&&(e=e.substring(1));let i=\"\";if(!(e=`${this.basePath}/${e}`).endsWith(\"/\")){const t=e.lastIndexOf(\"/\");e.lastIndexOf(\".\")>t&&(i=e.substring(t+1),e=e.substring(0,t+1))}return t&&this.#d(e),e+i}exists(e=\"\"){return e=this.filePath(e,!1),!!$file.exists(e)}write(e=\"\",t){return new Promise(((i,r)=>{try{const s=this.writeSync(e,t);s?i(s):r(s)}catch(e){r(e)}}))}writeSync(e=\"\",t){if(!t)throw new i(\"data\");return $file.write({data:t,path:this.filePath(e)})}read(e=\"\"){return new Promise(((t,i)=>{try{const r=this.readSync(e);r?t(r):i()}catch(e){i(e)}}))}readSync(e=\"\"){if(e=this.filePath(e),!$file.exists(e))throw new r(e);return $file.isDirectory(e)?$file.list(e):$file.read(e)}readAsJSON(e=\"\",t=null){try{const t=this.readSync(e)?.string;return JSON.parse(t)}catch(e){return t}}static readFromRoot(e=\"\"){return new Promise(((t,i)=>{try{const r=s.readFromRootSync(e);r?t(r):i()}catch(e){i(e)}}))}static readFromRootSync(e=\"\"){if(!e)throw new i(\"path\");if(!$file.exists(e))throw new r(e);return $file.isDirectory(e)?$file.list(e):$file.read(e)}static readFromRootAsJSON(e=\"\",t=null){try{const t=s.readFromRootSync(e)?.string;return JSON.parse(t)}catch(e){return t}}delete(e=\"\"){return $file.delete(this.filePath(e,!1))}copy(e,t){e=this.filePath(e),t=this.filePath(t),$file.copy({src:e,dst:t})}move(e,t){e=this.filePath(e),t=this.filePath(t),$file.move({src:e,dst:t})}}e.exports={FileStorageParameterError:i,FileStorageFileNotFoundError:r,FileStorage:s}})),parcelRequire.register(\"cgaQ6\",(function(e,t){var i=parcelRequire(\"czAIJ\").VERSION;class r{startTime=Date.now();isUseJsboxNav=!1;title=$addin?.current?.name;constructor(){$app.isDebugging&&this.debug()}static isTaio=$app.info.bundleID.includes(\"taio\");static l10n(e,t,i=!0){if(\"string\"==typeof t){const e={};t.split(\";\").forEach((t=>{if(\"\"!==(t=t.trim())){const i=t.split(\"=\");e[i[0].trim().slice(1,-1)]=i[1].trim().slice(1,-1)}})),t=e}const r=$app.strings;r[e]=i?Object.assign($app.strings[e],t):Object.assign(t,$app.strings[e]),$app.strings=r}static compressImage(e,t=921600){const i=$imagekit.info(e);if(i.height*i.width>t){const r=t/(i.height*i.width);e=$imagekit.scaleBy(e,r)}return e}static objectEqual(e,t){let i=Object.getOwnPropertyNames(e),s=Object.getOwnPropertyNames(t);if(i.length!==s.length)return!1;for(let s=0;se?i[e]:0,s=isNaN(Number(t))?t.charCodeAt():Number(t),n=r.length>e?r[e]:0,o=isNaN(Number(n))?n.charCodeAt():Number(n);if(so){a=1;break}}return a}static deleteConfirm(e,t){$ui.alert({title:$l10n(\"DELETE_CONFIRM_TITLE\"),message:e,actions:[{title:$l10n(\"DELETE\"),style:$alertActionType.destructive,handler:()=>{t()}},{title:$l10n(\"CANCEL\")}]})}static bytesToSize(e){if(0===e)return\"0 B\";const t=Math.floor(Math.log(e)/Math.log(1024));return(e/Math.pow(1024,t)).toPrecision(3)+\" \"+[\"B\",\"KB\",\"MB\",\"GB\",\"TB\",\"PB\",\"EB\",\"ZB\",\"YB\"][t]}debug(e,t){this.debugMode=!0,$app.idleTimerDisabled=!0,\"function\"==typeof e&&(this.debugPrint=e),\"function\"==typeof t&&(this.debugError=t),this.print(\"You are running EasyJsBox in debug mode.\")}print(e){this.debugMode&&(\"function\"==typeof this.debugPrint?this.debugPrint(e):console.log(e))}error(e){this.debugMode&&(\"function\"==typeof this.debugError?this.debugError(e):console.error(e))}useJsboxNav(){return this.isUseJsboxNav=!0,this}setTitle(e){this.isUseJsboxNav&&($ui.title=e),this.title=e}setNavButtons(e){this.navButtons=e}openInJsbox(){$app.openURL(`jsbox://run?name=${this.title}`)}UIRender(e){try{e.props=Object.assign({title:this.title,navBarHidden:!this.isUseJsboxNav,navButtons:this.navButtons??[],statusBarStyle:0},e.props),e.events||(e.events={});const t=e.events.layoutSubviews,{UIKit:i}=parcelRequire(\"45Ip7\");e.events.layoutSubviews=()=>{$app.notify({name:\"interfaceOrientationEvent\",object:{statusBarOrientation:i.statusBarOrientation,isHorizontal:i.isHorizontal}}),\"function\"==typeof t&&t()},$ui.render(e)}catch(e){this.print(e)}}async checkUpdate(){const e=await $http.get(\"https://raw.githubusercontent.com/ipuppet/EasyJsBox/dev/src/version.js\");if(e.error)throw e.error;const t=srcRes.data.match(/.*VERSION.?\\\"([0-9\\.]+)\\\"/)[1];if(this.print(`easy-jsbox latest version: ${t}`),r.versionCompare(t,i)>0){const e=await $http.get(\"https://raw.githubusercontent.com/ipuppet/EasyJsBox/dev/dist/easy-jsbox.js\");if(e.error)throw e.error;return e.data}return!1}}r.l10n(\"zh-Hans\",{DELETE_CONFIRM_TITLE:\"删除前确认\"},!1),r.l10n(\"en\",{DELETE_CONFIRM_TITLE:\"Delete Confirmation\"},!1),e.exports={Kernel:r}})),parcelRequire.register(\"czAIJ\",(function(e,t){e.exports={VERSION:\"1.3.3\"}})),parcelRequire.register(\"aXWmO\",(function(e,t){var i=parcelRequire(\"6Xrbz\").ValidationError,r=parcelRequire(\"liCrE\").View,s=parcelRequire(\"45Ip7\").UIKit,a=parcelRequire(\"12xzj\").NavigationView,n=parcelRequire(\"dcStC\").NavigationBar,o=parcelRequire(\"gAYmG\").BarButtonItem;class l extends Error{constructor(){super(\"Please call setView(view) first.\"),this.name=\"SheetAddNavBarError\"}}class c extends i{constructor(e,t){super(e,t),this.name=\"SheetViewTypeError\"}}class h extends r{#p=()=>{};#u=()=>{};style=h.UIModalPresentationStyle.PageSheet;#g=!1;static UIModalPresentationStyle={Automatic:-2,FullScreen:0,PageSheet:1,FormSheet:2,CurrentContext:3,Custom:4,OverFullScreen:5,OverCurrentContext:6,Popover:7,BlurOverFullScreen:8};navigationView;init(){const{width:e,height:t}=$device.info.screen,i=$objc(\"UIView\").invoke(\"initWithFrame\",$rect(0,0,e,t)),r=$objc(\"UIViewController\").invoke(\"alloc.init\"),a=r.$view();return a.$setBackgroundColor(s.primaryViewBackgroundColor),a.$addSubview(i),r.$setModalPresentationStyle(this.style),r.$setModalInPresentation(this.#g),this.#p=()=>{a.jsValue().add(this.navigationView?.getPage().definition??this.view),$ui.vc.ocValue().invoke(\"presentViewController:animated:completion:\",r,!0,void 0)},this.#u=()=>r.invoke(\"dismissViewControllerAnimated:completion:\",!0,void 0),this}preventDismiss(){return this.#g=!0,this}setStyle(e){return this.style=e,this}setView(e={}){if(\"object\"!=typeof e)throw new c(\"view\",\"object\");return this.view=e,this}addNavBar({title:e=\"\",popButton:t={title:$l10n(\"DONE\")},rightButtons:i=[]}={}){if(void 0===this.view)throw new l;this.navigationView=new a;const r=new o;r.setEvents(Object.assign({tapped:()=>{this.dismiss(),\"function\"==typeof t.tapped&&t.tapped()}},t.events)).setAlign(s.align.left).setSymbol(t.symbol).setTitle(t.title).setColor(t.color).setMenu(t.menu);const c=r.definition.views[0];return c.layout=(e,t)=>{e.left.equalTo(t.super.safeArea).offset(15),e.centerY.equalTo(t.super.safeArea)},this.navigationView.navigationBar.setLargeTitleDisplayMode(n.largeTitleDisplayModeNever).pageSheetMode(),this.navigationView.navigationBarItems.addPopButton(\"\",c).setRightButtons(i),this.navigationView.setView(this.view).navigationBarTitle(e),this.view.props?.bgcolor&&this.navigationView?.getPage().setProp(\"bgcolor\",this.view.props?.bgcolor),this}present(){this.#p()}dismiss(){this.#u()}}e.exports={Sheet:h}})),parcelRequire.register(\"6Xrbz\",(function(e,t){class i extends Error{constructor(e,t){super(`The type of the parameter '${e}' must be '${t}'`),this.name=\"ValidationError\"}}e.exports={ValidationError:i}})),parcelRequire.register(\"liCrE\",(function(e,t){var i=parcelRequire(\"45Ip7\").UIKit;class r{id=$text.uuid;type;props;views;events;layout;#$=void 0;#f=null;constructor({type:e=\"view\",props:t={},views:i=[],events:r={},layout:s=$layout.fill}={}){this.type=e,this.props=t,this.views=i,this.events=r,this.layout=s,this.props.id?this.id=this.props.id:this.props.id=this.id}static create(e){return new this(e)}static createFromViews(e){return new this({views:e})}get scrollableView(){return this.scrollable?this.#f:null}set scrollableView(e){this.#f=e}get scrollable(){if(void 0===this.#$)if(this.#$=!1,i.scrollViewList.indexOf(this.type)>-1)this.scrollableView=this,this.#$=!0;else if(this.views.length>0){const e=t=>{if(!this.#$&&t?.length>0)for(let s=0;s-1)return typeof t[s]!==r&&(t[s]=r.create(t[s])),this.scrollableView=t[s],void(this.#$=!0);e(t[s].views)}};e(this.views)}return this.#$}set scrollable(e){throw new Error(\"[scrollable] is readonly prop.\")}setProps(e){return Object.keys(e).forEach((t=>this.setProp(t,e[t]))),this}setProp(e,t){return\"id\"===e&&(this.id=t),this.props[e]=t,this}setViews(e){return this.views=e,this.#$=void 0,this}setEvents(e){return Object.keys(e).forEach((t=>this.setEvent(t,e[t]))),this}setEvent(e,t){return this.events[e]=t,this}eventMiddleware(e,t){const i=this.events[e];return this.events[e]=(...e)=>{\"function\"==typeof i&&t(i,...e)},this}assignEvent(e,t){const i=this.events[e];return this.events[e]=(...e)=>{\"function\"==typeof i&&i(...e),t(...e)},this}setLayout(e){return this.layout=e,this}getView(){return this}get definition(){return this.getView()}}e.exports={View:r,PageView:class extends r{constructor(e={}){super(e),this.activeStatus=!0}show(){$(this.props.id).hidden=!1,this.activeStatus=!0}hide(){$(this.props.id).hidden=!0,this.activeStatus=!1}setHorizontalSafeArea(e){return this.horizontalSafeArea=e,this}#y(e,t){e.top.bottom.equalTo(t.super),this.horizontalSafeArea?e.left.right.equalTo(t.super.safeArea):e.left.right.equalTo(t.super)}getView(){return this.layout=this.#y,this.props.clipsToBounds=!0,this.props.hidden=!this.activeStatus,super.getView()}}}})),parcelRequire.register(\"12xzj\",(function(e,t){var i=parcelRequire(\"fYz8N\").Controller,r=parcelRequire(\"liCrE\"),s=r.View,a=r.PageView,n=parcelRequire(\"6Xrbz\").ValidationError,o=parcelRequire(\"cgaQ6\").Kernel,l=parcelRequire(\"45Ip7\").UIKit,c=parcelRequire(\"dcStC\"),h=c.NavigationBar,d=c.NavigationBarController,p=parcelRequire(\"gAYmG\").NavigationBarItems;class u extends n{constructor(e,t){super(e,t),this.name=\"NavigationViewTypeError\"}}e.exports={NavigationView:class extends i{page;navigationController=new d;navigationBar=new h;navigationBarItems=new p;constructor(){super(),this.navigationBar.navigationBarItems=this.navigationBarItems,this.navigationController.navigationBar=this.navigationBar}navigationBarTitle(e){return this.navigationBar.setTitle(e),this}setView(e){if(\"object\"!=typeof e)throw new u(\"view\",\"object\");return this.view=s.create(e),this}#b(){if(!(this.view instanceof s))throw new u(\"view\",\"View\");const e=this.view.scrollableView,t=$app.isDebugging||o.isTaio?0:l.topSafeAreaInsets,i=this.navigationBar.largeTitleDisplayMode===h.largeTitleDisplayModeNever?this.navigationBar.navigationBarNormalHeight:this.navigationBar.navigationBarLargeTitleHeight;let r=this.navigationBar.contentViewHeightOffset+i;if(this.navigationBarItems.titleView&&(r+=this.navigationBarItems.titleView.topOffset,r+=this.navigationBarItems.titleView.height,r+=this.navigationBarItems.titleView.bottomOffset),!this.view.scrollable||!1===e.props.associateWithNavigationBar)return void(this.view.layout=(e,i)=>{e.left.right.equalTo(i.super.safeArea),e.bottom.equalTo(i.super);let s=r-this.navigationBar.contentViewHeightOffset;l.isHorizontal&&!l.isLargeScreen||!this.navigationBar.topSafeArea||(s+=t),e.top.equalTo(s)});e.props.stickyHeader&&(r-=i,r+=this.navigationBar.largeTitleFontHeight),e.props.header?e.props.header={type:\"view\",props:{height:r+(e.props.header?.props?.height??0)},views:[{type:\"view\",props:{clipsToBounds:!0},views:[e.props.header],layout:(e,t)=>{e.top.equalTo(r),e.bottom.width.equalTo(t.super)}}]}:e.props.header={props:{height:r}},e.props.footer=Object.assign({props:{}},e.props.footer??{}),e.props.footer.props.height=(this.navigationBarItems.fixedFooterView?.height??0)+(e.props.footer.props?.height??0);const a=this.navigationBarItems.isPinTitleView?this.navigationBarItems.titleView.height+this.navigationBarItems.titleView.bottomOffset+this.navigationBar.contentViewHeightOffset:0;if(e.props.indicatorInsets){const t=e.props.indicatorInsets;e.props.indicatorInsets=$insets(t.top+this.navigationBar.navigationBarNormalHeight+a,t.left,t.bottom+(this.navigationBarItems.fixedFooterView?.height??0),t.right)}else e.props.indicatorInsets=$insets(this.navigationBar.navigationBarNormalHeight+a,0,this.navigationBarItems.fixedFooterView?.height??0,0);e.layout=(t,i)=>{e.props.stickyHeader?t.top.equalTo(i.super.safeArea).offset(this.navigationBar.navigationBarNormalHeight):t.top.equalTo(i.super),t.left.right.equalTo(i.super.safeArea),t.bottom.equalTo(i.super)},e.assignEvent(\"didScroll\",(i=>{let r=i.contentOffset.y;l.isHorizontal&&!l.isLargeScreen||!this.navigationBar.topSafeArea||e.props.stickyHeader||(r+=t),this.navigationController.didScroll(r)})).assignEvent(\"didEndDragging\",((i,r)=>{let s=i.contentOffset.y,a=0;l.isHorizontal&&!l.isLargeScreen||!this.navigationBar.topSafeArea||e.props.stickyHeader||(s+=t,a=t),this.navigationController.didEndDragging(s,r,((...e)=>i.scrollToOffset(...e)),a)})).assignEvent(\"didEndDecelerating\",((...t)=>{t[0].tracking||e.events?.didEndDragging(...t)}))}#m(){if(this.navigationBar.prefersLargeTitles){this.#b();let e={};if(this.navigationBarItems.titleView){const t=this.navigationBar.largeTitleDisplayMode===h.largeTitleDisplayModeNever?1:0;e=s.create({views:[this.navigationBar.backgroundColor?{type:\"view\",props:{alpha:t,bgcolor:this.navigationBar.backgroundColor,id:this.navigationBar.id+\"-title-view-background\"},layout:$layout.fill}:l.blurBox({alpha:t,id:this.navigationBar.id+\"-title-view-background\"}),l.separatorLine({id:this.navigationBar.id+\"-title-view-underline\",alpha:t}),this.navigationBarItems.titleView.definition],layout:(e,t)=>{e.top.equalTo(t.prev.bottom),e.width.equalTo(t.super),e.height.equalTo(this.navigationBarItems.titleView.topOffset+this.navigationBarItems.titleView.height+this.navigationBarItems.titleView.bottomOffset)}})}this.page=a.createFromViews([this.view,this.navigationBar.getLargeTitleView(),e,this.navigationBar.getNavigationBarView(),this.navigationBarItems.fixedFooterView?.definition??{}])}else this.page=a.createFromViews([this.view]);this.view.props?.bgcolor?this.page.setProp(\"bgcolor\",this.view.props.bgcolor):this.page.setProp(\"bgcolor\",l.defaultBackgroundColor(this.view.type))}getPage(){return this.page||this.#m(),this.page}}}})),parcelRequire.register(\"dcStC\",(function(e,t){var i=parcelRequire(\"liCrE\").View,r=parcelRequire(\"fYz8N\").Controller,s=parcelRequire(\"45Ip7\").UIKit;parcelRequire(\"gAYmG\").BarButtonItem;class a extends i{static largeTitleDisplayModeAutomatic=0;static largeTitleDisplayModeAlways=1;static largeTitleDisplayModeNever=2;static pageSheetNavigationBarHeight=56;navigationBarItems;title=\"\";prefersLargeTitles=!0;largeTitleDisplayMode=a.largeTitleDisplayModeAutomatic;largeTitleFontSize=34;largeTitleFontFamily=\"bold\";largeTitleFontHeight=$text.sizeThatFits({text:\"A\",width:100,font:$font(this.largeTitleFontFamily,this.largeTitleFontSize)}).height;navigationBarTitleFontSize=17;topSafeArea=!0;contentViewHeightOffset=10;navigationBarNormalHeight=s.NavigationBarNormalHeight;navigationBarLargeTitleHeight=s.NavigationBarLargeTitleHeight;pageSheetMode(){return this.navigationBarLargeTitleHeight-=this.navigationBarNormalHeight,this.navigationBarNormalHeight=a.pageSheetNavigationBarHeight,this.navigationBarLargeTitleHeight+=this.navigationBarNormalHeight,this.topSafeArea=!1,this}setTopSafeArea(){return this.topSafeArea=!0,this}removeTopSafeArea(){return this.topSafeArea=!1,this}setLargeTitleDisplayMode(e){return this.largeTitleDisplayMode=e,this}setBackgroundColor(e){return this.backgroundColor=e,this}setTitle(e){return this.title=e,this}setPrefersLargeTitles(e){return this.prefersLargeTitles=e,this}setContentViewHeightOffset(e){return this.contentViewHeightOffset=e,this}getLargeTitleView(){return this.prefersLargeTitles&&this.largeTitleDisplayMode!==a.largeTitleDisplayModeNever?{type:\"label\",props:{id:this.id+\"-large-title\",text:this.title,textColor:s.textColor,align:$align.left,font:$font(this.largeTitleFontFamily,this.largeTitleFontSize),line:1},layout:(e,t)=>{e.left.equalTo(t.super.safeArea).offset(15),e.height.equalTo(this.largeTitleFontHeight),e.top.equalTo(t.super.safeAreaTop).offset(this.navigationBarNormalHeight)}}:{props:{id:this.id+\"-large-title\"},layout:(e,t)=>{e.left.top.right.inset(0),e.bottom.equalTo(t.super.safeAreaTop).offset(this.navigationBarNormalHeight)}}}getNavigationBarView(){const e=(e,t)=>{let i=0;const r=[];return e.forEach((e=>{i+=e.width,r.push(e.definition)})),i+=e[0]?.edges??0,e.length>0?{type:\"view\",views:r,layout:(e,r)=>{e.top.equalTo(r.super.safeAreaTop),e.bottom.equalTo(r.super.safeAreaTop).offset(this.navigationBarNormalHeight),t===s.align.left?e.left.equalTo(r.super.safeArea):e.right.equalTo(r.super.safeArea),e.width.equalTo(i)}}:{}},t=e(this.navigationBarItems.rightButtons,s.align.right),i=this.navigationBarItems.popButtonView??e(this.navigationBarItems.leftButtons,s.align.left),r=this.prefersLargeTitles,n=!this.prefersLargeTitles||this.largeTitleDisplayMode===a.largeTitleDisplayModeNever;return{type:\"view\",props:{id:this.id+\"-navigation\",bgcolor:$color(\"clear\")},layout:(e,t)=>{e.left.top.right.inset(0),e.bottom.equalTo(t.super.safeAreaTop).offset(this.navigationBarNormalHeight)},views:[this.backgroundColor?{type:\"view\",props:{hidden:r,bgcolor:this.backgroundColor,id:this.id+\"-background\"},layout:$layout.fill}:s.blurBox({hidden:r,id:this.id+\"-background\"}),s.separatorLine({id:this.id+\"-underline\",alpha:r?0:1}),{type:\"view\",props:{alpha:0,bgcolor:$color(\"clear\"),id:this.id+\"-large-title-mask\"},events:{ready:e=>{e.bgcolor=$(this.id+\"-large-title\")?.prev.bgcolor}},layout:$layout.fill},{type:\"label\",props:{id:this.id+\"-small-title\",alpha:n?1:0,text:this.title,font:$font(this.largeTitleFontFamily,this.navigationBarTitleFontSize),align:$align.center,bgcolor:$color(\"clear\"),textColor:s.textColor},layout:(e,t)=>{e.left.right.inset(0),e.height.equalTo(20),e.centerY.equalTo(t.super.safeArea)}}].concat(t,i)}}}class n extends r{static largeTitleViewSmallMode=0;static largeTitleViewLargeMode=1;navigationBar;updateSelector(){this.selector={navigation:$(this.navigationBar.id+\"-navigation\"),largeTitleView:$(this.navigationBar.id+\"-large-title\"),smallTitleView:$(this.navigationBar.id+\"-small-title\"),underlineView:this.navigationBar.navigationBarItems.isPinTitleView?$(this.navigationBar.id+\"-title-view-underline\"):$(this.navigationBar.id+\"-underline\"),largeTitleMaskView:$(this.navigationBar.id+\"-large-title-mask\"),backgroundView:$(this.navigationBar.id+\"-background\"),titleViewBackgroundView:$(this.navigationBar.id+\"-title-view-background\")}}toNormal(e=!0){this.updateSelector(),this.selector.backgroundView.hidden=!1,$ui.animate({duration:.2,animation:()=>{this.selector.underlineView.alpha=1,this.selector.smallTitleView.alpha=1,this.selector.largeTitleView.alpha=0}}),e&&this.navigationBar.navigationBarItems&&(this.navigationBar.largeTitleDisplayMode=a.largeTitleDisplayModeNever)}toLargeTitle(e=!0){this.updateSelector(),this.selector.backgroundView.hidden=!0,$ui.animate({duration:.2,animation:()=>{this.selector.underlineView.alpha=0,this.selector.smallTitleView.alpha=0,this.selector.largeTitleView.alpha=1}}),e&&this.navigationBar.navigationBarItems&&(this.navigationBar.largeTitleDisplayMode=a.largeTitleDisplayModeAlways)}#v(e){const t=e===n.largeTitleViewSmallMode;this.selector.largeTitleView.alpha=t?0:1,$ui.animate({duration:.2,animation:()=>{this.selector.smallTitleView.alpha=t?1:0}})}#w(e){if(this.selector.largeTitleView.updateLayout(((t,i)=>{this.navigationBar.navigationBarNormalHeight-e>0?t.top.equalTo(i.super.safeAreaTop).offset(this.navigationBar.navigationBarNormalHeight-e):t.top.equalTo(i.super.safeAreaTop).offset(0)})),e>0)e>=this.navigationBar.navigationBarNormalHeight?this.#v(n.largeTitleViewSmallMode):this.#v(n.largeTitleViewLargeMode);else{this.#v(n.largeTitleViewLargeMode);let t=this.navigationBar.largeTitleFontSize-.04*e;t>40&&(t=40),this.selector.largeTitleView.font=$font(this.navigationBar.largeTitleFontFamily,t)}}#T(e){const t=this.navigationBar.largeTitleDisplayMode===a.largeTitleDisplayModeNever?5:this.navigationBar.navigationBarNormalHeight,i=void 0!==this.selector.titleViewBackgroundView;if(e>t){this.selector.backgroundView.hidden=!1;const r=()=>{i&&this.navigationBar.navigationBarItems.isPinTitleView&&(this.selector.titleViewBackgroundView.alpha=1),this.selector.largeTitleMaskView.alpha=0,this.selector.underlineView.alpha=1};(e-t)/3>=1?r():$ui.animate({duration:.2,animation:()=>{r()}})}else this.selector.largeTitleMaskView.alpha=e>0?1:0,this.selector.underlineView.alpha=0,i&&(this.selector.titleViewBackgroundView.alpha=0),this.selector.backgroundView.hidden=!0}didScroll(e){if(!this.navigationBar.prefersLargeTitles)return;const t=this.navigationBar.largeTitleDisplayMode;t!==a.largeTitleDisplayModeAlways&&(this.updateSelector(),t===a.largeTitleDisplayModeAutomatic?(!this.navigationBar.navigationBarItems?.isPinTitleView&&(this.navigationBar.navigationBarItems?.titleView?.controller.didScroll(e),e>0)&&(e-=this.navigationBar.navigationBarItems?.titleView?.height??0)<0&&(e=0),this.#w(e),this.#T(e)):t===a.largeTitleDisplayModeNever&&this.#T(e))}didEndDragging(e,t,i,r){if(!this.navigationBar.prefersLargeTitles)return;const s=this.navigationBar.largeTitleDisplayMode;if(s!==a.largeTitleDisplayModeAlways&&(this.updateSelector(),s===a.largeTitleDisplayModeAutomatic)){let s=0;this.navigationBar.navigationBarItems?.isPinTitleView||(this.navigationBar.navigationBarItems?.titleView?.controller.didEndDragging(e,t,i,r),s=this.navigationBar.navigationBarItems?.titleView?.height??0,e-=s),e>=0&&e<=this.navigationBar.largeTitleFontHeight&&i($point(0,e>=this.navigationBar.largeTitleFontHeight/2?this.navigationBar.navigationBarNormalHeight+s-r:s-r))}}}e.exports={NavigationBar:a,NavigationBarController:n}})),parcelRequire.register(\"gAYmG\",(function(e,t){var i=parcelRequire(\"liCrE\").View,r=parcelRequire(\"45Ip7\").UIKit;class s extends i{static#E;edges=15;iconSize=$size(23,23);fontSize=16;color=r.textColor;title;symbol;align=r.align.right;get width(){if(this.title){const e=$text.sizeThatFits({text:this.title,width:r.windowSize.width,font:$font(this.fontSize)});return Math.ceil(e.width)+this.edges}return this.iconSize.width+this.edges}static get style(){return void 0===this.#E&&(this.#E=new s),this.#E}setEdges(e){return this.edges=e,this}setFontSize(e){return this.fontSize=e,this}setColor(e=r.textColor){return this.color=e,this}setTitle(e){return this.title=e,this}setSymbol(e){return this.symbol=e,this}setMenu(e){return this.menu=e,this}setAlign(e){return this.align=e,this}setLoading(e){e?($(this.id).hidden=!0,$(\"spinner-\"+this.id).hidden=!1):($(this.id).hidden=!1,$(\"spinner-\"+this.id).hidden=!0)}#A(){const e=$(`icon-button-${this.id}`),t=$(`icon-checkmark-${this.id}`);e.alpha=0,$(this.id).hidden=!1,$(\"spinner-\"+this.id).hidden=!0,$ui.animate({duration:.6,animation:()=>{t.alpha=1},completion:()=>{$delay(.3,(()=>$ui.animate({duration:.6,animation:()=>{t.alpha=0},completion:()=>{$ui.animate({duration:.4,animation:()=>{e.alpha=1},completion:()=>{e.alpha=1}})}})))}})}getView(){const e=this.events.tapped;return this.events.tapped=t=>{e&&e({start:()=>this.setLoading(!0),done:()=>this.#A(),cancel:()=>this.setLoading(!1)},t)},{type:\"view\",props:{info:{align:this.align}},views:[{type:\"button\",props:Object.assign({id:this.id,bgcolor:$color(\"clear\"),font:$font(this.fontSize),titleColor:this.color,contentEdgeInsets:$insets(0,0,0,0),titleEdgeInsets:$insets(0,0,0,0),imageEdgeInsets:$insets(0,0,0,0)},this.menu?{menu:this.menu}:{},this.title?{title:this.title}:{},this.props),views:[{type:\"image\",props:Object.assign({id:`icon-button-${this.id}`,hidden:void 0===this.symbol,tintColor:this.color},void 0===this.symbol?{}:\"string\"==typeof this.symbol?{symbol:this.symbol}:{data:this.symbol.png}),layout:(e,t)=>{e.center.equalTo(t.super),e.size.equalTo(this.iconSize)}},{type:\"image\",props:{id:`icon-checkmark-${this.id}`,alpha:0,tintColor:this.color,symbol:\"checkmark\"},layout:(e,t)=>{e.center.equalTo(t.super),e.size.equalTo(this.iconSize)}}],events:this.events,layout:$layout.fill},{type:\"spinner\",props:{id:\"spinner-\"+this.id,loading:!0,hidden:!0},layout:$layout.fill}],layout:(e,t)=>{if(e.size.equalTo($size(this.width,r.NavigationBarNormalHeight)),e.centerY.equalTo(t.super),t.prev&&t.prev?.info?.align===this.align)this.align===r.align.right?e.right.equalTo(t.prev.left):e.left.equalTo(t.prev.right);else{const t=this.edges/2;this.align===r.align.right?e.right.inset(t):e.left.inset(t)}}}}static creat({id:e,symbol:t,title:i,tapped:a,menu:n,events:o,color:l,align:c=r.align.right}={}){const h=new s;return h.setEvents(Object.assign({tapped:a},o)).setAlign(c).setSymbol(t).setTitle(i).setColor(l).setMenu(n),e&&h.setProp(\"id\",e),h}}e.exports={BarTitleView:class extends i{controller={};setController(e){return this.controller=e,this}},BarButtonItem:s,NavigationBarItems:class{rightButtons=[];leftButtons=[];#S={};hasbutton=!1;isPinTitleView=!1;setTitleView(e){return this.titleView=e,this}pinTitleView(){return this.isPinTitleView=!0,this}setFixedFooterView(e){return this.fixedFooterView=e,this}setRightButtons(e){return e.forEach((e=>this.addRightButton(e))),this.hasbutton||(this.hasbutton=!0),this}setLeftButtons(e){return e.forEach((e=>this.addLeftButton(e))),this.hasbutton||(this.hasbutton=!0),this}addRightButton({id:e,symbol:t,title:i,tapped:a,menu:n,events:o,color:l}={}){const c=s.creat({id:e,symbol:t,title:i,tapped:a,menu:n,events:o,color:l,align:r.align.right});return this.rightButtons.push(c),this.#S[e??c.id]=c,this.hasbutton||(this.hasbutton=!0),this}addLeftButton({id:e,symbol:t,title:i,tapped:a,menu:n,events:o,color:l}={}){const c=s.creat({id:e,symbol:t,title:i,tapped:a,menu:n,events:o,color:l,align:r.align.left});return this.leftButtons.push(c),this.#S[e??c.id]=c,this.hasbutton||(this.hasbutton=!0),this}getButton(e){return this.#S[e]}addPopButton(e,t,i){return e||(e=$l10n(\"BACK\")),this.popButtonView=t??{type:\"button\",props:{bgcolor:$color(\"clear\"),symbol:\"chevron.left\",tintColor:r.linkColor,title:` ${e}`,titleColor:r.linkColor,font:$font(\"bold\",16)},layout:(e,t)=>{e.left.equalTo(t.super.safeArea).offset(s.style.edges),e.centerY.equalTo(t.super.safeArea)},events:{tapped:()=>{$ui.pop(),\"function\"==typeof i&&i()}}},this}removePopButton(){return this.popButtonView=void 0,this}}}})),parcelRequire.register(\"gMc1q\",(function(e,t){var i=parcelRequire(\"fYz8N\").Controller;e.exports={ViewController:class extends i{#C=[];#I(e){e.callEvent(\"onPop\"),this.callEvent(\"onPop\",e),this.#C.pop()}push(e){const t=this.#C[this.#C.length-1];e.navigationBarItems.addPopButton(t?.navigationBar.title),this.#C.push(e),$ui.push({props:{statusBarStyle:0,navBarHidden:!0},events:{dealloc:()=>{this.#I(e)}},views:[e.getPage().definition],layout:$layout.fill})}}}})),String.prototype.trim=function(e,t){return e?\"l\"===t?this.replace(new RegExp(\"^\\\\\"+e+\"+\",\"g\"),\"\"):\"r\"===t?this.replace(new RegExp(\"\\\\\"+e+\"+$\",\"g\"),\"\"):this.replace(new RegExp(\"^\\\\\"+e+\"+|\\\\\"+e+\"+$\",\"g\"),\"\"):this.replace(/^\\s+|\\s+$/g,\"\")};var $czAIJ=parcelRequire(\"czAIJ\"),$bb0fea222fc5aea5$require$VERSION=$czAIJ.VERSION,$fYz8N=parcelRequire(\"fYz8N\"),$bb0fea222fc5aea5$require$Controller=$fYz8N.Controller,$272f042430a952c6$exports={},$45Ip7=parcelRequire(\"45Ip7\"),$272f042430a952c6$require$UIKit=$45Ip7.UIKit,$aXWmO=parcelRequire(\"aXWmO\"),$272f042430a952c6$require$Sheet=$aXWmO.Sheet,$cgaQ6=parcelRequire(\"cgaQ6\"),$272f042430a952c6$require$Kernel=$cgaQ6.Kernel,$12xzj=parcelRequire(\"12xzj\"),$272f042430a952c6$require$NavigationView=$12xzj.NavigationView,$dcStC=parcelRequire(\"dcStC\"),$272f042430a952c6$require$NavigationBar=$dcStC.NavigationBar;class $272f042430a952c6$var$FileManager{viewController;constructor(){this.listId=\"file-manager-list\",this.edges=10,this.iconSize=25,this.loadL10n()}loadL10n(){$272f042430a952c6$require$Kernel.l10n(\"zh-Hans\",{FILE_MANAGER_DELETE_CONFIRM_MSG:\"确认要删除吗\",DELETE:\"删除\",CANCEL:\"取消\",CLOSE:\"关闭\",SHARE:\"分享\",SAVE:\"保存\",SAVE_SUCCESS:\"保存成功\"},!1),$272f042430a952c6$require$Kernel.l10n(\"en\",{FILE_MANAGER_DELETE_CONFIRM_MSG:\"Are you sure you want to delete\",DELETE:\"Delete\",CANCEL:\"Cancel\",CLOSE:\"Close\",SHARE:\"Share\",SAVE:\"Save\",SAVE_SUCCESS:\"Save Success\"},!1)}setViewController(e){this.viewController=e}get menu(){return{items:[{title:$l10n(\"SHARE\"),symbol:\"square.and.arrow.up\",handler:async(e,t)=>{const i=e.object(t).info.info;$share.sheet([$file.absolutePath(i.path)])}}]}}delete(e){$file.delete(e.path)}edit(e){const t=$file.read(e.path);if(t.image)$quicklook.open({image:t.image});else{const i=new $272f042430a952c6$require$Sheet,r=$text.uuid;i.setView({type:\"code\",layout:$layout.fill,props:{id:r,lineNumbers:!0,theme:$device.isDarkMode?\"atom-one-dark\":\"atom-one-light\",text:t.string,insets:$insets(15,15,15,15)}}).addNavBar({title:e.file,popButton:{title:$l10n(\"CLOSE\")},rightButtons:[{title:$l10n(\"SAVE\"),tapped:()=>{$file.write({data:$data({string:$(r).text}),path:e.path}),$ui.success($l10n(\"SAVE_SUCCESS\"))}}]}),i.init().present()}}getFiles(e=\"\"){return $file.list(e).map((t=>{const i=e+\"/\"+t,r=$file.isDirectory(i);return{info:{info:{path:i,file:t,isDirectory:r}},icon:{symbol:r?\"folder.fill\":\"doc\"},name:{text:t},size:{text:r?\"\":\"--\"}}})).sort(((e,t)=>e.info.info.isDirectory!==t.info.info.isDirectory?e.info.info.isDirectory?-1:1:e.info.info.isDirectory===t.info.info.isDirectory?e.info.info.file.localeCompare(t.info.info.file):void 0))}async loadFileSize(e){return e.map(((t,i)=>{const r=t.info.info;if(!r.isDirectory)try{e[i].size.text=$272f042430a952c6$require$Kernel.bytesToSize($file.read(r.path).info.size)}catch(t){e[i].size.text=t}})),e}get listTemplate(){return{props:{bgcolor:$color(\"clear\")},views:[{props:{id:\"info\"}},{type:\"image\",props:{id:\"icon\"},layout:(e,t)=>{e.centerY.equalTo(t.super),e.left.inset(this.edges),e.size.equalTo(this.iconSize)}},{type:\"label\",props:{id:\"name\",lines:1},layout:(e,t)=>{e.centerY.equalTo(t.super),e.left.equalTo(t.prev.right).offset(this.edges)}},{type:\"label\",props:{id:\"size\",color:$color(\"secondaryText\"),lines:1},layout:(e,t)=>{e.centerY.equalTo(t.super),e.right.inset(this.edges)}}]}}#x(e,t){if(this.viewController){const i=new $272f042430a952c6$require$NavigationView;i.setView(t).navigationBarTitle(e),i.navigationBar.setLargeTitleDisplayMode($272f042430a952c6$require$NavigationBar.largeTitleDisplayModeNever),this.viewController.push(i)}else $272f042430a952c6$require$UIKit.push({title:e,views:[t]})}getListView(e=\"\"){return{type:\"list\",props:{id:this.listId,menu:this.menu,info:{basePath:e},bgcolor:$272f042430a952c6$require$UIKit.primaryViewBackgroundColor,separatorInset:$insets(0,this.edges,0,0),data:[],template:this.listTemplate,actions:[{title:\" \"+$l10n(\"DELETE\")+\" \",color:$color(\"red\"),handler:(e,t)=>{const i=e.object(t).info.info;$272f042430a952c6$require$Kernel.deleteConfirm($l10n(\"FILE_MANAGER_DELETE_CONFIRM_MSG\")+' \"'+i.file+'\" ?',(()=>{this.delete(i),e.delete(t)}))}}]},layout:$layout.fill,events:{ready:()=>{const t=this.getFiles(e);$(this.listId).data=t,this.loadFileSize(t).then((e=>{$(this.listId).data=e}))},pulled:async e=>{const t=this.getFiles($(this.listId).info.basePath);$(this.listId).data=t,$(this.listId).data=await this.loadFileSize(t),$delay(.5,(()=>{e.endRefreshing()}))},didSelect:(e,t,i)=>{const r=i.info.info;r.isDirectory?this.#x(r.file,this.getListView(r.path)):this.edit(r)}}}}push(e=\"\"){const t=e.substring(e.lastIndexOf(\"/\"));this.#x(t,this.getListView(e))}}$272f042430a952c6$exports={FileManager:$272f042430a952c6$var$FileManager};var $bb0fea222fc5aea5$require$FileManager=$272f042430a952c6$exports.FileManager,$8aDdQ=parcelRequire(\"8aDdQ\"),$bb0fea222fc5aea5$require$FileStorageParameterError=$8aDdQ.FileStorageParameterError,$bb0fea222fc5aea5$require$FileStorageFileNotFoundError=$8aDdQ.FileStorageFileNotFoundError,$bb0fea222fc5aea5$require$FileStorage=$8aDdQ.FileStorage,$4c192cc93140b629$exports={},$liCrE=parcelRequire(\"liCrE\"),$4c192cc93140b629$require$View=$liCrE.View,$45Ip7=parcelRequire(\"45Ip7\"),$4c192cc93140b629$require$UIKit=$45Ip7.UIKit;class $4c192cc93140b629$var$FixedFooterView extends $4c192cc93140b629$require$View{height=60;getView(){return this.type=\"view\",this.setProp(\"bgcolor\",$4c192cc93140b629$require$UIKit.primaryViewBackgroundColor),this.layout=(e,t)=>{e.left.right.bottom.equalTo(t.super),e.top.equalTo(t.super.safeAreaBottom).offset(-this.height)},this.views=[$4c192cc93140b629$require$View.create({props:this.props,views:this.views,layout:(e,t)=>{e.left.right.top.equalTo(t.super),e.height.equalTo(this.height)}})],this}}$4c192cc93140b629$exports={FixedFooterView:$4c192cc93140b629$var$FixedFooterView};var $bb0fea222fc5aea5$require$FixedFooterView=$4c192cc93140b629$exports.FixedFooterView,$cgaQ6=parcelRequire(\"cgaQ6\"),$bb0fea222fc5aea5$require$Kernel=$cgaQ6.Kernel,$50aa538fe0dbd3b0$exports={},$liCrE=parcelRequire(\"liCrE\"),$50aa538fe0dbd3b0$require$View=$liCrE.View;class $50aa538fe0dbd3b0$var$Matrix extends $50aa538fe0dbd3b0$require$View{titleStyle={font:$font(\"bold\",21),height:30};#k;#B;templateIdByIndex(e){return void 0===this.props.template.views[e]?.props?.id&&(void 0===this.props.template.views[e].props&&(this.props.template.views[e].props={}),this.props.template.views[e].props.id=$text.uuid),this.props.template.views[e].props.id}get templateHiddenStatus(){if(!this.#B){this.#B={};for(let e=0;e(e.items=e.items.map((e=>(Object.keys(e).forEach((t=>{e[t].hidden=this.templateHiddenStatus[t]??!1})),Object.keys(this.templateHiddenStatus).forEach((t=>{e[t]||(e[t]={}),e[t].hidden=this.templateHiddenStatus[t]})),e.__templateProps={hidden:!1},e.__title={hidden:!0},e))),e.title&&e.items.unshift(this.#q(e.title)),e)))}rebuildTemplate(){let e={};void 0!==this.props.template.props&&(e=Object.assign(this.props.template.props,{id:\"__templateProps\",hidden:!1})),this.props.template.props={};const t=[{type:\"view\",props:e,layout:$layout.fill},{type:\"label\",props:{id:\"__title\",hidden:!0,font:this.titleStyle.font},layout:(e,t)=>{e.top.inset(-this.titleStyle.height/4*3),e.height.equalTo(this.titleStyle.height),e.width.equalTo(t.super.safeArea)}}].concat(this.props.template.views);this.props.template.views=t}insert(e,t=!0){return e.indexPath=this.indexPath(e.indexPath,t),$(this.id).insert(e)}delete(e,t=!0){return e=this.indexPath(e,t),$(this.id).delete(e)}object(e,t=!0){return e=this.indexPath(e,t),$(this.id).object(e)}cell(e,t=!0){return e=this.indexPath(e,t),$(this.id).cell(e)}indexPath(e,t){let i=t?0:1;return\"number\"==typeof e&&(e=$indexPath(0,e)),$indexPath(e.section,e.row+i)}update(e){this.props.data=this.rebuildData(e),$(this.id).data=this.props.data}getView(){return this.props.data=this.rebuildData(this.props.data),this.rebuildTemplate(),this.setEvent(\"itemSize\",((e,t)=>{const i=e.object(t)?.__title?.info;if(i?.title)return $size(Math.max($device.info.screen.width,$device.info.screen.height),0);const r=this.props.columns??2,s=this.props.spacing??15,a=this.props.itemWidth??this.props.itemSize?.width??(e.super.frame.width-s*(r+1))/r,n=this.props.itemHeight??this.props.itemSize?.height??100;return $size(a,n)})),this}}$50aa538fe0dbd3b0$exports={Matrix:$50aa538fe0dbd3b0$var$Matrix};var $bb0fea222fc5aea5$require$Matrix=$50aa538fe0dbd3b0$exports.Matrix,$619319e3f3656d3f$exports={};class $619319e3f3656d3f$var$Request{static method={get:\"GET\",post:\"POST\",delete:\"DELETE\",patch:\"PATCH\",head:\"HEAD\"};cacheContainerKey=$addin?.current?.name+\".request.cache\";#R=!1;#L=!1;cacheLife=2592e6;isLogRequest=!1;timeout=5;logger;constructor(e){\"function\"==typeof e&&(this.logger=e)}get cache(){return $cache.get(this.cacheContainerKey)??{}}#O(e){this.isLogRequest&&\"function\"==typeof logger&&this.logger(e)}logRequest(e){return this.isLogRequest=!0,\"function\"==typeof e&&(this.logger=e),this}getCacheKey(e){return $text.MD5(e)}getCache(e,t=null){return this.cache[e]??t}setCache(e,t){if(!t)return;const i=this.cache;i[e]=t,$cache.set(this.cacheContainerKey,i)}removeCache(e){let t=this.cache;delete t[e],$cache.set(this.cacheContainerKey,t)}clearCache(){$cache.remove(this.cacheContainerKey)}useCache(){return this.#R=!0,this}ignoreCacheExp(){this.#L=!0}async request(e,t,i={},r={},s=this.cacheLife){let a;const n=this.#R&&t===$619319e3f3656d3f$var$Request.method.get;if(n){a=this.getCacheKey(e);const t=this.getCache(a);if(t&&(this.#L||t.exp>Date.now()))return this.#O(\"get data from cache: \"+e),t.data}try{this.#O(`sending request [${t}]: ${e}`);const o=await $http.request({header:r,url:e,method:t,body:i,timeout:this.timeout});if(o.error)throw o.error;if(o?.response?.statusCode>=400){let e=o.data;throw\"object\"==typeof e&&(e=JSON.stringify(e)),new Error(\"http error: [\"+o.response.statusCode+\"] \"+e)}return n&&this.setCache(a,{exp:Date.now()+s,data:o}),o}catch(e){throw e.code&&(e=new Error(\"network error: [\"+e.code+\"] \"+e.localizedDescription)),e}}}$619319e3f3656d3f$exports={Request:$619319e3f3656d3f$var$Request};var $bb0fea222fc5aea5$require$Request=$619319e3f3656d3f$exports.Request,$7D8Kb=parcelRequire(\"7D8Kb\"),$bb0fea222fc5aea5$require$Setting=$7D8Kb.Setting,$aXWmO=parcelRequire(\"aXWmO\"),$bb0fea222fc5aea5$require$Sheet=$aXWmO.Sheet,$7dfcabb1e936a92c$exports={},$liCrE=parcelRequire(\"liCrE\"),$7dfcabb1e936a92c$require$View=$liCrE.View,$7dfcabb1e936a92c$require$PageView=$liCrE.PageView,$fYz8N=parcelRequire(\"fYz8N\"),$7dfcabb1e936a92c$require$Controller=$fYz8N.Controller,$45Ip7=parcelRequire(\"45Ip7\"),$7dfcabb1e936a92c$require$UIKit=$45Ip7.UIKit;class $7dfcabb1e936a92c$var$TabBarCellView extends $7dfcabb1e936a92c$require$View{constructor(e={}){super(e),this.setIcon(e.icon),this.setTitle(e.title),void 0!==e.activeStatus&&(this.activeStatus=e.activeStatus)}setIcon(e){return this.icon=e instanceof Array?e:[e,e],this}setTitle(e){return this.title=e,this}active(){$(`${this.props.id}-icon`).image=$image(this.icon[1]),$(`${this.props.id}-icon`).tintColor=$color(\"systemLink\"),$(`${this.props.id}-title`).textColor=$color(\"systemLink\"),this.activeStatus=!0}inactive(){$(`${this.props.id}-icon`).image=$image(this.icon[0]),$(`${this.props.id}-icon`).tintColor=$color(\"lightGray\"),$(`${this.props.id}-title`).textColor=$color(\"lightGray\"),this.activeStatus=!1}getView(){return this.views=[{type:\"image\",props:{id:`${this.props.id}-icon`,image:$image(this.activeStatus?this.icon[1]:this.icon[0]),bgcolor:$color(\"clear\"),tintColor:$color(this.activeStatus?\"systemLink\":\"lightGray\")},layout:(e,t)=>{e.centerX.equalTo(t.super);const i=$7dfcabb1e936a92c$var$TabBarController.tabBarHeight/2;e.size.equalTo(i),e.top.inset(($7dfcabb1e936a92c$var$TabBarController.tabBarHeight-i-13)/2)}},{type:\"label\",props:{id:`${this.props.id}-title`,text:this.title,font:$font(10),textColor:$color(this.activeStatus?\"systemLink\":\"lightGray\")},layout:(e,t)=>{e.centerX.equalTo(t.prev),e.top.equalTo(t.prev.bottom).offset(3)}}],this}}class $7dfcabb1e936a92c$var$TabBarHeaderView extends $7dfcabb1e936a92c$require$View{height=60;getView(){return this.type=\"view\",this.setProp(\"bgcolor\",this.props.bgcolor??$7dfcabb1e936a92c$require$UIKit.primaryViewBackgroundColor),this.layout=(e,t)=>{e.left.right.bottom.equalTo(t.super),e.top.equalTo(t.super.safeAreaBottom).offset(-this.height-$7dfcabb1e936a92c$var$TabBarController.tabBarHeight)},this.views=[$7dfcabb1e936a92c$require$View.create({props:this.props,views:this.views,layout:(e,t)=>{e.left.right.top.equalTo(t.super),e.height.equalTo(this.height)}})],this}}class $7dfcabb1e936a92c$var$TabBarController extends $7dfcabb1e936a92c$require$Controller{static tabBarHeight=50;#D={};#N={};#V;#_;#P=$text.uuid;#M=$text.uuid;bottomSafeAreaInsets=$app.isDebugging?0:$7dfcabb1e936a92c$require$UIKit.bottomSafeAreaInsets;get selected(){return this.#_}set selected(e){this.switchPageTo(e)}get contentOffset(){return $7dfcabb1e936a92c$var$TabBarController.tabBarHeight+(this.#V?.height??0)}setPages(e={}){return Object.keys(e).forEach((t=>this.setPage(t,e[t]))),this}setPage(e,t){return void 0===this.#_&&(this.#_=e),this.#D[e]=t instanceof $7dfcabb1e936a92c$require$PageView?t:$7dfcabb1e936a92c$require$PageView.create(t),this.#_!==e&&(this.#D[e].activeStatus=!1),this}switchPageTo(e){if(this.#D[e]){if(this.#_===e)return;$ui.animate({duration:.4,animation:()=>{this.#N[e].active()}}),this.#N[this.#_].inactive(),this.#D[this.#_].hide(),this.#D[e].show(),this.callEvent(\"onChange\",this.#_,e),this.#_=e,this.initBackground()}}hideBackground(e=!0){$(this.#M).hidden=!0,$ui.animate({duration:e?.2:1e-4,animation:()=>{$(this.#P).alpha=0}})}showBackground(e=!0){$(this.#M).hidden=!1,$ui.animate({duration:e?.2:1e-4,animation:()=>{$(this.#P).alpha=1}})}initBackground(){const e=this.#D[this.selected];e.scrollable&&$delay(0,(()=>{const t=$(e.id).get(e.scrollableView.id),i=t.contentOffset.y;t.contentSize.height+this.bottomSafeAreaInsets-t.frame.height-i<=0?this.hideBackground(!1):this.showBackground(!1)}))}setCells(e={}){return Object.keys(e).forEach((t=>this.setCell(t,e[t]))),this}setCell(e,t){return void 0===this.#_&&(this.#_=e),t instanceof $7dfcabb1e936a92c$var$TabBarCellView||(t=new $7dfcabb1e936a92c$var$TabBarCellView({props:{info:{key:e}},icon:t.icon,title:t.title,activeStatus:this.#_===e})),this.#N[e]=t,this}setHeader(e){return this.#V=e,this}#F(){const e=[];return Object.values(this.#N).forEach((t=>{t.setEvent(\"tapped\",(e=>{const t=e.info.key;this.switchPageTo(t)})),e.push(t.getView())})),e}#H(){return Object.values(this.#D).map((e=>{if(e.scrollable){const t=e.scrollableView;if(t.props.indicatorInsets){const e=t.props.indicatorInsets;t.props.indicatorInsets=$insets(e.top,e.left,e.bottom+this.contentOffset,e.right)}else t.props.indicatorInsets=$insets(0,0,this.contentOffset,0);t.props.footer=Object.assign({props:{}},t.props.footer??{}),t.props.footer.props.height?t.props.footer.props.height+=this.contentOffset:t.props.footer.props.height=this.contentOffset,\"function\"==typeof t.assignEvent&&t.assignEvent(\"didScroll\",(e=>{const t=e.contentOffset.y;e.contentSize.height+this.bottomSafeAreaInsets-e.frame.height-t<=1?this.hideBackground():this.showBackground()}))}return e.definition}))}generateView(){const e={type:\"view\",layout:(e,t)=>{e.centerX.equalTo(t.super),e.width.equalTo(t.super),e.top.equalTo(t.super.safeAreaBottom).offset(-$7dfcabb1e936a92c$var$TabBarController.tabBarHeight),e.bottom.equalTo(t.super)},views:[$7dfcabb1e936a92c$require$UIKit.blurBox({id:this.#P}),{type:\"stack\",layout:$layout.fillSafeArea,props:{axis:$stackViewAxis.horizontal,distribution:$stackViewDistribution.fillEqually,spacing:0,stack:{views:this.#F()}}},$7dfcabb1e936a92c$require$UIKit.separatorLine({id:this.#M},$7dfcabb1e936a92c$require$UIKit.align.top)],events:{ready:()=>this.initBackground()}};return $7dfcabb1e936a92c$require$View.createFromViews(this.#H().concat(this.#V?.definition??[],e))}}$7dfcabb1e936a92c$exports={TabBarCellView:$7dfcabb1e936a92c$var$TabBarCellView,TabBarHeaderView:$7dfcabb1e936a92c$var$TabBarHeaderView,TabBarController:$7dfcabb1e936a92c$var$TabBarController};var $bb0fea222fc5aea5$require$TabBarCellView=$7dfcabb1e936a92c$exports.TabBarCellView,$bb0fea222fc5aea5$require$TabBarHeaderView=$7dfcabb1e936a92c$exports.TabBarHeaderView,$bb0fea222fc5aea5$require$TabBarController=$7dfcabb1e936a92c$exports.TabBarController,$3839e9f9bae78bdd$exports={};class $3839e9f9bae78bdd$var$Tasks{#U={};addTask(e,t=0){const i=$text.uuid;return this.#U[i]=$delay(t,(async()=>{await e(),delete this.#U[i]})),i}cancelTask(e){this.#U[e].cancel()}clearTasks(){Object.values(this.#U).forEach((e=>e.cancel()))}}$3839e9f9bae78bdd$exports={Tasks:$3839e9f9bae78bdd$var$Tasks};var $bb0fea222fc5aea5$require$Tasks=$3839e9f9bae78bdd$exports.Tasks,$895b2d75ea56b5f0$exports={},$45Ip7=parcelRequire(\"45Ip7\"),$895b2d75ea56b5f0$require$UIKit=$45Ip7.UIKit;class $895b2d75ea56b5f0$var$Toast{static type={info:void 0,success:\"checkmark\",warning:\"exclamationmark.triangle\",error:\"xmark.circle\"};static edges=40;static iconSize=100;static labelTopMargin=10;width=Math.min(.6*$895b2d75ea56b5f0$require$UIKit.windowSize.width,260);labelWidth=this.width-2*$895b2d75ea56b5f0$var$Toast.edges;id=$text.uuid;#z=\"\";type=$895b2d75ea56b5f0$var$Toast.type.info;labelLines=2;font=$font(\"default\",26);constructor(e,t=$895b2d75ea56b5f0$var$Toast.type.info,i=2,r=$font(\"default\",26)){this.type=t,this.message=e,this.labelLines=i,this.font=r}get message(){return this.#z}set message(e){this.#z=e,this.fontHeight=$895b2d75ea56b5f0$require$UIKit.getContentSize(this.font,this.message,this.labelWidth,this.labelLines).height,this.height=(this.hasIcon?$895b2d75ea56b5f0$var$Toast.labelTopMargin+$895b2d75ea56b5f0$var$Toast.iconSize:0)+this.fontHeight+2*$895b2d75ea56b5f0$var$Toast.edges}get hasIcon(){return void 0!==this.type}get blurBox(){const e=$895b2d75ea56b5f0$require$UIKit.blurBox({id:this.id,cornerRadius:15,alpha:0},[{type:\"image\",props:{symbol:this.type,hidden:!this.hasIcon,tintColor:$color(\"lightGray\")},layout:(e,t)=>{e.top.inset($895b2d75ea56b5f0$var$Toast.edges),e.size.equalTo($895b2d75ea56b5f0$var$Toast.iconSize),e.centerX.equalTo(t.super)}},{type:\"label\",props:{font:this.font,text:this.message,align:$align.center,lines:this.labelLines,color:$color(\"lightGray\")},layout:(e,t)=>{e.bottom.equalTo(t.supper).offset(-$895b2d75ea56b5f0$var$Toast.edges),e.width.equalTo(this.labelWidth),e.height.equalTo(this.fontHeight),e.centerX.equalTo(t.super)}}]);return e.events={tapped:()=>{this.remove()}},e}show(){$ui.controller.view.insertAtIndex($ui.create(this.blurBox),0);const e=$(this.id);e.layout(((e,t)=>{e.center.equalTo(t.super),e.size.equalTo($size(this.width,this.height))})),e.moveToFront(),$ui.animate({duration:.2,animation:()=>{e.alpha=1}})}remove(){const e=$(this.id);e&&$ui.animate({duration:.2,animation:()=>{e.alpha=0},completion:()=>{e.remove()}})}static toast({message:e,type:t=$895b2d75ea56b5f0$var$Toast.type.info,displayTime:i=2,labelLines:r=2,font:s=$font(\"default\",26)}){const a=new $895b2d75ea56b5f0$var$Toast(e,t,r,s);a.show(),$delay(i,(()=>{a.remove()}))}static info(e,t={}){$895b2d75ea56b5f0$var$Toast.toast(Object.assign({message:e,type:$895b2d75ea56b5f0$var$Toast.type.info},t))}static success(e,t={}){$895b2d75ea56b5f0$var$Toast.toast(Object.assign({message:e,type:$895b2d75ea56b5f0$var$Toast.type.success},t))}static warning(e,t={}){$895b2d75ea56b5f0$var$Toast.toast(Object.assign({message:e,type:$895b2d75ea56b5f0$var$Toast.type.warning},t))}static error(e,t={}){$895b2d75ea56b5f0$var$Toast.toast(Object.assign({message:e,type:$895b2d75ea56b5f0$var$Toast.type.error},t))}}$895b2d75ea56b5f0$exports={Toast:$895b2d75ea56b5f0$var$Toast};var $bb0fea222fc5aea5$require$Toast=$895b2d75ea56b5f0$exports.Toast,$45Ip7=parcelRequire(\"45Ip7\"),$bb0fea222fc5aea5$require$UIKit=$45Ip7.UIKit,$86d2ffde19fb8791$exports={};class $86d2ffde19fb8791$var$UILoading{#j;text=\"\";interval;fullScreen=!1;#K=()=>{};constructor(){this.#j=$text.uuid}updateText(e){$(this.#j).text=e}setLoop(e){if(\"function\"!=typeof e)throw\"loop must be a function\";this.#K=e}done(){clearInterval(this.interval)}load(){$ui.render({props:{navBarHidden:this.fullScreen},views:[{type:\"spinner\",props:{loading:!0},layout:(e,t)=>{e.centerY.equalTo(t.super).offset(-15),e.width.equalTo(t.super)}},{type:\"label\",props:{id:this.#j,align:$align.center,text:\"\"},layout:(e,t)=>{e.top.equalTo(t.prev.bottom).offset(10),e.left.right.equalTo(t.super)}}],layout:$layout.fill,events:{appeared:()=>{this.interval=setInterval((()=>{this.#K()}),100)}}})}}$86d2ffde19fb8791$exports={UILoading:$86d2ffde19fb8791$var$UILoading};var $bb0fea222fc5aea5$require$UILoading=$86d2ffde19fb8791$exports.UILoading,$6Xrbz=parcelRequire(\"6Xrbz\"),$bb0fea222fc5aea5$require$ValidationError=$6Xrbz.ValidationError,$liCrE=parcelRequire(\"liCrE\"),$bb0fea222fc5aea5$require$View=$liCrE.View,$bb0fea222fc5aea5$require$PageView=$liCrE.PageView,$gMc1q=parcelRequire(\"gMc1q\"),$bb0fea222fc5aea5$require$ViewController=$gMc1q.ViewController,$12xzj=parcelRequire(\"12xzj\"),$bb0fea222fc5aea5$require$NavigationView=$12xzj.NavigationView,$dcStC=parcelRequire(\"dcStC\"),$bb0fea222fc5aea5$require$NavigationBar=$dcStC.NavigationBar,$bb0fea222fc5aea5$require$NavigationBarController=$dcStC.NavigationBarController,$gAYmG=parcelRequire(\"gAYmG\"),$bb0fea222fc5aea5$require$NavigationBarItems=$gAYmG.NavigationBarItems,$bb0fea222fc5aea5$require$BarButtonItem=$gAYmG.BarButtonItem,$ee5e1f8d12d987dc$exports={},$fYz8N=parcelRequire(\"fYz8N\"),$ee5e1f8d12d987dc$require$Controller=$fYz8N.Controller,$gAYmG=parcelRequire(\"gAYmG\"),$ee5e1f8d12d987dc$require$BarTitleView=$gAYmG.BarTitleView;class $ee5e1f8d12d987dc$var$SearchBar extends $ee5e1f8d12d987dc$require$BarTitleView{height=35;topOffset=15;bottomOffset=10;kbType=$kbType.search;placeholder=$l10n(\"SEARCH\");inputEvents={};keyboardView;accessoryView;constructor(e){super(e),this.setController(new $ee5e1f8d12d987dc$var$SearchBarController),this.controller.setSearchBar(this)}setEvent(e,t){return this.inputEvents[e]=t,this}setPlaceholder(e){return this.placeholder=e,this}setKbType(e){return this.kbType=e,this}setKeyboardView(e){return this.keyboardView=e,this}setAccessoryView(e){return this.accessoryView=e,this}getView(){return this.props={id:this.id,smoothCorners:!0,cornerRadius:6,bgcolor:$color(\"#EEF1F1\",\"#212121\")},this.views=[{type:\"input\",props:{id:this.id+\"-input\",type:this.kbType,bgcolor:$color(\"clear\"),placeholder:this.placeholder,keyboardView:this.keyboardView,accessoryView:this.accessoryView},layout:$layout.fill,events:Object.assign({changed:e=>this.controller.callEvent(\"onChange\",e.text),returned:e=>this.controller.callEvent(\"onReturn\",e.text)},this.inputEvents)}],this.layout=(e,t)=>{e.height.equalTo(this.height),e.top.equalTo(t.super.safeArea).offset(this.topOffset),e.left.equalTo(t.super.safeArea).offset(15),e.right.equalTo(t.super.safeArea).offset(-15)},this}}class $ee5e1f8d12d987dc$var$SearchBarController extends $ee5e1f8d12d987dc$require$Controller{setSearchBar(e){return this.searchBar=e,this}updateSelector(){this.selector={inputBox:$(this.searchBar.id),input:$(this.searchBar.id+\"-input\")}}hide(){this.updateSelector(),this.selector.inputBox.updateLayout((e=>{e.height.equalTo(0)}))}show(){this.updateSelector(),this.selector.inputBox.updateLayout((e=>{e.height.equalTo(this.searchBar.height)}))}didScroll(e){this.updateSelector();let t=this.searchBar.height-e;if(t=t>0?t>this.searchBar.height?this.searchBar.height:t:0,this.selector.inputBox.updateLayout((e=>{e.height.equalTo(t)})),e>0){const t=(this.searchBar.height/2-5-e)/10;this.selector.input.alpha=t}else this.selector.input.alpha=1}didEndDragging(e,t,i){this.updateSelector(),e>=0&&e<=this.searchBar.height&&i($point(0,e>=this.searchBar.height/2?this.searchBar.height:0))}}$ee5e1f8d12d987dc$exports={SearchBar:$ee5e1f8d12d987dc$var$SearchBar,SearchBarController:$ee5e1f8d12d987dc$var$SearchBarController};var $bb0fea222fc5aea5$require$SearchBar=$ee5e1f8d12d987dc$exports.SearchBar,$bb0fea222fc5aea5$require$SearchBarController=$ee5e1f8d12d987dc$exports.SearchBarController;module.exports={VERSION:$bb0fea222fc5aea5$require$VERSION,Controller:$bb0fea222fc5aea5$require$Controller,FileManager:$bb0fea222fc5aea5$require$FileManager,FileStorageParameterError:$bb0fea222fc5aea5$require$FileStorageParameterError,FileStorageFileNotFoundError:$bb0fea222fc5aea5$require$FileStorageFileNotFoundError,FileStorage:$bb0fea222fc5aea5$require$FileStorage,FixedFooterView:$bb0fea222fc5aea5$require$FixedFooterView,Kernel:$bb0fea222fc5aea5$require$Kernel,Matrix:$bb0fea222fc5aea5$require$Matrix,Request:$bb0fea222fc5aea5$require$Request,Setting:$bb0fea222fc5aea5$require$Setting,Sheet:$bb0fea222fc5aea5$require$Sheet,TabBarCellView:$bb0fea222fc5aea5$require$TabBarCellView,TabBarHeaderView:$bb0fea222fc5aea5$require$TabBarHeaderView,TabBarController:$bb0fea222fc5aea5$require$TabBarController,Tasks:$bb0fea222fc5aea5$require$Tasks,Toast:$bb0fea222fc5aea5$require$Toast,UIKit:$bb0fea222fc5aea5$require$UIKit,UILoading:$bb0fea222fc5aea5$require$UILoading,ValidationError:$bb0fea222fc5aea5$require$ValidationError,View:$bb0fea222fc5aea5$require$View,PageView:$bb0fea222fc5aea5$require$PageView,ViewController:$bb0fea222fc5aea5$require$ViewController,NavigationView:$bb0fea222fc5aea5$require$NavigationView,NavigationBar:$bb0fea222fc5aea5$require$NavigationBar,NavigationBarController:$bb0fea222fc5aea5$require$NavigationBarController,NavigationBarItems:$bb0fea222fc5aea5$require$NavigationBarItems,BarButtonItem:$bb0fea222fc5aea5$require$BarButtonItem,SearchBar:$bb0fea222fc5aea5$require$SearchBar,SearchBarController:$bb0fea222fc5aea5$require$SearchBarController}})),parcelRequire.register(\"jEwwi\",(function(e,t){var i=parcelRequire(\"gxpqj\").Kernel;class r{sqlite;constructor(e){this.kernel=e,this.dbName=\"CAIO.db\",this.localDb=`/${this.dbName}`,this.imagePath=\"/image\",this.imageOriginalPath=`${this.imagePath}/original`,this.imagePreviewPath=`${this.imagePath}/preview`,this.tempPath=\"/temp\",this.tempDbFile=`${this.tempPath}/${this.dbName}`,this.tempImagePath=`${this.tempPath}/image`,this.exportFileName=\"CAIO.zip\",this.init()}init(){this.sqlite=$sqlite.open(this.kernel.fileStorage.filePath(this.localDb)),this.sqlite.update(\"CREATE TABLE IF NOT EXISTS clips(uuid TEXT PRIMARY KEY NOT NULL, text TEXT, md5 TEXT, prev TEXT, next TEXT)\"),this.sqlite.update(\"CREATE TABLE IF NOT EXISTS favorite(uuid TEXT PRIMARY KEY NOT NULL, text TEXT, md5 TEXT, prev TEXT, next TEXT)\"),this.sqlite.update(\"CREATE TABLE IF NOT EXISTS tag(uuid TEXT PRIMARY KEY NOT NULL, tag TEXT)\")}rebuild(){const e=this.tempPath+\"/rebuild.db\";this.kernel.fileStorage.delete(e);const t=new r(this.kernel);t.localDb=e,t.init();const i=(e,i)=>{const r=[];e.forEach((e=>{const s={uuid:e.uuid,text:e.text,md5:e.md5,tag:e.tag,image:e.image,prev:null,next:r[0]?.uuid??null};t.beginTransaction();try{t.insert(i,s),s.next&&(r[0].prev=s.uuid,t.update(i,r[0])),t.commit(),r.unshift(s)}catch(e){throw t.rollback(),this.kernel.error(e),e}}))};[\"clips\",\"favorite\"].map((e=>{let t=this.all(e);try{const e=this.sort(JSON.parse(JSON.stringify(t)));if(e.length>t.length)throw new Error;t=e.reverse()}catch{}i(t,e)}));const s=this.sqlite.query(\"SELECT * FROM tag\");this.parseTag(s).forEach((e=>{t.beginTransaction();try{t.setTag(e.uuid,e.tag),t.commit()}catch(e){throw t.rollback(),this.kernel.error(e),e}})),this.kernel.fileStorage.copy(e,this.localDb)}deleteAllData(){this.kernel.fileStorage.delete(this.imagePath),this.kernel.fileStorage.delete(this.localDb)}clearTemp(){this.kernel.fileStorage.delete(this.tempPath)}async export(e){this.clearTemp(),this.kernel.fileStorage.copy(this.localDb,this.tempDbFile),this.kernel.fileStorage.copy(this.imagePath,this.tempImagePath);const t=this.tempPath+\"/\"+this.exportFileName;await $archiver.zip({directory:this.kernel.fileStorage.filePath(this.tempPath),dest:this.kernel.fileStorage.filePath(t)}),$share.sheet({items:[{name:this.exportFileName,data:$data({path:this.kernel.fileStorage.filePath(t)})}],handler:i=>{this.kernel.fileStorage.delete(t),e(i)}})}async import(e){if(\"db\"===e.fileName.slice(-2)){if(!this.kernel.fileStorage.writeSync(this.localDb,e))throw new Error(\"WRITE_DB_FILE_FAILED\")}else if(\"zip\"===e.fileName.slice(-3)){if(!await $archiver.unzip({file:e,dest:this.kernel.fileStorage.filePath(this.tempPath)}))throw new Error(\"UNZIP_FAILED\");this.kernel.fileStorage.move(this.tempDbFile,this.localDb),this.kernel.fileStorage.move(this.tempImagePath,this.imagePath)}}sort(e,t=9e3){const i={};let r=0,s=null;e.forEach((e=>{i[e.uuid]=e,null===e.prev&&(s=e.uuid),r++}));const a=[];if(r>0)try{let e=i[s];for(;null!==e.next&&t>0;)t--,a.push(e),e=i[e.next];a.push(e)}catch(e){throw\"Unable to sort: \"+e}return a}parse(e){const t=e.result,i=e.error;if(null!==i)throw new Error(`Code [${i.code}] ${i.domain} ${i.localizedDescription}`);const r=[];for(;t.next();)r.push({uuid:t.get(\"uuid\"),section:t.get(\"section\"),text:t.get(\"text\"),md5:t.get(\"md5\"),tag:t.get(\"tag\")??\"\",prev:t.get(\"prev\")??null,next:t.get(\"next\")??null});return t.close(),r}parseTag(e){if(null!==e.error)throw e.error;const t=[];for(;e.result.next();)t.push({uuid:e.result.get(\"uuid\"),tag:e.result.get(\"tag\")});return e.result.close(),t}beginTransaction(){this.sqlite.beginTransaction()}commit(){this.sqlite.commit()}rollback(){this.sqlite.rollback()}getByUUID(e){e=e.replace(\"'\",\"\");const t=this.sqlite.query({sql:`\\n SELECT *, 'clips' AS section FROM clips WHERE uuid = '${e}'\\n UNION\\n SELECT *, 'favorite' AS section FROM favorite WHERE uuid = '${e}'\\n `});return this.parse(t)[0]}getByMD5(e){e=e.replace(\"'\",\"\");const t=this.sqlite.query({sql:`\\n SELECT *, 'clips' AS section FROM clips WHERE md5 = '${e}'\\n UNION\\n SELECT *, 'favorite' AS section FROM favorite WHERE md5 = '${e}'\\n `});return this.parse(t)[0]}search(e){const t=this.sqlite.query({sql:\"SELECT * from\\n (SELECT clips.*, 'clips' AS section FROM clips WHERE text like ?\\n UNION\\n SELECT favorite.*, 'favorite' AS section FROM favorite WHERE text like ?) a\\n LEFT JOIN tag ON a.uuid = tag.uuid\\n \",args:[`%${e}%`,`%${e}%`]});return this.parse(t)}isImage(e){return e?.startsWith(\"@image=\")}pathToKey(e){return`@image=${e=JSON.stringify(e)}`}keyToPath(e){return!!this.isImage(e)&&JSON.parse(e.slice(7))}deleteTable(e){const t=this.sqlite.update(`DELETE FROM ${e}`);if(!t.result)throw t.error}all(e){const t=this.sqlite.query(`SELECT ${e}.*, tag, '${e}' AS section FROM ${e} LEFT JOIN tag ON ${e}.uuid = tag.uuid`);return this.parse(t)}insert(e,t){if(t.image){const e=t.image,r=$text.uuid,s={original:`${this.imageOriginalPath}/${r}.png`,preview:`${this.imagePreviewPath}/${r}.jpg`};this.kernel.fileStorage.write(s.original,e.png),this.kernel.fileStorage.write(s.preview,i.compressImage(e).jpg(.8)),t.text=this.pathToKey(s)}const r=this.sqlite.update({sql:`INSERT INTO ${e} (uuid, text, md5, prev, next) values (?, ?, ?, ?, ?)`,args:[t.uuid,t.text,$text.MD5(t.text),t.prev,t.next]});if(!r.result)throw r.error}update(e,t){if(Object.keys(t).length<4||\"string\"!=typeof t.uuid)return;const i=this.sqlite.update({sql:`UPDATE ${e} SET text = ?, md5 = ?, prev = ?, next = ? WHERE uuid = ?`,args:[t.text,$text.MD5(t.text),t.prev,t.next,t.uuid]});if(!i.result)throw i.error}updateText(e,t,i){if(\"string\"!=typeof t)return;const r=this.sqlite.update({sql:`UPDATE ${e} SET text = ?, md5 = ? WHERE uuid = ?`,args:[i,$text.MD5(i),t]});if(!r.result)throw r.error}delete(e,t){const i=this.getByUUID(t);this.beginTransaction();try{const i=this.sqlite.update({sql:`DELETE FROM ${e} WHERE uuid = ?`,args:[t]});if(!i.result)throw i.error;this.deleteTag(t),this.commit()}catch(e){throw this.rollback(),e}const r=this.keyToPath(i?.text);r&&(this.kernel.fileStorage.delete(r.original),this.kernel.fileStorage.delete(r.preview))}setTag(e,t){const i=this.sqlite.update({sql:\"INSERT OR REPLACE INTO tag (uuid, tag) values (?, ?)\",args:[e,t]});if(!i.result)throw i.error}deleteTag(e){const t=this.sqlite.update({sql:\"DELETE FROM tag WHERE uuid = ?\",args:[e]});if(!t.result)throw t.error}}e.exports=r})),parcelRequire.register(\"imdB1\",(function(e,t){var i=parcelRequire(\"gxpqj\"),r=i.View,s=i.Kernel,a=i.UIKit,n=i.Sheet,o=i.ViewController,l=i.NavigationView,c=i.NavigationBar,h=i.Toast,d=parcelRequire(\"f0nX9\"),p=parcelRequire(\"ZnuTV\"),u=parcelRequire(\"ay4Kj\"),g=parcelRequire(\"9LqeL\"),f=parcelRequire(\"eSp9Z\"),y=f.ActionData,b=f.ActionEnv;e.exports=class extends p{listId=\"clips-list\";#Y=!1;#G=-1;tabLeftMargin=20;horizontalMargin=20;verticalMargin=20;containerMargin=0;fontSize=16;copiedIndicatorSize=6;imageContentHeight=50;tagFontSize=14;tagContainerHeight=25;menuItemActionMaxCount=5;tabHeight=44;copied=$cache.get(\"clips.copied\")??{};#W={};constructor(e){super(e),this.viewController=new o,this.search=new u(this.kernel),this.search.setCallback((e=>{(new n).setView(this.getListView(this.listId+\"-search-result\",e.map((e=>this.lineData(e))))).addNavBar({title:$l10n(\"SEARCH_RESULT\"),popButton:{title:$l10n(\"DONE\"),tapped:()=>this.search.dismiss()}}).init().present()}))}get singleLineHeight(){return this.#G<0&&(this.#G=$text.sizeThatFits({text:\"A\",width:this.fontSize,font:$font(this.fontSize)}).height),this.#G}setSingleLine(){this.#Y=!0,this.imageContentHeight=this.singleLineHeight}getTextHeight(e){return this.#W[e]||(this.#W[e]=this.#Y?this.singleLineHeight:Math.min($text.sizeThatFits({text:e,width:a.windowSize.width-2*(this.horizontalMargin+this.containerMargin),font:$font(this.fontSize)}).height,2*this.singleLineHeight)),this.#W[e]}appListen(){s.isTaio||$app.listen({resume:()=>{this.updateList(!0),$delay(.5,(()=>{this.readClipboard()}))}})}listReady(){this.updateList(),s.isTaio||($delay(.5,(()=>{if($context.query.copy){const e=$context.query.copy,t=this.kernel.storage.getByUUID(e);this.setClipboardText(t.text),this.setCopied(e,this.getRowByUUID(e)),$ui.success($l10n(\"COPIED\"))}else $context.query.add?this.getAddTextView():$context.query.actions&&(this.kernel.isUseJsboxNav?this.kernel.actionManager.present():this.kernel.tabBarController.switchPageTo(\"actions\"))})),$delay(.5,(()=>{this.readClipboard()})),this.appListen())}updateList(e=!1){e&&this.loadAllClips(),$(this.listId).data=this.clips.map((e=>this.lineData(e,this.copied.uuid===e.uuid))),this.updateListBackground()}updateListBackground(){const e=$(this.listId+\"-empty-list-background\");e&&(e.hidden=this.clips.length>0)}updateCopied(e={}){Object.assign(this.copied,e),this.kernel.print(`this.copied: ${JSON.stringify(this.copied,null,2)}`),$cache.set(\"clips.copied\",this.copied)}setCopied(e,t,i=!0){if(!e||e===this.copied.uuid&&this.tabIndex===this.copied?.tabIndex&&t===this.copied?.row)return;let r={};this.copied.uuid!==e&&(r=this.kernel.storage.getByUUID(e)??{}),r.tabIndex=this.tabIndex,r.row=t;const s=this.copied.row;this.updateCopied(r),i&&$delay(.3,(()=>{const e=$(this.listId);e.cell($indexPath(0,s)).get(\"copied\").hidden=!0,e.cell($indexPath(0,t)).get(\"copied\").hidden=!1}))}readClipboard(e=!1){if(e||this.kernel.setting.get(\"clipboard.autoSave\")){if(this.kernel.print(\"read clipboard\"),!this.isChanged)return void(e&&$ui.toast($l10n(\"CLIPBOARD_NO_CHANGE\")));if(this.switchTab(1,!0),$clipboard.images?.length>0)return!!e&&($clipboard.images.forEach((e=>{this.add(e)})),!0);const t=$clipboard.text;if(!t||\"\"===t)return!1;if(this.copied.text===t)return!1;const i=$text.MD5(t);if(this.savedClipboardIndex[i]){const e=this.kernel.storage.getByMD5(i);this.setCopied(e.uuid,this.getRowByUUID(e.uuid))}else{const e=this.add(t);this.copy(t,e.uuid,0)}}return!1}add(e){try{const t=super.add(e);return this.updateListBackground(),$(this.listId).insert({indexPath:$indexPath(0,0),value:this.lineData(t)}),this.copied?.tabIndex===this.tabIndex&&this.setCopied(this.copied.uuid,this.copied?.row+1,!1),t}catch(e){$ui.alert(e)}}delete(e,t){try{super.delete(e,t),this.copied.uuid===e&&(this.copied={},$clipboard.clear()),this.updateListBackground()}catch(e){$ui.alert(e)}}update(e,t,i){return!!super.update(e,t,i)&&(this.updateList(),e===this.copied.uuid&&(this.setClipboardText(t),this.updateCopied({text:t})),!0)}move(e,t,i=!0){if(e!==t)try{if(super.move(e,t),!i)return;const r=$(this.listId);ee&&this.copied.rowt||this.copied.row===t)&&this.setCopied(this.copied.uuid,e{i.text?$share.sheet(i.text):$ui.warning($l10n(\"NONE\"))}}];if(this.kernel.isUseJsboxNav)i.uikitPush(e,(e=>t(e)),r);else{const s=i.getNavigationView(e,(e=>t(e)),r);this.viewController.push(s)}}getAddTextView(){this.edit(\"\",(e=>{\"\"!==e&&this.add(e)}))}menuItems(e=!1){const t=[{inline:!0,items:[{title:$l10n(\"TAG\"),symbol:\"tag\",handler:(e,t)=>{const i=this.clips[t.row].uuid;$input.text({placeholder:$l10n(\"ADD_TAG\"),text:e.text,handler:e=>{(e=e.trim()).length>0?this.kernel.storage.setTag(i,e):this.kernel.storage.deleteTag(i),this.updateList(!0)}})}}]},{inline:!0,items:[{title:$l10n(\"SHARE\"),symbol:\"square.and.arrow.up\",handler:(e,t)=>{const i=this.clips[t.row].text;let r=i;const s=this.kernel.storage.keyToPath(i);if(s&&this.kernel.fileStorage.exists(s.original)){const e=this.kernel.fileStorage.readSync(s.original)?.image?.png;r={name:e.fileName,data:e}}$share.sheet([r])}},{title:$l10n(\"COPY\"),symbol:\"square.on.square\",handler:(e,t)=>{const i=this.clips[t.row];this.copy(i.text,i.uuid,t.row)}},{title:$l10n(\"DELETE\"),symbol:\"trash\",destructive:!0,handler:(e,t)=>{this.kernel.deleteConfirm($l10n(\"CONFIRM_DELETE_MSG\"),(()=>{const i=this.clips[t.row];this.delete(i.uuid,t.row),e.delete(t)}))}}]}];if(e)return t;const i=e=>{const t=this.kernel.actionManager.getActionHandler(e.type,e.dir);return e.handler=(e,i)=>{const r=this.clips[i.row],s=new y({env:b.clipboard,text:r.text,uuid:r.uuid});t(s)},e.title=e.name,e.symbol=e.icon,e},r=this.kernel.actionManager.getActions(\"clipboard\"),s={inline:!0,items:r.slice(0,this.menuItemActionMaxCount).map(i)};return r.length>this.menuItemActionMaxCount&&s.items.push({title:$l10n(\"MORE_ACTIONS\"),symbol:\"square.grid.2x2\",items:r.slice(this.menuItemActionMaxCount).map(i)}),[s,...t]}switchTab(e,t=!1){this.tabIndex=e,this.updateList(),t&&($(this.listId+\"-tab\").index=this.tabIndex)}tabView(){return{type:\"tab\",props:{id:this.listId+\"-tab\",items:this.tabItems,index:this.tabIndex,dynamicWidth:!0},events:{changed:e=>this.switchTab(e.index)},layout:(e,t)=>{e.centerY.equalTo(t.super),t.prev?e.left.equalTo(t.prev.right).offset(this.tabLeftMargin):e.left.inset(this.tabLeftMargin)}}}lineData(e,t=!1){const i={hidden:!0},r={text:\"\"},s=this.kernel.storage.keyToPath(e.text);return s?(i.src=s.preview,i.hidden=!1):r.text=e.text,{copied:{hidden:!t},image:i,tag:{text:e.tag},content:r}}listTemplate(){return{props:{bgcolor:$color(\"clear\")},views:[{type:\"view\",views:[{type:\"view\",props:{id:\"copied\",circular:this.copiedIndicatorSize,hidden:!0,bgcolor:$color(\"green\")},layout:(e,t)=>{e.centerY.equalTo(t.super),e.size.equalTo(this.copiedIndicatorSize),e.left.equalTo(t.super).inset(this.horizontalMargin/2-this.copiedIndicatorSize/2)}},{type:\"label\",props:{id:\"content\",lines:this.#Y?1:2,font:$font(this.fontSize)},layout:(e,t)=>{e.left.right.equalTo(t.super).inset(this.horizontalMargin),this.#Y?e.top.inset(this.imageContentHeight/2):e.top.inset(this.verticalMargin)}},{type:\"image\",props:{id:\"image\",hidden:!0},layout:$layout.fill}],layout:$layout.fill},{type:\"label\",props:{id:\"tag\",color:$color(\"systemGray2\"),font:$font(this.tagFontSize)},layout:(e,t)=>{e.bottom.width.equalTo(t.super),e.left.inset(this.horizontalMargin),e.height.equalTo(this.tagContainerHeight)}}]}}getListView(e=this.listId,t=[]){const i={type:\"list\",props:{id:e,associateWithNavigationBar:!1,bgcolor:$color(\"clear\"),separatorInset:$insets(0,this.horizontalMargin,0,0),menu:{items:this.menuItems()},data:t,template:this.listTemplate(),actions:[{title:$l10n(\"COPY\"),color:$color(\"systemLink\"),handler:(e,t)=>{const i=this.clips[t.row];this.copy(i.text,i.uuid,t.row)}},{title:$l10n(\"FAVORITE\"),color:$color(\"orange\"),handler:(e,t)=>{const i=this.clips[t.row];this.favorite(i,t.row)}}]},layout:$layout.fill,events:{ready:()=>this.listReady(),rowHeight:(e,t)=>{const i=e.object(t),r=i.tag.text?this.tagContainerHeight:this.verticalMargin;return(this.kernel.storage.isImage(i.content.text)?this.imageContentHeight:this.getTextHeight(i.content.text))+this.verticalMargin+r},didSelect:(e,t,i)=>{const r=this.clips[t.row],s=r.text,a=this.kernel.storage.keyToPath(s);a&&this.kernel.fileStorage.exists(a.original)?$quicklook.open({image:this.kernel.fileStorage.readSync(a.original)?.image}):this.edit(r.text,(e=>{r.md5!==$text.MD5(e)&&this.update(r.uuid,e,t.row)}))},pulled:e=>{this.updateList(!0),$delay(.5,(()=>e.endRefreshing()))}}},s={type:\"label\",props:{id:e+\"-empty-list-background\",color:$color(\"secondaryText\"),hidden:this.clips.length>0,text:$l10n(\"NONE\"),align:$align.center},layout:$layout.center};return r.createFromViews([i,s])}getNavigationView(){const e=this.tabView();e.type=\"menu\",e.layout=(e,t)=>{e.top.left.right.equalTo(t.super),e.height.equalTo(this.tabHeight)};const t=this.getListView();t.views.unshift(e),t.views[1].layout=(e,t)=>{e.bottom.left.right.equalTo(t.super),e.top.equalTo(t.prev.bottom)},t.views.push(this.search.getSearchHistoryView());const i=(new l).navigationBarTitle($l10n(\"CLIPS\")).setView(t);return i.navigationBarItems.setTitleView(this.search.getSearchBarView()).pinTitleView().setRightButtons([{symbol:\"plus.circle\",tapped:()=>this.getAddTextView()}]).setLeftButtons([{title:$l10n(\"EDIT\"),tapped:()=>{new g(this).presentSheet()}},{symbol:\"square.and.arrow.down.on.square\",tapped:e=>{e.start(),this.readClipboard(!0),e.done()}}]),i.navigationBar.setBackgroundColor(a.primaryViewBackgroundColor).setLargeTitleDisplayMode(c.largeTitleDisplayModeNever),this.kernel.isUseJsboxNav&&i.navigationBar.removeTopSafeArea(),i}}})),parcelRequire.register(\"f0nX9\",(function(e,t){var i=parcelRequire(\"gxpqj\"),r=i.UIKit,s=i.NavigationBar,a=i.NavigationView,n=i.Sheet,o=parcelRequire(\"eSp9Z\"),l=o.ActionEnv,c=o.ActionData;e.exports=class{#J=\"\";constructor(e){this.kernel=e,this.id=\"editor\",this.originalContent=void 0}set text(e=\"\"){void 0===this.originalContent&&(this.originalContent=e),this.#J=e}get text(){return this.#J}getActionButton(){return{symbol:\"bolt.circle\",tapped:(e,t)=>{t&&(e=t);const i=$(this.id).selectedRange,r=new c({env:l.editor,editor:{setContent:e=>this.setContent(e)},text:i.length>0?this.text.slice(i.location,i.location+i.length):this.text,selectedRange:i}),s=$ui.popover({sourceView:e,directions:$popoverDirection.up,size:$size(200,300),views:[this.kernel.actionManager.getActionListView((e=>{s.dismiss(),$delay(.5,(()=>e(r)))}))]})}}}setContent(e){this.text=e,$(this.id).text=e}getView(e=\"text\"){return{type:e,layout:$layout.fill,props:{id:this.id,lineNumbers:this.kernel.setting.get(\"editor.code.lineNumbers\"),theme:this.kernel.setting.get($device.isDarkMode?\"editor.code.darkTheme\":\"editor.code.lightTheme\"),text:this.text,insets:$insets(15,15,\"text\"===e?this.kernel.setting.get(\"editor.text.insets\"):15,15)},events:{ready:e=>{\"\"===this.text&&setTimeout((()=>e.focus()),500)},didChange:e=>{this.text=e.text}}}}pageSheet(e=\"\",t,i,r=[],s=\"text\"){this.text=e,r.unshift(this.getActionButton());const a=new n;a.setView(this.getView(s)).addNavBar({title:i,popButton:{title:$l10n(\"DONE\"),tapped:()=>t(this.text)},rightButtons:r}),a.navigationView.navigationBar.contentViewHeightOffset=0,a.init().present()}uikitPush(e=\"\",t,i=[],s=\"text\"){this.text=e,i.unshift(this.getActionButton()),r.push({title:\"\",navButtons:i.map((e=>(e.handler=e.tapped,e.tapped=void 0,e))),views:[this.getView(s)],disappeared:()=>t(this.text)})}getNavigationView(e=\"\",t,i=[],r=\"text\"){this.text=e,i.unshift(this.getActionButton());const n=new a;return n.navigationBar.contentViewHeightOffset=0,n.navigationBar.setLargeTitleDisplayMode(s.largeTitleDisplayModeNever),n.navigationBarItems.setRightButtons(i),n.setView(this.getView(r)).navigationBarTitle(\"\"),n.setEvent(\"onPop\",(()=>t(this.text))),n}}})),parcelRequire.register(\"eSp9Z\",(function(e,t){var i=parcelRequire(\"gxpqj\"),r=i.Kernel,s=i.Sheet;class a{static keyboard=0;static today=0;static editor=1;static clipboard=2;static action=3}e.exports={ActionEnv:a,ActionData:class{env;args;text;originalContent;uuid;selectedRange;textBeforeInput;textAfterInput;editor;constructor({env:e,args:t,text:i,uuid:r=null,selectedRange:s=null,textBeforeInput:a=null,textAfterInput:n=null,editor:o=null}={}){this.env=e,this.args=t,this.text=i,this.originalContent=i,this.uuid=r,this.selectedRange=s,this.textBeforeInput=a,this.textAfterInput=n,this.editor=o}},Action:class{#X;constructor(e,t,i){this.#X=e,this.config=t,Object.assign(this,i),this.originalContent=this.text;const s=this.l10n();Object.keys(s).forEach((e=>{r.l10n(e,s[e])}))}l10n(){return{}}pageSheet({view:e,title:t=\"\",done:i,doneText:r=$l10n(\"DONE\"),rightButtons:a=[]}){(new s).setView(e).addNavBar({title:t,popButton:{title:r,tapped:()=>{i&&i()}},rightButtons:a}).init().present()}getAllClips(){return{favorite:this.#X.storage.all(\"favorite\").map((e=>e.text)),clips:this.#X.storage.all(\"clips\").map((e=>e.text))}}async clearAllClips(){if(0!==(await $ui.alert({title:$l10n(\"DELETE_DATA\"),message:$l10n(\"DELETE_TABLE\").replace(\"${table}\",$l10n(\"CLIPS\")),actions:[{title:$l10n(\"DELETE\"),style:$alertActionType.destructive},{title:$l10n(\"CANCEL\")}]})).index)return!1;try{return this.#X.storage.deleteTable(\"clips\"),!0}catch(e){throw this.#X.error(e),e}}setContent(e){this.text=e,this.env===a.editor&&this.editor.setContent(e)}getAction(e,t,i){return this.#X.actionManager.getAction(e,t,i)}async runAction(e,t){const i=this.getAction(e,t);return await i.do()}async request(e,t,i={},r={}){try{this.#X.print(`sending request [${t}]: ${e}`);const s=await $http.request({header:r,url:e,method:t,body:i,timeout:5});if(s.error)throw s.error;if(s?.response?.statusCode>=400){let e=s.data;throw\"object\"==typeof e&&(e=JSON.stringify(e)),new Error(\"http error: [\"+s.response.statusCode+\"] \"+e)}return s}catch(e){throw e.code&&(e=new Error(\"network error: [\"+e.code+\"] \"+e.localizedDescription)),e}}getUrls(){return(this.text??\"\").match(/(https?:\\/\\/)([\\da-z\\.-]+)\\.([a-z\\.]{2,6})([:0-9])*([\\/\\w\\#\\.\\-\\?\\=\\&])*\\s?/gi)??[]}}}})),parcelRequire.register(\"ZnuTV\",(function(e,t){var i=parcelRequire(\"gxpqj\").UIKit;e.exports=class{kernel;pasteboard=$objc(\"UIPasteboard\").$generalPasteboard();#Q=[];savedClipboardIndex={};tabItems=[$l10n(\"FAVORITE\"),$l10n(\"CLIPS\")];tabItemsIndex=[\"favorite\",\"clips\"];constructor(e){this.kernel=e}set tabIndex(e){$cache.set(\"caio.main.tab.index\",e)}get tabIndex(){return $cache.get(\"caio.main.tab.index\")??0}get table(){return this.tabItemsIndex[this.tabIndex]}get tableL10n(){return this.tabItems[this.tabIndex]}get allClips(){return 0===this.#Q.length&&this.loadAllClips(),this.#Q}set allClips(e){this.#Q=e.map((e=>new Proxy(e??[],{set:(e,t,i)=>Reflect.set(e,t,i),get:(e,t)=>Reflect.get(e,t)})))}get clips(){return this.allClips[this.tabIndex]}get isChanged(){const e=this.pasteboard.$changeCount(),t=$cache.get(\"clipboard.changeCount\");return $cache.set(\"clipboard.changeCount\",e),t!==e}getRowByUUID(e){let t=this.clips.length;for(let i=0;i{const i=JSON.parse(JSON.stringify(e));return Object.assign(i,t)},r=this.table;this.clips[t]||(this.clips[t]={uuid:null,text:\"\",next:null,prev:this.clips[t-1].uuid});try{this.kernel.storage.beginTransaction();const s=i(this.clips[e]),a=i(this.clips[t]);if(this.clips[e-1]){const t=i(this.clips[e-1],{next:this.clips[e].next});this.kernel.storage.update(r,t),this.clips[e-1]=t}if(this.clips[e+1]){const t=i(this.clips[e+1],{prev:this.clips[e].prev});this.kernel.storage.update(r,t),this.clips[e+1]=t}if(this.clips[t-1]){const s=i(this.clips[t-1],{next:this.clips[e].uuid});this.kernel.storage.update(r,s),this.clips[t-1]=s}const n=i(a,{prev:s.uuid,next:this.clips[t].next});this.kernel.storage.update(r,n);const o=i(s,{prev:this.clips[t].prev,next:a.uuid});this.kernel.storage.update(r,o),this.clips[t]=n,this.clips[e]=o,this.clips.splice(t,0,this.clips[e]),this.clips.splice(e>t?e+1:e,1),this.kernel.storage.commit()}catch(e){throw this.kernel.error(e),this.kernel.storage.rollback(),e}finally{null===this.clips[t].uuid&&this.clips.splice(t,1)}}favorite(e,t){e.next=this.allClips[0][0]?.uuid??null,e.prev=null;try{this.kernel.storage.beginTransaction(),this.kernel.storage.insert(\"favorite\",e),e.next&&(this.allClips[0][0].prev=e.uuid,this.kernel.storage.update(\"favorite\",this.allClips[0][0])),this.kernel.storage.commit(),\"favorite\"!==e?.section&&(e.section=\"favorite\",this.delete(e.uuid,t)),this.allClips[0].unshift(e),this.savedClipboardIndex[e.md5]=1}catch(e){throw this.kernel.error(e),this.kernel.storage.rollback(),e}}loadAllClips(){this.kernel.print(\"load all clips\");const e=e=>{try{return this.kernel.storage.sort(e,this.kernel.setting.get(\"clipboard.maxItemLength\")).map((e=>(this.savedClipboardIndex[e.md5]=1,e)))}catch(e){$ui.alert({title:$l10n(\"REBUILD_DATABASE\"),message:$l10n(\"CLIPS_STRUCTURE_ERROR\"),actions:[{title:$l10n(\"OK\"),handler:()=>{const e=i.loading();e.start(),this.kernel.storage.rebuild(),e.end(),$delay(.8,(()=>$addin.restart()))}},{title:$l10n(\"CANCEL\")}]}),this.kernel.error(e)}};this.allClips=[e(this.kernel.storage.all(this.tabItemsIndex[0])),e(this.kernel.storage.all(this.tabItemsIndex[1]))]}}})),parcelRequire.register(\"ay4Kj\",(function(e,t){var i=parcelRequire(\"gxpqj\"),r=i.UIKit,s=i.SearchBar;e.exports=class{listId=\"clips-list-search\";kernel;callback=()=>{};onBegin=()=>{};onDismiss=()=>{};constructor(e){this.kernel=e,this.searchBar=new s,this.searchBarId=this.searchBar.id+\"-input\"}get searchHistoryView(){return{hide:()=>$(this.listId+\"-history\").hidden=!0,show:()=>$(this.listId+\"-history\").hidden=!1}}get searchHistory(){return[{title:$l10n(\"SEARCH_HISTORY\"),rows:$cache.get(\"caio.search.history\")?.reverse()??[]}]}getAccessoryView(){return r.blurBox({height:50},[{type:\"button\",props:{bgcolor:$color(\"clear\"),tintColor:$color(\"primaryText\"),symbol:\"xmark.circle\"},layout:(e,t)=>{e.right.inset(0),e.height.equalTo(t.super),e.width.equalTo(t.super.height)},events:{tapped:()=>this.dismiss()}},{type:\"button\",props:{bgcolor:$color(\"clear\"),tintColor:$color(\"primaryText\"),symbol:\"keyboard.chevron.compact.down\"},layout:(e,t)=>{e.right.equalTo(t.prev.left),e.height.equalTo(t.super),e.width.equalTo(t.super.height)},events:{tapped:()=>$(this.searchBarId).blur()}}])}getSearchHistoryView(){return{type:\"list\",props:{id:this.listId+\"-history\",hidden:!0,stickyHeader:!0,data:this.searchHistory,separatorInset:$insets(0,13,0,0),actions:[{title:$l10n(\"DELETE\"),handler:(e,t)=>{const i=e.data;this.updateSearchHistory(i[0].rows.reverse())}}]},events:{didSelect:(e,t,i)=>{this.searchAction(i),$(this.searchBarId).text=i}},layout:$layout.fill}}setCallback(e){this.callback=e}setOnBegin(e){this.onBegin=e}setOnDismiss(e){this.onDismiss=e}begin(){this.searchHistoryView.show(),this.onBegin()}dismiss(){$(this.searchBarId).blur(),$(this.searchBarId).text=\"\",this.searchHistoryView.hide(),this.onDismiss()}searchAction(e){try{if(\"\"!==e){const t=this.kernel.storage.search(e);t&&t.length>0?($(this.searchBarId).blur(),this.callback(t)):$ui.toast($l10n(\"NO_SEARCH_RESULT\")),this.pushSearchHistory(e)}}catch(e){throw e}}pushSearchHistory(e){let t=$cache.get(\"caio.search.history\")??[];-1===t.indexOf(e)&&(t.push(e),t.length>20&&(t=t.slice(-20)),$(this.listId+\"-history\").data=this.searchHistory,$cache.set(\"caio.search.history\",t))}updateSearchHistory(e=[]){$cache.set(\"caio.search.history\",e)}getSearchBarView(){return this.searchBar.controller.setEvent(\"onReturn\",(e=>{\"\"!==e?this.searchAction(e):this.searchHistoryView.show()})),this.searchBar.controller.setEvent(\"onChange\",(e=>{\"\"===e&&this.searchHistoryView.show()})),this.searchBar.setEvent(\"didBeginEditing\",(e=>{\"\"===e.text&&this.begin()})),this.searchBar.setAccessoryView(this.getAccessoryView()),this.searchBar}}})),parcelRequire.register(\"9LqeL\",(function(e,t){var i=parcelRequire(\"gxpqj\"),r=i.View,s=i.UIKit,a=i.Sheet;class n{static symbol={selected:\"checkmark.circle.fill\",unselected:\"circle\"};listId=\"clips-list-editor\";reorder={};toolBarHeight=44;#Z=void 0;#ee={};constructor(e){this.clipsInstance=e,this.kernel=e.kernel}get editorSelectedIsEmpty(){let e=!0;const t=this.editorSelected;for(const i of Object.keys(t))if(t[i]){e=!1;break}return e}get editorSelectedIsFull(){let e=0,t=0;const i=this.editorSelected;for(const r of Object.keys(i))++t,i[r]&&++e;return t===e}get editorSelected(){return void 0===this.#Z&&(Array(this.clipsInstance.clips.length).fill(0).map(((e,t)=>this.#ee[t]=!1)),this.#Z=new Proxy(this.#ee,{set:(e,t,i,r)=>{Reflect.set(e,t,i,r),t=Number(t);const s=this.editorSelectedIsEmpty,a=$(this.listId+\"-select-button\"),o=$(this.listId+\"-delete-button\");a.title=this.editorSelectedIsFull?$l10n(\"DESELECT_ALL\"):$l10n(\"SELECT_ALL\"),o.hidden=s;const l=$(this.listId);return l.data=this.clipsInstance.clips.map(((t,i)=>{const r=this.lineData(t);return r.checkmark={symbol:e[i]?n.symbol.selected:n.symbol.unselected},r})),l.reorder=s,!0}})),this.#Z}set editorSelected(e){this.#Z=e}selectAll(){const e=this.editorSelectedIsFull;this.clipsInstance.clips.forEach(((t,i)=>{this.editorSelected[i]=!e}))}deleteSelected(){this.kernel.deleteConfirm($l10n(\"CONFIRM_DELETE_MSG\"),(()=>{const e=$(this.listId),t=$(this.clipsInstance.listId);Object.keys(this.editorSelected).reverse().forEach((i=>{if(this.editorSelected[i]){i=Number(i);const r=this.clipsInstance.clips[i];this.kernel.print(`delete selected: [${i}]\\n${r.text}`),this.clipsInstance.delete(r.uuid,i),t.delete(i),e.delete(i)}}))}))}getToolBarView(){return s.blurBox({},[s.separatorLine(),{type:\"view\",views:[{type:\"button\",props:{id:this.listId+\"-select-button\",title:$l10n(\"SELECT_ALL\"),titleColor:$color(\"tint\"),bgcolor:$color(\"clear\")},layout:(e,t)=>{e.left.inset(this.clipsInstance.horizontalMargin),e.centerY.equalTo(t.super)},events:{tapped:()=>this.selectAll()}},{type:\"button\",props:{id:this.listId+\"-delete-button\",symbol:\"trash\",hidden:!0,tintColor:$color(\"red\"),bgcolor:$color(\"clear\")},layout:(e,t)=>{e.right.inset(this.clipsInstance.horizontalMargin),e.centerY.equalTo(t.super)},events:{tapped:()=>this.deleteSelected()}}],layout:(e,t)=>{e.left.right.top.equalTo(t.super),e.bottom.equalTo(t.super.safeAreaBottom)}}],((e,t)=>{e.left.right.bottom.equalTo(t.super),e.top.equalTo(t.super.safeAreaBottom).offset(-this.toolBarHeight)}))}lineData(e){const t=this.clipsInstance.lineData(e);return t.checkmark={symbol:n.symbol.unselected},t}listTemplate(){const e=this.clipsInstance.listTemplate();return e.views[0].layout=(e,t)=>{e.height.right.equalTo(t.super),e.left.inset(30)},e.views.push({type:\"image\",props:{id:\"checkmark\",symbol:n.symbol.unselected,contentMode:$contentMode.scaleAspectFit},layout:(e,t)=>{e.centerY.equalTo(t.super),e.left.inset(15),e.size.equalTo($size(25,25))}}),e}getListEditerView(){return{type:\"list\",props:{id:this.listId,bgcolor:s.primaryViewBackgroundColor,separatorInset:$insets(0,this.clipsInstance.horizontalMargin,0,0),indicatorInsets:$insets(0,0,this.toolBarHeight,0),data:this.clipsInstance.clips.map((e=>this.lineData(e))),template:this.listTemplate(),reorder:!0,footer:{height:this.toolBarHeight},crossSections:!1},events:{rowHeight:(e,t)=>{const i=this.clipsInstance.clips[t.row].text;return(this.kernel.storage.isImage(i)?this.imageContentHeight:this.clipsInstance.getTextHeight(i))+2*this.clipsInstance.verticalMargin},reorderBegan:e=>{this.reorder.began=!0,this.reorder.from=e.row,this.reorder.to=void 0},reorderMoved:(e,t)=>{this.reorder.to=t.row},reorderFinished:()=>{this.reorder.began=!1,void 0!==this.reorder.to&&this.clipsInstance.move(this.reorder.from,this.reorder.to)},didSelect:(e,t,i)=>{this.editorSelected[t.row]=!this.editorSelected[t.row]}},layout:$layout.fill}}presentSheet(){const e=new a;e.setView(r.createFromViews([this.getListEditerView(),this.getToolBarView()])).addNavBar({title:\"\",popButton:{title:$l10n(\"CLOSE\")},rightButtons:[{title:$l10n(\"CLEAR\"),color:$color(\"red\"),tapped:async()=>{if(0===(await $ui.alert({title:$l10n(\"DELETE_DATA\"),message:$l10n(\"DELETE_TABLE\").replace(\"${table}\",this.clipsInstance.tableL10n),actions:[{title:$l10n(\"DELETE\"),style:$alertActionType.destructive},{title:$l10n(\"CANCEL\")}]})).index)try{this.kernel.storage.deleteTable(this.clipsInstance.table),e.dismiss(),this.clipsInstance.updateList(!0)}catch(e){this.kernel.error(e),$ui.error(e)}}}]}).init().present()}}e.exports=n})),parcelRequire.register(\"44eiF\",(function(e,t){var i=parcelRequire(\"gxpqj\"),r=i.Matrix,s=i.Setting,a=i.NavigationView,n=i.BarButtonItem,o=i.Sheet,l=i.UIKit,c=parcelRequire(\"f0nX9\"),h=parcelRequire(\"47XCm\"),d=parcelRequire(\"eSp9Z\"),p=d.ActionEnv,u=d.ActionData;e.exports=class extends h{matrix;reorder={};addActionButtonId=\"action-manager-button-add\";syncLabelId=\"action-manager-sync-label\";get actionList(){return super.actions.map((e=>{const t=[];return e.items.forEach((e=>{t.push(this.actionToData(e))})),{title:e.title,items:t,rows:t}}))}actionSyncStatus(){$app.listen({actionSyncStatus:e=>{if(e.status===h.syncStatus.syncing)this.undateAddActionButton(!0),this.undateSyncLabel($l10n(\"SYNCING\"));else if(e.status===h.syncStatus.success)try{this.matrix.update(this.actionList)}catch(e){this.kernel.error(e),this.undateSyncLabel(e),$ui.error(e)}finally{this.undateSyncLabel(),this.undateAddActionButton(!1)}}})}editActionInfoPageSheet(e,t){const i=this.getActionTypes(),r={};i.forEach(((e,t)=>{r[e]=t}));const a=!Boolean(e);a?this.editingActionInfo={type:\"clipboard\",name:\"MyAction\",color:\"#CC00CC\",icon:\"icon_062.png\",readme:\"\"}:(this.editingActionInfo=e,this.editingActionInfo.readme=this.getActionReadme(e.type,e.dir));const n=new s({structure:{},set:(e,t)=>(this.editingActionInfo[e]=\"type\"===e?t[1]:t,!0),get:(e,t=null)=>\"type\"===e?r[this.editingActionInfo.type]:Object.prototype.hasOwnProperty.call(this.editingActionInfo,e)?this.editingActionInfo[e]:t}),l=n.createInput(\"name\",[\"pencil.circle\",\"#FF3366\"],$l10n(\"NAME\")),c=n.createColor(\"color\",[\"pencil.tip.crop.circle\",\"#0066CC\"],$l10n(\"COLOR\")),h=n.createIcon(\"icon\",[\"star.circle\",\"#FF9933\"],$l10n(\"ICON\"),this.kernel.setting.getColor(this.editingActionInfo.color)),d=n.createMenu(\"type\",[\"tag.circle\",\"#33CC33\"],$l10n(\"TYPE\"),i,!0),p={type:\"view\",views:[{type:\"text\",props:{id:\"action-text\",textColor:$color(\"#000000\",\"secondaryText\"),bgcolor:$color(\"systemBackground\"),text:this.editingActionInfo.readme,insets:$insets(10,10,10,10)},layout:$layout.fill,events:{tapped:e=>{$(\"actionInfoPageSheetList\").scrollToOffset($point(0,a?280:230)),$delay(.2,(()=>e.focus()))},didChange:e=>{this.editingActionInfo.readme=e.text}}}],layout:$layout.fill},u=[{title:$l10n(\"INFORMATION\"),rows:[l,c,h]},{title:$l10n(\"DESCRIPTION\"),rows:[p]}];a&&(u[0].rows=u[0].rows.concat(d));(new o).setView({type:\"list\",props:{id:\"actionInfoPageSheetList\",bgcolor:$color(\"insetGroupedBackground\"),style:2,separatorInset:$insets(0,50,0,10),data:u},layout:$layout.fill,events:{rowHeight:(e,t)=>1===t.section?120:50}}).addNavBar({title:\"\",popButton:{title:$l10n(\"DONE\"),tapped:()=>{this.editingActionInfo.dir||(this.editingActionInfo.dir=$text.MD5(this.editingActionInfo.name)),this.saveActionInfo(this.editingActionInfo),t&&t(this.editingActionInfo)}}}).init().present()}editActionMainJs(e=\"\",t){new c(this.kernel).pageSheet(e,(e=>{this.saveMainJs(t,e)}),t.name,[{symbol:\"book.circle\",tapped:()=>{const e=$file.read(\"scripts/action/README.md\").string;(new o).setView({type:\"markdown\",props:{content:e},layout:(e,t)=>{e.size.equalTo(t.super)}}).init().present()}}],\"code\")}move(e,t){if(e.section===t.section&&e.row===t.row)return;super.move(e,t);const i=this.matrix,r=this.actionToData(this.actions[t.section].items[t.row]);e.row{const i=e.cell(t),r=i.get(\"info\").info;this.editActionInfoPageSheet(r,(e=>{i.get(\"info\").info=e,i.get(\"color\").bgcolor=this.kernel.setting.getColor(e.color),i.get(\"name\").text=e.name,\"icon_\"===e.icon.slice(0,5)?i.get(\"icon\").icon=$icon(e.icon.slice(5,e.icon.indexOf(\".\")),$color(\"#ffffff\")):i.get(\"icon\").image=$image(e.icon)}))}},{title:$l10n(\"EDIT_SCRIPT\"),symbol:\"square.and.pencil\",handler:(e,t,i)=>{const r=i.info.info;if(!r)return;const s=`${this.userActionPath}/${r.type}/${r.dir}/main.js`,a=$file.read(s).string;this.editActionMainJs(a,r)}},{inline:!0,items:[{title:\"README\",symbol:\"book\",handler:(e,t)=>{const i=e.cell(t).get(\"info\").info;let r;try{r=__ACTIONS__[i.type][i.dir][\"README.md\"]}catch{r=this.getActionReadme(i.type,i.dir)}(new o).setView({type:\"markdown\",props:{content:r},layout:(e,t)=>{e.size.equalTo(t.super)}}).init().present()}}]},{inline:!0,items:[{title:$l10n(\"DELETE\"),symbol:\"trash\",destructive:!0,handler:(e,t,i)=>{this.kernel.deleteConfirm($l10n(\"CONFIRM_DELETE_MSG\"),(()=>{this.delete(i.info.info),e.delete(t)}))}}]}]}getNavButtons(){return[{symbol:\"plus.circle\",id:this.addActionButtonId,menu:{pullDown:!0,asPrimary:!0,items:[{title:$l10n(\"CREATE_NEW_ACTION\"),handler:()=>{this.editActionInfoPageSheet(null,(e=>{this.matrix.insert({indexPath:$indexPath(this.getActionTypes().indexOf(e.type),0),value:this.actionToData(e)});const t=$file.read(`${this.actionPath}/template.js`).string;this.saveMainJs(e,t),this.editActionMainJs(t,e)}))}},{title:$l10n(\"CREATE_NEW_TYPE\"),handler:()=>{$input.text({text:\"\",placeholder:$l10n(\"CREATE_NEW_TYPE\"),handler:e=>{if(\"\"===(e=e.trim()))return void $ui.toast($l10n(\"INVALID_VALUE\"));const t=`${this.userActionPath}/${e}`;$file.isDirectory(t)?$ui.warning($l10n(\"TYPE_ALREADY_EXISTS\")):($file.mkdir(t),$ui.success($l10n(\"SUCCESS\")))}})}}]}},{symbol:\"arrow.up.arrow.down.circle\",tapped:(e,t)=>{$ui.popover({sourceView:t,directions:$popoverDirection.up,size:$size(200,300),views:[this.getActionListView(void 0,{reorder:!0,actions:[{title:\"delete\",handler:(e,t)=>{const i=this.matrix,r=i.object(t,!1).info.info;this.delete(r),i.delete(t,!1)}}]},{reorderBegan:e=>{this.reorder.from=e,this.reorder.to=void 0},reorderMoved:(e,t)=>{this.reorder.to=t},reorderFinished:e=>{void 0!==this.reorder.to&&this.move(this.reorder.from,this.reorder.to,e)}})]})}}]}actionToData(e){return{name:{text:e.name},icon:\"icon_\"===e.icon.slice(0,5)?{icon:$icon(e.icon.slice(5,e.icon.indexOf(\".\")),$color(\"#ffffff\"))}:{image:$image(e.icon)},color:{bgcolor:this.kernel.setting.getColor(e.color)},info:{info:e}}}undateSyncLabel(e){e||(e=$l10n(\"LAST_SYNC_AT\")+this.getSyncDate().toLocaleString()),$(this.syncLabelId)&&($(this.syncLabelId).text=e)}undateAddActionButton(e){const t=this.navigationView?.navigationBarItems?.getButton(this.addActionButtonId)??{};t&&t.setLoading(e)}getActionListView(e,t={},i={}){return e&&(i.didSelect=(t,i,r)=>{const s=r.info.info,a=this.kernel.actionManager.getActionHandler(s.type,s.dir);e(a)}),{type:\"list\",layout:(e,t)=>{e.top.width.equalTo(t.super.safeArea),e.bottom.inset(0)},events:i,props:Object.assign({reorder:!1,bgcolor:$color(\"clear\"),rowHeight:60,sectionTitleHeight:30,stickyHeader:!0,data:this.actionList,template:{props:{bgcolor:$color(\"clear\")},views:[{type:\"image\",props:{id:\"color\",cornerRadius:8,smoothCorners:!0},layout:(e,t)=>{e.centerY.equalTo(t.super),e.left.inset(15),e.size.equalTo($size(30,30))}},{type:\"image\",props:{id:\"icon\",tintColor:$color(\"#ffffff\")},layout:(e,t)=>{e.centerY.equalTo(t.super),e.left.inset(20),e.size.equalTo($size(20,20))}},{type:\"label\",props:{id:\"name\",lines:1,font:$font(16)},layout:(e,t)=>{e.height.equalTo(30),e.centerY.equalTo(t.super),e.left.equalTo(t.prev.right).offset(15)}},{type:\"label\",props:{id:\"info\"}}]}},t)}}getMatrixView({columns:e=2,spacing:t=15,itemHeight:i=100}={}){return this.matrix=r.create({type:\"matrix\",props:{columns:e,itemHeight:i,spacing:t,bgcolor:l.scrollViewBackgroundColor,menu:{items:this.menuItems()},data:this.actionList,template:{props:{smoothCorners:!0,cornerRadius:10,bgcolor:$color(\"#ffffff\",\"#242424\")},views:[{type:\"image\",props:{id:\"color\",cornerRadius:8,smoothCorners:!0},layout:e=>{e.top.left.inset(10),e.size.equalTo($size(30,30))}},{type:\"image\",props:{id:\"icon\",tintColor:$color(\"#ffffff\")},layout:e=>{e.top.left.inset(15),e.size.equalTo($size(20,20))}},{type:\"button\",props:{bgcolor:$color(\"clear\"),tintColor:l.textColor,titleColor:l.textColor,contentEdgeInsets:$insets(0,0,0,0),titleEdgeInsets:$insets(0,0,0,0),imageEdgeInsets:$insets(0,0,0,0)},views:[{type:\"image\",props:{symbol:\"ellipsis.circle\"},layout:(e,t)=>{e.center.equalTo(t.super),e.size.equalTo(n.style.iconSize)}}],events:{tapped:e=>{const t=e.next.info;if(!t)return;const i=`${this.userActionPath}/${t.type}/${t.dir}/main.js`,r=$file.read(i).string;this.editActionMainJs(r,t)}},layout:e=>{e.top.right.inset(0),e.size.equalTo(n.style.width)}},{type:\"view\",props:{id:\"info\",hidden:!0}},{type:\"label\",props:{id:\"name\",font:$font(16)},layout:(e,t)=>{e.bottom.left.inset(10),e.width.equalTo(t.super)}}]},footer:{type:\"view\",props:{hidden:!this.kernel.setting.get(\"experimental.syncAction\"),height:this.kernel.setting.get(\"experimental.syncAction\")?50:0},views:[{type:\"label\",props:{id:this.syncLabelId,color:$color(\"secondaryText\"),font:$font(12),text:$l10n(\"LAST_SYNC_AT\")+this.getSyncDate().toLocaleString()},layout:(e,i)=>{e.size.equalTo(i.super),e.top.inset(-30),e.left.inset(t)}}]}},layout:$layout.fill,events:{didSelect:(e,t,i)=>{const r=i.info.info,s=new u({env:p.action,text:\"clipboard\"===r.type||\"uncategorized\"===r.type?$clipboard.text:null});this.getActionHandler(r.type,r.dir)(s)},pulled:e=>{$delay(.5,(async()=>{this.undateAddActionButton(!0),await this.sync(),this.actionsNeedReload(),this.matrix.update(this.actionList),this.undateSyncLabel(),this.undateAddActionButton(!1),e.endRefreshing()}))}}}),this.actionSyncStatus(),this.matrix.definition}getPage(){return this.navigationView=new a,this.navigationView.navigationBarItems.setRightButtons(this.getNavButtons()),this.navigationView.setView(this.getMatrixView()).navigationBarTitle($l10n(\"ACTIONS\")),this.navigationView.getPage()}present(){const e=new o,t=this.getNavButtons();this.kernel.setting.get(\"experimental.syncAction\")&&t.push({symbol:\"arrow.up.arrow.down.circle\",tapped:async(e,t)=>{e.actionStart(),this.undateAddActionButton(!0),await this.sync(),this.actionsNeedReload(),this.matrix.update(this.actionList),this.undateSyncLabel(),e.actionDone(),this.undateAddActionButton(!1)}}),e.setView(this.getMatrixView()).addNavBar({title:$l10n(\"ACTIONS\"),popButton:{symbol:\"xmark.circle\"},rightButtons:t}).init().present()}}})),parcelRequire.register(\"47XCm\",(function(e,t){var i=parcelRequire(\"eSp9Z\"),r=i.ActionEnv,s=i.ActionData,a=i.Action;class n{static syncStatus={syncing:0,success:1};#te=3;#ie=!1;#re;constructor(e){this.kernel=e,this.actionPath=\"scripts/action\",this.actionOrderFile=\"order.json\",this.tempPath=`${this.kernel.fileStorage.basePath}/temp`,this.userActionPath=`${this.kernel.fileStorage.basePath}/user_action`,this.localSyncFile=this.userActionPath+\"/data.json\",this.iCloudPath=\"drive://CAIO/user_action\",this.iCloudSyncFile=this.iCloudPath+\"/data.json\",this.iCloudSyncFileUndownloaded=this.iCloudPath+\"/.data.json.icloud\",this.typeNameMap={},this.checkUserAction(),$thread.background({delay:this.#te,handler:()=>this.sync(!0)})}get actions(){return this.#re||(this.#re=this.getActionTypes().map((e=>({title:this.getTypeName(e),items:this.getActions(e)})))),this.#re}actionsNeedReload(e=!1){this.#re=void 0,e&&$file.write({data:$data({string:JSON.stringify({date:Date.now()})}),path:this.localSyncFile})}importExampleAction(){try{Object.keys(__ACTIONS__).forEach((e=>{const t=`${this.userActionPath}/${e}`;Object.keys(__ACTIONS__[e]).forEach((i=>{$file.exists(`${t}/${i}/main.js`)||($file.mkdir(t),$file.mkdir(`${t}/${i}`),$file.write({data:$data({string:__ACTIONS__[e][i][\"main.js\"]}),path:`${t}/${i}/main.js`}),$file.write({data:$data({string:__ACTIONS__[e][i][\"config.json\"]}),path:`${t}/${i}/config.json`}),$file.write({data:$data({string:__ACTIONS__[e][i][\"README.md\"]}),path:`${t}/${i}/README.md`}))}))}))}catch{$file.list(this.actionPath).forEach((e=>{const t=`${this.actionPath}/${e}`;if($file.isDirectory(t)){const i=`${this.userActionPath}/${e}`;$file.list(t).forEach((e=>{$file.exists(`${i}/${e}/main.js`)||($file.mkdir(i),$file.copy({src:`${t}/${e}`,dst:`${i}/${e}`}))}))}}))}}#se(e=\"\"){if(e=e.trim(\"/\"),!$file.exists(e)){const t=e.lastIndexOf(\"/\");if(-1!==t){const i=e.substring(0,t);this.#se(i)}$file.mkdir(e)}}async downloadFiles(e){const t=$file.list(e);for(let i=0;ithis.sync(e)}));let t;this.#ie=!0,this.checkSyncData(),t=$file.exists(this.iCloudSyncFileUndownloaded)?await $file.download(this.iCloudSyncFileUndownloaded):$file.read(this.iCloudSyncFile),t=JSON.parse(t);const i=JSON.parse($file.read(this.localSyncFile).string);if(i.datet.date&&($file.write({data:$data({string:JSON.stringify({date:i.date})}),path:this.iCloudSyncFile}),await $wait(this.#te),$app.notify({name:\"actionSyncStatus\",object:{status:n.syncStatus.success}}));this.#ie=!1,e&&$thread.background({delay:this.#te,handler:()=>this.sync(e)})}checkUserAction(){$file.exists(this.userActionPath)&&0!==$file.list(this.userActionPath).length||($file.mkdir(this.userActionPath),this.importExampleAction()),$file.exists(this.iCloudPath)&&0!==$file.list(this.iCloudPath).length||($file.mkdir(this.iCloudPath),$file.copy({src:this.userActionPath,dst:this.iCloudPath}))}getActionTypes(){const e=[\"clipboard\",\"editor\"];return e.concat($file.list(this.userActionPath).filter((t=>{if($file.isDirectory(`${this.userActionPath}/${t}`)&&e.indexOf(t)<0)return t})))}getActionOrder(e){const t=`${this.userActionPath}/${e}/${this.actionOrderFile}`;return $file.exists(t)?JSON.parse($file.read(t).string):[]}getActionPath(e,t){return`${this.userActionPath}/${e}/${t}`}getActionConfig(e,t){return JSON.parse($file.read(`${this.getActionPath(e,t)}/config.json`).string)}getActionReadme(e,t){return $file.read(`${this.getActionPath(e,t)}/README.md`).string}getAction(e,t,i){const n=this.getActionPath(e,t),o=this.getActionConfig(e,t);try{const e=$file.read(`${n}/main.js`).string,t=new Function(\"Action\",\"ActionEnv\",\"ActionData\",`${e}\\n return MyAction`)(a,r,s);return new t(this.kernel,o,i)}catch(e){$ui.error(e),this.kernel.error(e)}}getActionHandler(e,t){return async i=>{try{const r=this.getAction(e,t,i);return await r.do()}catch(e){$ui.error(e),this.kernel.error(e)}}}getActions(e){const t=[],i=`${this.userActionPath}/${e}`;if(!$file.exists(i))return[];const r=r=>{const s=`${i}/${r}/`;if($file.isDirectory(s)){const i=this.getActionConfig(e,r);t.push(Object.assign(i,{dir:r,type:e,name:i.name??r,icon:i.icon,color:i.color}))}},s=this.getActionOrder(e);return s.forEach((e=>r(e))),$file.list(i).forEach((e=>{-1===s.indexOf(e)&&r(e)})),t}getTypeName(e){const t=e.toUpperCase(),i=$l10n(t),r=i===t?e:i;return this.typeNameMap[r]=e,r}getTypeDir(e){return this.typeNameMap[e]??e}#ae(e,t,i,r){\"string\"!=typeof r&&(r=JSON.stringify(r));const s=`${this.userActionPath}/${e}/${t}`;if($file.exists(s)||$file.mkdir(s),r===$file.read(`${s}/${i}`)?.string)return;$file.write({data:$data({string:r}),path:`${s}/${i}`});const a=`${this.iCloudPath}/${e}/${t}`;$file.exists(a)||$file.mkdir(a),$file.write({data:$data({string:r}),path:`${a}/${i}`})}saveActionInfo(e){this.#ae(e.type,e.dir,\"config.json\",{icon:e.icon,color:e.color,name:e.name}),this.#ae(e.type,e.dir,\"README.md\",e.readme),this.actionsNeedReload(!0)}saveMainJs(e,t){this.#ae(e.type,e.dir,\"main.js\",t)}saveOrder(e,t){$file.write({data:$data({string:JSON.stringify(t)}),path:`${this.userActionPath}/${e}/${this.actionOrderFile}`}),$file.write({data:$data({string:JSON.stringify(t)}),path:`${this.iCloudPath}/${e}/${this.actionOrderFile}`}),this.actionsNeedReload(!0)}move(e,t){if(e.section===t.section&&e.row===t.row)return;const i=this.actions[e.section],r=i.items,s=this.getTypeDir(i.title),a=e=>e.map((e=>e.dir));if(e.section===t.section)r.splice(e.rowt.row?e.row+1:e.row,1),this.saveOrder(s,a(r));else{const i=this.actions[t.section],n=i.items,o=this.getTypeDir(i.title);n.splice(t.row,0,r[e.row]),r.splice(e.row,1),this.saveOrder(o,a(n)),this.saveOrder(s,a(r)),$file.move({src:`${this.userActionPath}/${s}/${n[t.row].dir}`,dst:`${this.userActionPath}/${o}/${n[t.row].dir}`}),$file.move({src:`${this.iCloudPath}/${s}/${n[t.row].dir}`,dst:`${this.iCloudPath}/${o}/${n[t.row].dir}`})}this.actionsNeedReload(!0)}delete(e){$file.delete(`${this.userActionPath}/${e.type}/${e.dir}`),$file.delete(`${this.iCloudPath}/${e.type}/${e.dir}`),this.actionsNeedReload(!0)}}e.exports=n})),parcelRequire.register(\"gYDdO\",(function(e,t){function i(e,t=[]){t.forEach((t=>{$file.exists(t)&&(e.print(`delete file: ${t}`),$file.delete(t))}))}function r(e,t,i){const r=e.storage.sqlite.query(`SELECT count(*), name FROM sqlite_master WHERE type = \"table\" AND name = \"${t}\"`);if(null!==r.error)throw new Error(`Code [${r.error.code}] ${r.error.domain} ${r.error.localizedDescription}`);r.result.next();const s=r.result.get(0);r.result.close(),s>0&&(e.print(`copy data from old table: ${t}`),e.storage.sqlite.update(`INSERT INTO ${i} SELECT * FROM ${t}`),e.print(`drop table: ${t}`),e.storage.sqlite.update(`DROP TABLE ${t}`))}async function s(e,t={}){const i=\"scripts/action\",r=`${e.fileStorage.basePath}/user_action`,s=[];for(let e of Object.keys(t))t[e].forEach((t=>{const r=JSON.parse($file.read(`${i}/${e}/${t}/config.json`).string);s.push(r.name)}));if(1!==(await $ui.alert({title:$l10n(\"compatibility.rebuildUserAction.alert.title\"),message:$l10n(\"compatibility.rebuildUserAction.alert.message\")+\"\\n\"+JSON.stringify(s,null,2)+\"\\n\"+$l10n(\"compatibility.rebuildUserAction.alert.message2\"),actions:[{title:$l10n(\"OK\")},{title:$l10n(\"CANCEL\")}]})).index)for(let s of Object.keys(t))t[s].forEach((t=>{$file.exists(`${r}/${s}/${t}`)&&(e.print(`rebuild user action: ${s}/${t}`),$file.copy({src:`${i}/${s}/${t}/main.js`,dst:`${r}/${s}/${t}/main.js`}))}))}e.exports=async function(e){if(!e)return;const t=$cache.get(\"compatibility.version\")??0;try{t<1&&(e.print(`compatibility: userVersion [${t}] lower than [1], start action`),await async function(e){i(e,[\"scripts/action/clipboard/ClearClipboard\",\"scripts/ui/clipboard.js\",\"scripts/ui/clipboard-data.js\",\"scripts/ui/clipboard-search.js\"]),r(e,\"clipboard\",\"clips\"),await s(e,{uncategorized:[\"ExportAllContent\",\"DisplayClipboard\"],clipboard:[\"B23Clean\"]}),$cache.get(\"caio.keyboard.height\")&&(e.setting.set(\"keyboard.previewAndHeight\",$cache.get(\"caio.keyboard.height\")),$cache.remove(\"caio.keyboard.height\"))}(e)),t<2&&(e.print(`compatibility: userVersion [${t}] lower than [2], start action`),await async function(e){i(e,[\"scripts/storage.js\",\"scripts/ui/clips-data.js\",\"scripts/ui/components/action-manager-data.js\"]),r(e,\"pin\",\"favorite\"),await s(e,{uncategorized:[\"ExportAllContent\"]})}(e))}catch(t){throw e.error(t),t}$cache.set(\"compatibility.version\",2)}})),parcelRequire.register(\"9RsVy\",(function(e,t){var i=parcelRequire(\"gxpqj\"),r=i.Kernel,s=i.UIKit,a=parcelRequire(\"2aNLD\"),n=parcelRequire(\"ilpYs\");let o;function l(){o.setting.method.exportClipboard=e=>{e.actionStart(),o.storage.export((t=>{t?e.actionDone():e.actionCancel()}))},o.setting.method.importClipboard=e=>{e.actionStart(),$ui.alert({title:$l10n(\"ALERT_INFO\"),message:$l10n(\"OVERWRITE_ALERT\"),actions:[{title:$l10n(\"OK\"),handler:()=>{$drive.open({handler:t=>{void 0!==t?\"db\"===t.fileName.slice(-2)||\"zip\"===t.fileName.slice(-3)?o.storage.import(t).then((()=>{e.actionDone(),$delay(.3,(()=>{$addin.restart()}))})).catch((t=>{$ui.error(t),o.print(t),e.actionCancel()})):($ui.warning($l10n(\"FILE_TYPE_ERROR\")),e.actionCancel()):e.actionCancel()}})}},{title:$l10n(\"CANCEL\"),handler:()=>e.actionCancel()}]})},o.setting.method.rebuildDatabase=e=>{e.actionStart();$ui.alert({title:$l10n(\"REBUILD_DATABASE_ALERT\"),actions:[{title:$l10n(\"REBUILD\"),style:$alertActionType.destructive,handler:()=>{(()=>{try{o.storage.rebuild(),e.actionDone(),$delay(.8,(()=>$addin.restart()))}catch(t){e.actionCancel(),$ui.alert(t)}})()}},{title:$l10n(\"CANCEL\"),handler:()=>{e.actionCancel()}}]})},o.setting.method.deleteAllData=e=>{e.actionStart(),$ui.alert({title:$l10n(\"DELETE_ALL_DATA_ALERT\"),actions:[{title:$l10n(\"DELETE\"),style:$alertActionType.destructive,handler:()=>{o.storage.deleteAllData(),e.actionDone(),$delay(.5,(()=>$addin.restart()))}},{title:$l10n(\"CANCEL\"),handler:()=>{e.actionCancel()}}]})}}e.exports=function(e){o=e,o.setting.method.checkUpdate=async e=>{e.actionStart();const t=\"scripts/libs/easy-jsbox.js\";if($file.exists(t))try{const e=await o.checkUpdate();e&&($file.write({data:$data({string:e}),path:t}),$ui.toast(\"The framework has been updated.\"))}catch{}$http.get({url:\"https://raw.githubusercontent.com/ipuppet/CAIO/master/config.json\",handler:t=>{const i=t.data?.info.version;let s;try{s=__INFO__}catch{s=JSON.parse($file.read(\"config.json\").string).info}r.versionCompare(i,s.version)>0?$ui.alert({title:\"New Version\",message:`New version found: ${i}\\nUpdate via Github or click the button to open Erots.`,actions:[{title:$l10n(\"CANCEL\")},{title:\"Erots\",handler:()=>{$addin.run({name:\"Erots\",query:{q:\"show\",objectId:\"603e6eaaca0dd64fcef93e2d\"}})}}]}):$ui.toast(\"No need to update\"),e.actionDone()}})},o.setting.method.previewWidget=e=>{const{Widget:t}=parcelRequire(\"8Makm\"),i={};try{JSON.parse($file.read(\"widget-options.json\").string).forEach((e=>{i[e.name]=e.value}))}catch(e){return void $ui.error(e)}$ui.menu({items:Object.keys(i),handler:e=>{t.render(i[e])}})},o.setting.method.fileManager=()=>{o.fileManager.push(\"storage\")},l(),o.setting.method.exportAction=e=>{e.actionStart();const t=\"actions.zip\",i=\"/actions.zip\",r=o.fileStorage.filePath(i);$archiver.zip({directory:o.actionManager.userActionPath,dest:r,handler:()=>{$share.sheet({items:[{name:t,data:$data({path:r})}],handler:t=>{t?e.actionDone():e.actionCancel(),o.fileStorage.delete(i)}})}})},o.setting.method.importAction=e=>{e.actionStart(),$drive.open({handler:t=>{if(void 0!==t)if(\"zip\"===t.fileName.slice(-3)){const i=`${o.fileStorage.basePath}/action_import`;$archiver.unzip({file:t,dest:i,handler:()=>{$file.list(i).forEach((e=>{$file.isDirectory(`${i}/${e}`)&&$file.copy({src:`${i}/${e}`,dst:`${o.actionManager.userActionPath}/${e}`})})),$file.delete(i),e.actionDone()}})}else $ui.warning($l10n(\"FILE_TYPE_ERROR\")),e.actionCancel();else e.actionCancel()}})},o.setting.method.importExampleAction=e=>{e.actionStart(),o.actionManager.importExampleAction(),e.actionDone()},o.setting.method.rebuildAction=e=>{e.actionStart(),$ui.alert({title:$l10n(\"REBUILD_ACTION_DATABASE_ALERT_TITLE\"),message:$l10n(\"REBUILD_ACTION_DATABASE_ALERT_MESSAGE\"),actions:[{title:$l10n(\"REBUILD\"),style:$alertActionType.destructive,handler:()=>{$file.delete(o.actionManager.userActionPath),$file.delete(o.actionManager.iCloudPath),e.actionDone(),$delay(.8,(()=>$addin.restart()))}},{title:$l10n(\"CANCEL\"),handler:()=>e.actionCancel()}]})},function(){const e=parcelRequire(\"7eNYp\"),t=200;o.setting.method.previewKeyboard=()=>{const i=new e(o),r=$text.uuid,s=e=>{$(r).updateLayout((t=>{t.height.equalTo(e)})),i.keyboardHeight=e},a=e=>(e-t)/200;return{views:[{type:\"label\",layout:(e,t)=>{e.top.inset(20),e.centerX.equalTo(t.super)},events:{ready:e=>e.text=i.keyboardHeight,tapped:e=>{$input.text({type:$kbType.number,text:i.keyboardHeight,handler:i=>{if(/^[0-9]+$/.test(i)){let r=Number(i);r=Math.min(r,400),r=Math.max(r,t),e.text=r,e.next.value=a(r),s(r)}else $ui.toast(\"Only integers can be entered.\")}})}}},{type:\"slider\",props:{max:1,min:0},layout:(e,t)=>{e.top.equalTo(t.prev.bottom),e.right.inset(20),e.width.equalTo(t.super).offset(-40)},events:{ready:e=>e.value=a(i.keyboardHeight),changed:e=>{const i=Math.floor(200*e.value+t);e.prev.text=i,s(i)}}},{type:\"view\",props:{id:r},views:[i.getView()],layout:(e,t)=>{e.width.equalTo(t.super),e.height.equalTo(i.keyboardHeight),e.bottom.inset(0)}}],layout:$layout.fill}},o.setting.method.setKeyboardQuickStart=()=>a.sheet()}(),o.setting.method.previewTodayWidget=e=>{e.touchHighlightStart();const t=new(parcelRequire(\"49je6\"))(o).getView();s.push({views:[t],disappeared:()=>e.touchHighlightEnd()})},o.setting.method.setTodayWidgetActions=e=>{n.sheet(o)}}})),parcelRequire.register(\"2aNLD\",(function(e,t){var i=parcelRequire(\"gxpqj\").Sheet;class r{constructor(){this.listId=\"keyboard-script-list\"}static getAddins(){const e=$cache.get(\"keyboard.addins\");return void 0===e?(this.setAddins(),[]):JSON.parse(e)}static setAddins(e=[]){e.map(((t,i)=>{null===t&&e.splice(i,1)})),$cache.set(\"keyboard.addins\",JSON.stringify(e))}getUnsetAddins(){const e=$addin.current.name,t=r.getAddins(),i=[];return $addin.list?.forEach((r=>{const s=r.displayName;-1===t.indexOf(s)&&e!==s&&i.push(s)})),i}add(){const e={type:\"list\",props:{data:this.getUnsetAddins()},events:{didSelect:(e,t,i)=>{const s=r.getAddins();s.unshift(i),r.setAddins(s),$(this.listId).insert({indexPath:$indexPath(0,0),value:i}),e.delete(t)}},layout:$layout.fill};(new i).setView(e).addNavBar({title:$l10n(\"ADD\")}).init().present()}getNavButtons(){return[{symbol:\"plus\",tapped:()=>this.add()}]}getListView(){return{type:\"list\",props:{id:this.listId,reorder:!0,data:r.getAddins(),actions:[{title:\"delete\",handler:(e,t)=>{r.setAddins(e.data)}}]},events:{reorderFinished:e=>{r.setAddins(e)}},layout:$layout.fill}}static sheet(){const e=new i,t=new r;e.setView(t.getListView()).addNavBar({title:$l10n(\"QUICK_START_SCRIPTS\"),popButton:{title:$l10n(\"CLOSE\")},rightButtons:t.getNavButtons()}),e.init().present()}}e.exports=r})),parcelRequire.register(\"ilpYs\",(function(e,t){var i=parcelRequire(\"gxpqj\").Sheet;class r{constructor(e){this.listId=\"today-action-list\",this.kernel=e}getActions(){let e=$cache.get(\"today.actions\")??[];\"string\"==typeof e&&(e=JSON.parse(e),this.setActions(e));const t={};this.kernel.actionManager.getActionTypes().forEach((e=>{this.kernel.actionManager.getActions(e).forEach((e=>{t[e.type+e.dir]=e}))}));const i=[];let r=!1;return e.forEach((e=>{const s=t[e.type+e.dir];s?i.push(s):r=!0})),r&&this.setActions(i),i}setActions(e=[]){e.map(((t,i)=>{t||e.splice(i,1)})),$cache.set(\"today.actions\",e)}getAllActions(){let e=[];return this.kernel.actionManager.getActionTypes().forEach((t=>{e=e.concat(this.kernel.actionManager.getActions(t))})),e}getUnsetActions(){const e=this.getActions().map((e=>e.name)),t=[];return this.getAllActions().forEach((i=>{const r=i.name;-1===e.indexOf(r)&&t.push(i)})),t}getListData(e){return e.map((e=>({action:{text:e.name,info:e},icon:\"icon_\"===e.icon.slice(0,5)?{icon:$icon(e.icon.slice(5,e.icon.indexOf(\".\")),$color(\"#ffffff\"))}:{image:$image(e.icon)},color:{bgcolor:this.kernel.setting.getColor(e.color)}})))}getListTemplate(){return{views:[{type:\"image\",props:{id:\"color\",cornerRadius:8,smoothCorners:!0},layout:e=>{e.top.left.inset(10),e.size.equalTo($size(30,30))}},{type:\"image\",props:{id:\"icon\",tintColor:$color(\"#ffffff\")},layout:e=>{e.top.left.inset(15),e.size.equalTo($size(20,20))}},{type:\"label\",props:{id:\"action\"},layout:(e,t)=>{e.bottom.top.inset(10),e.left.equalTo(t.prev.prev.right).offset(10),e.right.inset(10)}}]}}add(){const e={type:\"list\",props:{data:this.getListData(this.getUnsetActions()),template:this.getListTemplate(),rowHeight:50},events:{didSelect:(e,t,i)=>{const r=i.action.info,s=this.getActions();s.unshift(r),this.setActions(s),$(this.listId).insert({indexPath:$indexPath(0,0),value:this.getListData([r])[0]}),e.delete(t)}},layout:$layout.fill};(new i).setView(e).addNavBar({title:$l10n(\"ADD\"),popButton:{title:$l10n(\"CLOSE\")}}).init().present()}getNavButtons(){return[{symbol:\"plus\",tapped:()=>this.add()}]}getListView(){return{type:\"list\",props:{id:this.listId,data:this.getListData(this.getActions()),template:this.getListTemplate(),rowHeight:50,reorder:!0,actions:[{title:\"delete\",handler:(e,t)=>{this.setActions(e.data.map((e=>e.action.info)))}}]},events:{reorderFinished:e=>{const t=[];e.forEach((e=>{t.push(e.action.info)})),this.setActions(t)}},layout:$layout.fill}}static sheet(e){const t=new i,s=new r(e);t.setView(s.getListView()).addNavBar({title:$l10n(\"ACTIONS\"),popButton:{title:$l10n(\"CLOSE\")},rightButtons:s.getNavButtons()}),t.init().present()}}e.exports=r})),parcelRequire.register(\"7eNYp\",(function(e,t){var i=parcelRequire(\"eSp9Z\"),r=i.ActionData,s=i.ActionEnv,a=parcelRequire(\"gxpqj\"),n=a.UIKit,o=a.BarButtonItem,l=parcelRequire(\"imdB1\"),c=parcelRequire(\"2aNLD\");e.exports=class extends l{#ne;listId=\"keyboard-clips-list\";keyboardSwitchLockId=\"keyboard-switch-lock\";keyboardSwitchLockKey=\"caio.keyboard.switch.lock\";deleteTimer=void 0;continuousDeleteTimer=void 0;continuousDeleteDelay=.5;horizontalMargin=15;verticalMargin=10;copiedIndicatorSize=5;containerMargin=5;fontSize=14;navHeight=50;menuItemActionMaxCount=3;constructor(e){super(e),this.backgroundImage=this.kernel.setting.getImage(\"keyboard.background.image\"),this.backgroundColor=this.kernel.setting.getColor(this.kernel.setting.get(\"keyboard.background.color\")),this.backgroundColorDark=this.kernel.setting.getColor(this.kernel.setting.get(\"keyboard.background.color.dark\")),this.deleteDelay=this.kernel.setting.get(\"keyboard.deleteDelay\"),this.keyboardSetting(),\"boolean\"!=typeof $cache.get(this.keyboardSwitchLockKey)&&$cache.set(this.keyboardSwitchLockKey,!1)}get keyboardHeight(){return this.kernel.setting.get(\"keyboard.previewAndHeight\")}set keyboardHeight(e){this.kernel.setting.set(\"keyboard.previewAndHeight\",e)}getKeyboardSwitchLock(){const e=$cache.get(this.keyboardSwitchLockKey);return\"boolean\"!=typeof e&&$cache.set(this.keyboardSwitchLockKey,!0),e}switchKeyboardSwitchLock(){const e=$cache.get(this.keyboardSwitchLockKey);$cache.set(this.keyboardSwitchLockKey,!e),$(this.keyboardSwitchLockId).symbol=e?\"lock.open\":\"lock\"}listReady(){this.updateList(),this.kernel.setting.get(\"clipboard.autoSave\")&&$app.env===$env.keyboard&&(this.#ne=$timer.schedule({interval:1,handler:()=>{this.kernel.setting.get(\"clipboard.autoSave\")?this.readClipboard():this.#ne.invalidate()}}))}keyboardSetting(){if($app.env!==$env.keyboard)return;const e=$timer.schedule({interval:0,handler:()=>{$keyboard.height!==this.keyboardHeight?$keyboard.height=this.keyboardHeight:e.invalidate()}});this.kernel.setting.get(\"keyboard.showJSBoxToolbar\")||($keyboard.barHidden=!0)}keyboardTapped(e,t=!0,i=1){return(...r)=>{t&&this.kernel.setting.get(\"keyboard.tapticEngine\")&&$device.taptic(i),e(...r)}}getTopButtons(){const e=[{symbol:\"keyboard.chevron.compact.down\",tapped:this.keyboardTapped((()=>$keyboard.dismiss()))},{symbol:\"square.and.arrow.down.on.square\",tapped:this.keyboardTapped((e=>{e.start(),this.readClipboard(!0),e.done()}))},{symbol:\"bolt.circle\",tapped:this.keyboardTapped(((e,t)=>{const i=$ui.popover({sourceView:t,directions:$popoverDirection.up,size:$size(200,300),views:[this.kernel.actionManager.getActionListView((e=>{i.dismiss(),$delay(.5,(async()=>{const t=new r({env:s.keyboard,textBeforeInput:$keyboard.textBeforeInput,textAfterInput:$keyboard.textAfterInput,text:$keyboard.selectedText??await $keyboard.getAllText()});e(t)}))}))]})}))}];return{type:\"view\",views:e.map(((e,t)=>(new o).setAlign(n.align.right).setSymbol(e.symbol).setEvent(\"tapped\",e.tapped).definition)),layout:(t,i)=>{const r=new o;t.height.equalTo(i.super),t.right.inset(this.containerMargin-r.edges),t.width.equalTo(r.width*e.length+r.edges)}}}getTopBarView(){return{type:\"view\",views:[{type:\"view\",layout:$layout.fill,views:[{type:\"label\",props:{text:$l10n(\"CAIO\"),font:$font(\"bold\",20)},events:{tapped:()=>this.kernel.openInJsbox(),ready:e=>{$cache.get(\"tips.keyboard.title\")||($cache.set(\"tips.keyboard.title\",!0),$ui.popover({sourceView:e,size:$size(200,60),directions:$popoverDirection.up,views:[{type:\"label\",props:{lines:0,text:$l10n(\"CLICK_TO_OPEN_JSBOX\"),align:$align.center},layout:$layout.fillSafeArea}]}))}},layout:(e,t)=>{e.centerY.equalTo(t.super),e.left.equalTo(t.super).offset(this.containerMargin)}}].concat(this.tabView(),this.getTopButtons())}],layout:(e,t)=>{e.top.width.equalTo(t.super),e.height.equalTo(this.navHeight)}}}getButtonView(e,t){const i=$size(38,38),r=this.containerMargin;return n.blurBox({info:{align:t},smoothCorners:!0,cornerRadius:5},[{type:\"button\",props:Object.assign({symbol:e.symbol,title:e.title,id:e.id??$text.uuid,font:$font(16),bgcolor:this.backgroundImage?$color($rgba(172,176,184,.3),$rgba(71,71,73,.3)):$color(\"#ACB0B8\",\"#474749\"),tintColor:n.textColor,titleColor:n.textColor,info:{align:t}},e.menu?{menu:e.menu}:{}),events:Object.assign({},e.tapped?{tapped:e.tapped}:{},e.events),layout:$layout.fill}],((s,a)=>{if(e.title){const t=$text.sizeThatFits({text:e.title,width:n.windowSize.width,font:$font(16)}),a=Math.ceil(t.width)+2*r;s.size.equalTo($size(a,i.height))}else s.size.equalTo(i);s.centerY.equalTo(a.super),a.prev&&a.prev.info.align===t?t===n.align.right?s.right.equalTo(a.prev.left).offset(-r):s.left.equalTo(a.prev.right).offset(r):t===n.align.right?s.right.inset(r):s.left.inset(r)}))}getBottomBarView(){const e=[],t=[];return $device.hasFaceID&&!$device.isIpadPro||e.push({symbol:\"globe\",tapped:this.keyboardTapped((()=>$keyboard.next())),menu:{pullDown:!0,items:[{title:$l10n(\"SWITCH_KEYBOARD\"),handler:this.keyboardTapped((()=>$keyboard.next()))},{title:$l10n(\"OPEN_IN_JSBOX\"),handler:()=>this.kernel.openInJsbox()}]}}),this.kernel.setting.get(\"keyboard.switchAfterInsert\")&&e.push({symbol:this.getKeyboardSwitchLock()?\"lock\":\"lock.open\",id:this.keyboardSwitchLockId,tapped:this.keyboardTapped((()=>this.switchKeyboardSwitchLock()))}),e.push({symbol:\"paperplane\",menu:{pullDown:!0,asPrimary:!0,items:c.getAddins().reverse().map((e=>({title:e,handler:this.keyboardTapped((()=>$addin.run(e)))})))}}),t.push({title:$l10n(\"SEND\"),tapped:this.keyboardTapped((()=>$keyboard.send()))},{symbol:\"delete.left\",events:{touchesBegan:this.keyboardTapped((()=>{$keyboard.delete(),this.continuousDeleteTimer=$delay(this.continuousDeleteDelay,(()=>{this.deleteTimer=$timer.schedule({interval:this.deleteDelay,handler:this.keyboardTapped((()=>$keyboard.delete()),this.kernel.setting.get(\"keyboard.tapticEngineForDelete\"),0)})}))})),touchesEnded:()=>{this.deleteTimer?.invalidate(),this.continuousDeleteTimer?.cancel(),this.deleteTimer=void 0,this.continuousDeleteTimer=void 0}}}),{type:\"view\",views:[...e.map((e=>this.getButtonView(e,n.align.left))),...t.map((e=>this.getButtonView(e,n.align.right)))],layout:(e,t)=>{e.bottom.left.right.equalTo(t.super.safeArea),e.top.equalTo(t.prev.bottom)}}}menuItems(){const e=super.menuItems();return[e[0],e[2]]}getListView(){const e=super.getListView();e.layout=(e,t)=>{e.top.equalTo(this.navHeight),e.width.equalTo(t.super),e.bottom.equalTo(t.super.safeAreaBottom).offset(-this.navHeight)};const t=e.views[0];t.events.didSelect=(e,t)=>{const i=this.clips[t.row],r=this.kernel.storage.keyToPath(i.text);r&&this.kernel.fileStorage.exists(r.original)?$quicklook.open({image:this.kernel.fileStorage.readSync(r.original)?.image}):($keyboard.insert(i.text),this.kernel.setting.get(\"keyboard.switchAfterInsert\")&&!this.getKeyboardSwitchLock()&&$keyboard.next())},t.props.separatorInset=$insets(0,this.horizontalMargin,0,this.horizontalMargin);const i=n.blurBox({style:$blurStyle.ultraThinMaterial,smoothCorners:!0,cornerRadius:2*this.containerMargin},[t],((e,t)=>{e.bottom.top.equalTo(t.super),e.left.right.inset(this.containerMargin)}));return e.views[0]=i,e}getView(){return{type:\"view\",props:{id:\"keyboard.main\",bgcolor:$color(this.backgroundColor,this.backgroundColorDark)},views:[{type:\"image\",props:{image:this.backgroundImage,hidden:null===this.backgroundImage},layout:$layout.fill},this.getTopBarView(),this.getListView(),this.getBottomBarView()],layout:$layout.fill}}}})),parcelRequire.register(\"49je6\",(function(e,t){var i=parcelRequire(\"eSp9Z\"),r=i.ActionData,s=i.ActionEnv,a=parcelRequire(\"gxpqj\"),n=a.View,o=a.UIKit,l=a.BarButtonItem,c=a.NavigationBarItems,h=a.NavigationBar,d=parcelRequire(\"imdB1\"),p=parcelRequire(\"ilpYs\");e.exports=class extends d{tabLeftMargin=8;horizontalMargin=15;verticalMargin=10;copiedIndicatorSize=5;fontSize=14;navHeight=38;taptic=1;tagFontSize=10;tagContainerHeight=12;matrixItemHeight=50;inLauncher=$app.env===$env.today&&-1===$app.widgetIndex;launcherNavHeight=44;constructor(e){super(e),this.actionsId=\"today-list-actions\",this.listContainerId=\"today-list-container\",this.readClipboardButtonId=\"today-nav-readClipboard\",this.listId=\"today-list\",this.tabItems.push($l10n(\"ACTIONS\")),this.navigationBarItems=new c,this.bottomBar=new h,this.bottomBar.navigationBarItems=this.navigationBarItems,this.todayActions=new p(this.kernel),this.setClipboarPageSize($widget.mode),this.listPageNow=[0,0],this.listSection=Math.min(this.tabIndex,1),this.setSingleLine()}get isActionPage(){return 2===this.tabIndex}set tabIndex(e){$cache.set(\"caio.today.tab.index\",e)}get tabIndex(){return $cache.get(\"caio.today.tab.index\")??0}listReady(){$widget.modeChanged=e=>{this.setClipboarPageSize(e),this.updateList()},this.setClipboarPageSize($widget.mode),this.updateList(!0),this.appListen(),$delay(.5,(()=>this.readClipboard()))}readClipboard(e=!1){return!this.isActionPage&&$app.env===$env.today&&(super.readClipboard(e),!0)}setClipboarPageSize(e){if(0===e)this.listPageSize=1;else{const e=(($app.env===$env.app?o.windowSize.height:$widget.height)-2*this.navHeight-(this.inLauncher?this.launcherNavHeight:0))/(this.singleLineHeight+2*this.verticalMargin),t=Math.floor(e);this.listPageSize=t,e-t>=.6&&this.listPageSize++}}buttonTapped(e,t=!0){return(...i)=>{t&&this.kernel.setting.get(\"keyboard.tapticEngine\")&&$device.taptic(this.taptic),e(...i)}}navButtons(){return[{symbol:\"square.and.arrow.down.on.square\",props:{id:this.readClipboardButtonId,hidden:this.isActionPage},tapped:this.buttonTapped((e=>{e.start(),this.readClipboard(!0)?e.done():e.cancel()}))}].map((e=>{const t=new l;return t.setAlign(o.align.right).setSymbol(e.symbol).setEvent(\"tapped\",e.tapped).setProps(e.props??{}),t.definition}))}switchTab(e){this.tabIndex=e,2===e?($(this.listContainerId).hidden=!0,$(this.actionsId).hidden=!1,$(this.readClipboardButtonId).hidden=!0):(this.listSection=e,$(this.actionsId).hidden=!0,$(this.listContainerId).hidden=!1,$(this.readClipboardButtonId).hidden=!1,this.updateList())}getNavBarView(){return{type:\"view\",views:[{type:\"view\",layout:$layout.fill,views:[this.tabView(),{type:\"label\"},...this.navButtons()]}],layout:(e,t)=>{e.top.width.equalTo(t.super),e.height.equalTo(this.navHeight)}}}getBottomBarView(){this.navigationBarItems.setLeftButtons([{symbol:\"chevron.backward.circle\",tapped:this.buttonTapped((()=>{this.clipboardPrevPage()}))}]).setRightButtons([{symbol:\"chevron.forward.circle\",tapped:this.buttonTapped((()=>{this.clipboardNextPage()}))}]),this.bottomBar.setTitle(this.listPageNow[this.listSection]+1).setLargeTitleDisplayMode(h.largeTitleDisplayModeNever);const e=this.bottomBar.getNavigationBarView();return e.layout=(e,t)=>{e.bottom.left.right.equalTo(t.super.safeArea),e.top.equalTo(t.prev.bottom)},e}updateList(){const e=this.listPageNow[this.listSection]*this.listPageSize,t=e+this.listPageSize;$(this.listId).data=this.allClips[this.listSection].slice(e,t).map((e=>this.lineData(e,this.copied.uuid===e.uuid))),$(this.bottomBar.id+\"-small-title\").text=this.listPageNow[this.listSection]+1}clipboardPrevPage(){this.listPageNow[this.listSection]>0&&(this.listPageNow[this.listSection]--,this.updateList())}clipboardNextPage(){const e=Math.ceil(this.allClips[this.listSection].length/this.listPageSize);this.listPageNow[this.listSection]this.listReady(),rowHeight:(e,t)=>{const i=e.object(t).tag.text?this.tagContainerHeight:this.verticalMargin;return this.singleLineHeight+this.verticalMargin+i},didSelect:this.buttonTapped(((e,t)=>{const i=this.clips[t.row],r=this.kernel.storage.keyToPath(i.text);r&&this.kernel.fileStorage.exists(r.original)?$clipboard.image=this.kernel.fileStorage.readSync(r.original).image:(this.setClipboardText(i.text),this.setCopied(i.uuid,t.row)),$ui.toast($l10n(\"COPIED\"))}))},layout:(e,t)=>{e.top.width.equalTo(t.super),e.bottom.equalTo(t.super).offset(-this.navHeight)}},this.getBottomBarView()],layout:(e,t)=>{e.top.equalTo(this.navHeight),e.bottom.left.right.equalTo(t.super.safeArea)}}}getActionView(){let e=this.todayActions.getActions();0===e.length&&(e=this.todayActions.getAllActions());const t={type:\"matrix\",props:{bgcolor:$color(\"clear\"),columns:2,itemHeight:this.matrixItemHeight,spacing:this.tabLeftMargin,data:e.map((e=>this.kernel.actionManager.actionToData(e))),template:{props:{smoothCorners:!0,cornerRadius:10,bgcolor:$color($rgba(255,255,255,.3),$rgba(0,0,0,.3))},views:[{type:\"image\",props:{id:\"color\",cornerRadius:8,smoothCorners:!0},layout:e=>{const t=this.matrixItemHeight-20;e.top.left.inset((this.matrixItemHeight-t)/2),e.size.equalTo($size(t,t))}},{type:\"image\",props:{id:\"icon\",tintColor:$color(\"#ffffff\")},layout:(e,t)=>{e.edges.equalTo(t.prev).insets(5)}},{type:\"label\",props:{id:\"name\",font:$font(14)},layout:(e,t)=>{e.bottom.top.inset(10),e.left.equalTo(t.prev.prev.right).offset(10),e.right.inset(10)}},{type:\"view\",props:{id:\"info\",hidden:!0}}]}},layout:$layout.fill,events:{didSelect:(e,t,i)=>{const a=i.info.info,n=new r({env:s.today,text:\"clipboard\"===a.type||\"uncategorized\"===a.type?$clipboard.text:null});this.kernel.actionManager.getActionHandler(a.type,a.dir)(n)}}};return{type:\"view\",props:{id:this.actionsId,hidden:2!==this.tabIndex},views:[t],layout:(e,t)=>{e.top.equalTo(this.navHeight),e.bottom.left.right.equalTo(t.super.safeArea)}}}getView(){return n.create({props:{titleColor:o.textColor,barColor:o.primaryViewBackgroundColor},views:[{type:\"view\",views:[this.getNavBarView(),this.getListView(),this.getActionView()],layout:$layout.fill}],events:{appeared:async()=>{if($app.env!==$env.today)return;const e=$timer.schedule({interval:0,handler:()=>{$ui.animate({duration:.3,animation:()=>{$ui.vc.ocValue().$view().$setBackgroundColor($color(\"clear\"))},completion:()=>{e.invalidate()}})}})}}})}}})),$app.strings={en:{ALERT_INFO:\"Alert\",NONE:\"Nothing\",DONE:\"Done\",CLOSE:\"Close\",FAILED_TO_LOAD_VIEW:\"Faild to load view\",VIEW_NOT_PROVIDED:\"The view is not provided\",UNCATEGORIZED:\"Uncategorized\",SHARE:\"Share\",CLICK_TO_OPEN_JSBOX:\"Click the title to open the main app.\",CLIPS:\"Clips\",CLIPBOARD:\"Clipboard\",UNIVERSAL_CLIPBOARD:\"Universal Clipboard\",UNIVERSAL_CLIPBOARD_TIPS:\"Universal Clipboard allows you to copy something on your iPhone, and paste it on your Mac–or vice-versa–using iCloud.\",CLIPS_STRUCTURE_ERROR:\"Clips data structure is abnormal\",CLIPBOARD_NO_CHANGE:\"Clipboard no change\",ADD:\"Add\",TAG:\"Tag\",ADD_TAG:\"Add Tag\",EDIT:\"Edit\",SEARCH:\"Search\",SEARCH_HISTORY:\"Search History\",SEARCH_RESULT:\"Search Result\",NO_SEARCH_RESULT:\"No item found.\",FAVORITE:\"Favorite\",COPY:\"Copy\",COPIED:\"Copied\",SORT:\"Sort\",ACTIONS:\"Actions\",MORE_ACTIONS:\"More Actions\",PREVIEW:\"Preview\",MAX_ITEM_LENGTH:\"Line Limit\",TEXT_MAX_LENGTH:\"Display Character Length\",AUTO_SAVE:\"Auto Save\",AUTO_SYNC:\"Auto Sync\",SYNC_NOW:\"Sync Now\",UNZIP_FAILED:\"Unzip file failed\",SYNC_ALERT_INFO:\"If it has not been synced locally, the iCloud data will be pulled directly. \\\\nDo you want to continue?\",DELETE_ICLOUD_DATA:\"Delete iCloud Data\",REBUILD:\"Rebuild\",REBUILD_DATABASE:\"Rebuild Database\",REBUILD_DATABASE_ALERT:\"Rebuilding the database will lose the order information, do you want to confirm the rebuild?\",DELETE_ALL_DATA:\"Delete All Data\",DELETE_ALL_DATA_ALERT:\"Are you sure you want to delete all your data?\",DELETE_DATA:\"Delete Data\",DELETE_TABLE:\"Delete all data from ${table}?\",SELECT_ALL:\"Select All\",DESELECT_ALL:\"Deselect All\",EDITOR:\"Editor\",CREATE_NEW:\"Create New\",CREATE_NEW_ACTION:\"New Action\",CREATE_NEW_TYPE:\"New Category\",TYPE_ALREADY_EXISTS:\"This category already exists\",EDIT_DETAILS:\"Edit Details\",EDIT_SCRIPT:\"Edit Script\",INFORMATION:\"Information\",NAME:\"Name\",ICON:\"Icon\",TYPE:\"Category\",DESCRIPTION:\"Description\",CODE:\"Code\",TEXT_INSETS:\"Text bottom margin\",SHOW_LINE_NUMBER:\"Show line number\",LIGHT_MODE_THEME:\"Light Mode Theme\",DARK_MODE_THEME:\"Dark Mode Theme\",SAVE:\"Save\",SAVE_SUCCESS:\"Save success\",SAVE_ERROR:\"Save failed\",DELETE:\"Delete\",CONFIRM_DELETE_TITLE:\"Delete Confirmation\",CONFIRM_DELETE_MSG:\"Are you sure you want to delete?\",DELETE_SUCCESS:\"Delete success\",DELETE_ERROR:\"Delete failed\",IMPORT_EXAMPLE_ACTIONS:\"Import example actions\",REBUILD_ACTION_DATABASE:\"Rebuild Action Database\",REBUILD_ACTION_DATABASE_ALERT_TITLE:\"Are you sure you want to rebuild?\",REBUILD_ACTION_DATABASE_ALERT_MESSAGE:\"Rebuild also deletes the data saved in iCloud Drive!\",EXPORT:\"Export\",IMPORT:\"Import\",FILE_TYPE_ERROR:\"File type does not match\",OVERWRITE_ALERT:\"This operation will overwrite the current data. Do you want to continue?\",KEYBOARD:\"Keyboard\",KEYBOARD_HEIGHT:\"Keyboard Height\",BACKGROUND_COLOR:\"Background Color\",BACKGROUND_COLOR_DARK:\"Dark Background Color\",BACKGROUND_IMAGE:\"Background Image\",DELETE_DELAY:\"Delete Delay\",SWITCH_AFTER_INSERT:\"Switch After Insert\",JSBOX_TOOLBAR:\"JSBox Toolbar\",QUICK_START_SCRIPTS:\"Quick Start Scripts\",SEND:\"Send\",OPEN_IN_JSBOX:\"Open in JSBox\",SWITCH_KEYBOARD:\"Switch Keyboard\",TAPTIC_ENGINE:\"Taptic Engine\",TAPTIC_ENGINE_FOR_DELETE:\"Taptic Engine For Delete\",CHECK_UPDATE:\"Check Update\",UPDATE:\"Update\",WIDGET:\"Widget\",RECENT:\"Recent\",CLICK_ACTION:\"Click Action\",TODAY_WIDGET:\"Today Widget\",PREV_PAGE:\"Prev\",NEXT_PAGE:\"Next\",DISPLAY_MODE:\"Display Mode\",CLASSIC:\"Classic\",MODERN:\"Modern\",FILE_MANAGEMENT:\"File Management\",\"compatibility.rebuildUserAction.alert.title\":\"We need to rebuild some of the action!\",\"compatibility.rebuildUserAction.alert.message\":\"If you tap the OK button, the following actions will be rebuilt:\",\"compatibility.rebuildUserAction.alert.message2\":\"Only the action logic will be changed, and the name and icon will remain as it is.\",EXPERIMENTAL:\"Experimental\",SYNC_ACTIONS:\"Sync Actions\",SYNCING:\"Syncing...\",LAST_SYNC_AT:\"Last sync at: \"},\"zh-Hans\":{ALERT_INFO:\"提示\",NONE:\"什么都没有\",DONE:\"完成\",CLOSE:\"关闭\",FAILED_TO_LOAD_VIEW:\"加载视图失败\",VIEW_NOT_PROVIDED:\"未提供该视图\",UNCATEGORIZED:\"未分类\",SHARE:\"分享\",CLICK_TO_OPEN_JSBOX:\"点击标题打开主应用。\",CLIPS:\"剪切板\",CLIPBOARD:\"剪切板\",UNIVERSAL_CLIPBOARD:\"通用剪贴板\",UNIVERSAL_CLIPBOARD_TIPS:\"用剪贴板允许您在iPhone上复制某些内容,然后使用iCloud将其粘贴到Mac上(反之亦然)。\",CLIPS_STRUCTURE_ERROR:\"剪切板数据结构异常\",CLIPBOARD_NO_CHANGE:\"剪切板无变化\",ADD:\"添加\",TAG:\"标签\",ADD_TAG:\"添加标签\",EDIT:\"编辑\",SEARCH:\"搜索\",SEARCH_HISTORY:\"搜索历史\",SEARCH_RESULT:\"搜索结果\",NO_SEARCH_RESULT:\"搜索无结果\",FAVORITE:\"收藏\",COPY:\"复制\",COPIED:\"已复制\",SORT:\"排序\",ACTIONS:\"动作\",MORE_ACTIONS:\"更多动作\",PREVIEW:\"预览\",MAX_ITEM_LENGTH:\"行数限制\",TEXT_MAX_LENGTH:\"显示字符长度\",AUTO_SAVE:\"自动保存\",AUTO_SYNC:\"自动同步\",SYNC_NOW:\"立即同步\",UNZIP_FAILED:\"解压文件失败\",SYNC_ALERT_INFO:\"若未在本机进行过同步则会直接拉取 iCloud 数据。\\\\n是否继续?\",DELETE_ICLOUD_DATA:\"删除 iCloud 数据\",REBUILD:\"重建\",REBUILD_DATABASE:\"重建数据库\",REBUILD_DATABASE_ALERT:\"重建数据库将会丢失顺序信息,是否确认重建?\",DELETE_ALL_DATA:\"删除所有数据\",DELETE_ALL_DATA_ALERT:\"确定要删除所有数据吗?\",DELETE_DATA:\"删除数据\",DELETE_TABLE:\"删除${table}的所有数据?\",SELECT_ALL:\"全选\",DESELECT_ALL:\"取消全选\",EDITOR:\"编辑器\",CREATE_NEW:\"新建\",CREATE_NEW_ACTION:\"新建动作\",CREATE_NEW_TYPE:\"新建分类\",TYPE_ALREADY_EXISTS:\"该类别已经存在\",EDIT_DETAILS:\"编辑信息\",EDIT_SCRIPT:\"编辑脚本\",INFORMATION:\"信息\",NAME:\"名称\",ICON:\"图标\",TYPE:\"分类\",DESCRIPTION:\"描述\",CODE:\"代码\",TEXT_INSETS:\"文本下边距\",SHOW_LINE_NUMBER:\"显示行号\",LIGHT_MODE_THEME:\"浅色模式主题\",DARK_MODE_THEME:\"深色模式主题\",SAVE:\"保存\",SAVE_SUCCESS:\"保存成功\",SAVE_ERROR:\"保存失败\",DELETE:\"删除\",CONFIRM_DELETE_TITLE:\"删除前确认\",CONFIRM_DELETE_MSG:\"确认要删除吗?\",DELETE_SUCCESS:\"删除成功\",DELETE_ERROR:\"删除失败\",IMPORT_EXAMPLE_ACTIONS:\"导入示例动作\",REBUILD_ACTION_DATABASE:\"重建动作库\",REBUILD_ACTION_DATABASE_ALERT_TITLE:\"您确认要重建?\",REBUILD_ACTION_DATABASE_ALERT_MESSAGE:\"重建会同时删除保存在 iCloud 云盘中的数据!\",EXPORT:\"导出\",IMPORT:\"导入\",FILE_TYPE_ERROR:\"文件类型不符\",OVERWRITE_ALERT:\"该操作将会覆盖当前数据,是否继续?\",KEYBOARD:\"键盘\",KEYBOARD_HEIGHT:\"键盘高度\",BACKGROUND_COLOR:\"背景色\",BACKGROUND_COLOR_DARK:\"深色模式背景色\",BACKGROUND_IMAGE:\"背景图片\",DELETE_DELAY:\"删除延时\",SWITCH_AFTER_INSERT:\"输入后切换\",JSBOX_TOOLBAR:\"JSBox 工具栏\",QUICK_START_SCRIPTS:\"快速启动脚本\",SEND:\"发送\",OPEN_IN_JSBOX:\"在 JSBox 中打开\",SWITCH_KEYBOARD:\"切换键盘\",TAPTIC_ENGINE:\"触感反馈\",TAPTIC_ENGINE_FOR_DELETE:\"删除按钮触感反馈\",CHECK_UPDATE:\"检查更新\",UPDATE:\"更新\",WIDGET:\"小组件\",RECENT:\"最近内容\",CLICK_ACTION:\"点击事件\",TODAY_WIDGET:\"通知中心小组件\",PREV_PAGE:\"上一页\",NEXT_PAGE:\"下一页\",DISPLAY_MODE:\"显示模式\",CLASSIC:\"经典\",MODERN:\"现代\",FILE_MANAGEMENT:\"文件管理\",\"compatibility.rebuildUserAction.alert.title\":\"我们需要重建部分动作!\",\"compatibility.rebuildUserAction.alert.message\":\"如果您点击 好,以下动作将会被重建:\",\"compatibility.rebuildUserAction.alert.message2\":\"只有动作逻辑会被更改,名称和图标将维持现状。\",EXPERIMENTAL:\"实验功能\",SYNC_ACTIONS:\"动作同步\",SYNCING:\"正在同步...\",LAST_SYNC_AT:\"最后同步:\"}},$app.theme=\"auto\",$app.minSDKVer=\"2.19.0\",$app.minOSVer=\"14.0.0\",$app.idleTimerDisabled=!1,$app.keyboardToolbarEnabled=!0,$app.rotateDisabled=!1,__INFO__={name:\"CAIO\",version:\"1.8.2\",author:\"ipuppet\",module:!1},__README__={\"README.md\":\"# CAIO\\r\\n\\r\\n> Clipboard all in one.\\r\\n> \\r\\n> A Clipboard tool based on JSBox.\\r\\n\\r\\nSupport for home widget and notification center widgets.\\r\\n\\r\\n## Build Taio Action\\r\\n\\r\\nBuild script depend on [Parcel](https://parceljs.org/).\\r\\n\\r\\n```shell\\r\\nnpm i -g parcel\\r\\nnpm run build\\r\\n```\\r\\n\\r\\nYou can also use the packaged files directly [dist/CAIO-en.json](./dist/CAIO-en.json).\\r\\n\\r\\n## Actions\\r\\n\\r\\n> For details on how to write, see `scripts/action/README.md` or the book button in the upper right corner of the `Action` edit page in the app.\\r\\n\\r\\n### `Action` data difference in different environments\\r\\n\\r\\n- The data processed by the `Action` button at the top of the home page is the currently copied content.\\r\\n- The data processed by the `Action` menu that pops up by long-pressing the list is the selected content.\\r\\n- The data processed by the `Action` button in the editor is whatever is being edited.\\r\\n\\r\\n\\r\\n## Today Widget\\r\\n\\r\\n> Click to copy, long press to trigger the action.\\r\\n\\r\\nPlease try to avoid using the Today Widget when JSBox is running CAIO.\",\"README_CN.md\":\"# CAIO\\r\\n\\r\\n> Clipboard all in one.\\r\\n> \\r\\n> A Clipboard tool based on JSBox.\\r\\n\\r\\n支持桌面小组件和通知中心小组件\\r\\n\\r\\n## 构建 Taio 动作\\r\\n\\r\\n构建脚本依赖 [Parcel](https://parceljs.org/)\\r\\n\\r\\n```shell\\r\\nnpm i -g parcel\\r\\nnpm run build\\r\\n```\\r\\n\\r\\n您也可以直接使用已打包好的文件 [dist/CAIO-zh-Hans.json](./dist/CAIO-zh-Hans.json)\\r\\n\\r\\n## Actions\\r\\n\\r\\n> 编写方式详见 `scripts/action/README.md` 或应用内 `Action` 编辑页面右上角图书按钮。\\r\\n\\r\\n### 不同环境中 `Action` 数据区别\\r\\n\\r\\n- 首页顶部 `Action` 按钮处理的数据为当前复制的内容\\r\\n- 长按列表弹出的 `Action` 菜单处理的数据为被选中的内容\\r\\n- 编辑器中顶部 `Action` 按钮(闪电图形按钮)处理的数据为正在编辑的所有内容\\r\\n\\r\\n\\r\\n## Today Widget\\r\\n\\r\\n> 点击复制,长按触发动作。\\r\\n\\r\\n请尽量避免在 JSBox 运行 CAIO 时使用 Today Widget\"},__SETTING__=[{items:[{icon:[\"doc.on.clipboard\",\"#FFCC66\"],type:\"child\",title:\"CLIPS\",key:\"clipboard\",children:[{items:[{icon:[\"link\",\"#FF6633\"],title:\"UNIVERSAL_CLIPBOARD\",type:\"switch\",key:\"clipboard.universal\",value:!0},{icon:[\"cursorarrow.rays\",\"#FF6633\"],title:\"Tips\",type:\"script\",key:\"clipboard.tips.universal\",value:\"$ui.alert({title:$l10n('UNIVERSAL_CLIPBOARD'),message:$l10n('UNIVERSAL_CLIPBOARD_TIPS')})\"}]},{items:[{icon:[\"text.alignleft\",\"#FFCC66\"],title:\"MAX_ITEM_LENGTH\",type:\"number\",key:\"clipboard.maxItemLength\",value:100},{icon:[\"square.and.arrow.down.on.square\",\"#FF6633\"],title:\"AUTO_SAVE\",type:\"switch\",key:\"clipboard.autoSave\",value:!0}]},{items:[{icon:[\"square.and.arrow.up\"],title:\"EXPORT\",type:\"script\",key:\"clipboard.export\",value:\"this.method.exportClipboard\"},{icon:[\"square.and.arrow.down\",\"#FFCC33\"],title:\"IMPORT\",type:\"script\",key:\"clipboard.import\",value:\"this.method.importClipboard\"}]},{items:[{icon:[\"arrow.2.circlepath\",\"red\"],title:\"REBUILD_DATABASE\",type:\"script\",key:\"clipboard.rebuildDatabase\",value:\"this.method.rebuildDatabase\"},{icon:[\"trash\",\"red\"],title:\"DELETE_ALL_DATA\",type:\"script\",key:\"clipboard.deleteAllData\",value:\"this.method.deleteAllData\"}]}]},{icon:[\"bolt.circle\",\"#FF6633\"],type:\"child\",title:\"ACTIONS\",key:\"action\",children:[{items:[{icon:[\"bolt.circle\",\"#FF6633\"],title:\"IMPORT_EXAMPLE_ACTIONS\",type:\"script\",key:\"action.importExampleAction\",value:\"this.method.importExampleAction\"}]},{items:[{icon:[\"square.and.arrow.up\"],title:\"EXPORT\",type:\"script\",key:\"action.export\",value:\"this.method.exportAction\"},{icon:[\"square.and.arrow.down\",\"#FFCC33\"],title:\"IMPORT\",type:\"script\",key:\"action.import\",value:\"this.method.importAction\"}]},{items:[{icon:[\"arrow.2.circlepath\",\"red\"],title:\"REBUILD_ACTION_DATABASE\",type:\"script\",key:\"action.rebuildAction\",value:\"this.method.rebuildAction\"}]}]},{icon:[\"pencil.circle\",\"#CC0099\"],type:\"child\",title:\"EDITOR\",key:\"editor\",children:[{title:\"CLIPS\",items:[{icon:[\"wand.and.stars\",\"#FF6633\"],title:\"TEXT_INSETS\",type:\"number\",key:\"editor.text.insets\",value:300}]},{title:\"CODE\",items:[{icon:[\"list.number\",\"#6699CC\"],title:\"SHOW_LINE_NUMBER\",type:\"switch\",key:\"editor.code.lineNumbers\",value:!1},{icon:[\"wand.and.stars\",\"#FF6633\"],title:\"LIGHT_MODE_THEME\",type:\"input\",key:\"editor.code.lightTheme\",value:\"atom-one-light\"},{icon:[\"wand.and.stars\",\"#FF6633\"],title:\"DARK_MODE_THEME\",type:\"input\",key:\"editor.code.darkTheme\",value:\"atom-one-dark\"}]}]},{icon:[\"keyboard\",\"#a2a5a6\"],type:\"child\",title:\"KEYBOARD\",key:\"keyboard\",children:[{items:[{icon:[\"rectangle.3.offgrid.fill\"],title:\"PREVIEW\",type:\"push\",key:\"keyboard.previewAndHeight\",view:\"this.method.previewKeyboard\",value:267}]},{items:[{icon:[\"sun.min\",\"#A569BD\"],title:\"BACKGROUND_COLOR\",type:\"color\",key:\"keyboard.background.color\",value:\"#D1D3D9\"},{icon:[\"sun.min\",\"#A569BD\"],title:\"BACKGROUND_COLOR_DARK\",type:\"color\",key:\"keyboard.background.color.dark\",value:\"#313131\"},{icon:[\"photo\",\"#FFCC66\"],title:\"BACKGROUND_IMAGE\",type:\"image\",key:\"keyboard.background.image\"}]},{items:[{icon:[\"globe\",\"#1899c4\"],title:\"SWITCH_AFTER_INSERT\",type:\"switch\",key:\"keyboard.switchAfterInsert\",value:!1},{icon:[\"cursor.rays\",\"#FF8C00\"],title:\"TAPTIC_ENGINE\",type:\"switch\",key:\"keyboard.tapticEngine\",value:!0},{icon:[\"option\",\"#157EFB\"],title:\"JSBOX_TOOLBAR\",type:\"switch\",key:\"keyboard.showJSBoxToolbar\",value:!1},{icon:[\"paperplane\"],title:\"QUICK_START_SCRIPTS\",type:\"script\",key:\"keyboard.setKeyboardQuickStart\",value:\"this.method.setKeyboardQuickStart\"}]},{items:[{icon:[\"cursor.rays\",\"#FF8C00\"],title:\"TAPTIC_ENGINE_FOR_DELETE\",type:\"switch\",key:\"keyboard.tapticEngineForDelete\",value:!0},{icon:[\"rays\",\"#FFCC33\"],title:\"DELETE_DELAY\",type:\"number\",key:\"keyboard.deleteDelay\",value:.05}]}]},{icon:[\"rectangle.3.offgrid.fill\",\"#1899c4\"],type:\"child\",title:\"WIDGET\",key:\"widget\",children:[{items:[{icon:[\"rectangle.3.offgrid.fill\"],title:\"PREVIEW\",type:\"script\",key:\"previewWidget\",value:\"this.method.previewWidget\"}]},{title:\"2x2\",items:[{icon:[\"link\"],title:\"CLICK_ACTION\",type:\"menu\",key:\"widget.2x2.widgetURL\",items:[\"ADD\",\"ACTIONS\",\"CLIPS\"],value:2}]}]},{icon:[\"filemenu.and.selection\",\"#ebcc34\"],type:\"child\",title:\"TODAY_WIDGET\",key:\"todayWidget\",children:[{items:[{icon:[\"rectangle.3.offgrid.fill\"],title:\"PREVIEW\",type:\"script\",key:\"todayWidget.preview\",value:\"this.method.previewTodayWidget\"}]},{items:[{icon:[\"bolt.circle\"],title:\"ACTIONS\",type:\"script\",key:\"todayWidget.setTodayWidgetActions\",value:\"this.method.setTodayWidgetActions\"}]}]}]},{items:[{icon:[\"rectangle.topthird.inset.filled\",\"#A569BD\"],title:\"DISPLAY_MODE\",type:\"tab\",key:\"mainUIDisplayMode\",items:[\"CLASSIC\",\"MODERN\"],value:0},{icon:[\"folder.fill\",\"#FF9900\"],title:\"FILE_MANAGEMENT\",type:\"script\",key:\"fileManager\",value:\"this.method.fileManager\"}]},{items:[{icon:[\"wrench.and.screwdriver\"],title:\"EXPERIMENTAL\",type:\"child\",key:\"EXPERIMENTAL\",children:[{items:[{icon:[\"bolt.circle\"],title:\"SYNC_ACTIONS\",type:\"switch\",key:\"experimental.syncAction\",value:!1}]}]}]},{items:[{icon:[\"/assets/icon/github.com.jpeg\",\"white\"],title:\"Github\",type:\"info\",key:\"github\",value:[\"ipuppet/CAIO\",\"https://github.com/ipuppet/CAIO\"]},{icon:[\"/assets/icon/telegram.png\",\"white\"],title:\"Telegram\",type:\"info\",key:\"telegram\",value:[\"JSBoxTG\",\"https://t.me/JSBoxTG\"]},{icon:[\"person.fill\",\"#FF9900\"],title:\"AUTHOR\",type:\"info\",key:\"author\",value:[\"ipuppet\",\"https://blog.ultagic.com\"]},{icon:[\"arrow.2.circlepath\"],title:\"CHECK_UPDATE\",type:\"script\",key:\"checkUpdate\",value:\"this.method.checkUpdate\"},{icon:[\"book.fill\",\"#A569BD\"],title:\"README\",type:\"script\",key:\"readme\",value:\"this.method.readme\"}]}],__ACTIONS__={clipboard:{B23Clean:{\"config.json\":'{\\r\\n \"icon\": \"trash\",\\r\\n \"color\": \"#FF0000\",\\r\\n \"name\": \"b23 清除追踪\"\\r\\n}',\"main.js\":'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n */\\r\\nclass MyAction extends Action {\\r\\n l10n() {\\r\\n return {\\r\\n \"zh-Hans\": {\\r\\n \"b23clean.converting\": \"正在转换...\",\\r\\n \"b23clean.noUrl\": \"未检测到链接\",\\r\\n \"b23clean.noBiliUrl\": \"未检测到 bilibili 链接\",\\r\\n \"b23clean.success\": \"已转换为 BV 视频链接\",\\r\\n \"b23clean.noChange\": \"无变化\",\\r\\n \"b23clean.multipleLinks\": \"多条链接仅在编辑模式下可用。\"\\r\\n },\\r\\n en: {\\r\\n \"b23clean.converting\": \"Converting...\",\\r\\n \"b23clean.noUrl\": \"No link detected\",\\r\\n \"b23clean.noBiliUrl\": \"bilibili link not detected\",\\r\\n \"b23clean.success\": \"Converted to BV video link\",\\r\\n \"b23clean.noChange\": \"No change\",\\r\\n \"b23clean.multipleLinks\": \"Multiple links are only available in edit mode.\"\\r\\n }\\r\\n }\\r\\n }\\r\\n\\r\\n async cleanUrl(b23url) {\\r\\n if (b23url.indexOf(\"bilibili.com\") === -1 && b23url.indexOf(\"b23.tv\") === -1) {\\r\\n throw new Error($l10n(\"b23clean.noBiliUrl\"))\\r\\n }\\r\\n\\r\\n let url = b23url\\r\\n if (b23url.indexOf(\"b23.tv\") >= 0) {\\r\\n const resp = await $http.get(b23url)\\r\\n url = resp.response.url\\r\\n }\\r\\n\\r\\n const queryStart = url.indexOf(\"?\")\\r\\n if (queryStart > -1) {\\r\\n url = url.substring(0, queryStart - 1)\\r\\n }\\r\\n\\r\\n return url\\r\\n }\\r\\n\\r\\n /**\\r\\n * 系统会调用 do() 方法\\r\\n */\\r\\n async do() {\\r\\n $ui.toast($l10n(\"b23clean.converting\"), 1000)\\r\\n\\r\\n try {\\r\\n const b23url = this.getUrls()\\r\\n if (b23url.length === 0) {\\r\\n throw new Error($l10n(\"b23clean.noUrl\"))\\r\\n }\\r\\n\\r\\n if (b23url.length === 1) {\\r\\n let url = await this.cleanUrl(b23url[0])\\r\\n $ui.clearToast()\\r\\n $ui.alert({\\r\\n title: $l10n(\"b23clean.success\"),\\r\\n message: url,\\r\\n actions: [\\r\\n { title: $l10n(\"OK\") },\\r\\n {\\r\\n title: $l10n(\"COPY\"),\\r\\n handler: () => {\\r\\n $clipboard.text = url\\r\\n $ui.success($l10n(\"COPIED\"))\\r\\n }\\r\\n }\\r\\n ]\\r\\n })\\r\\n } else {\\r\\n if (this.env !== ActionEnv.editor) {\\r\\n $ui.toast($l10n(\"b23clean.multipleLinks\"))\\r\\n return\\r\\n }\\r\\n let flag = false\\r\\n for (let i = 0; i < b23url.length; i++) {\\r\\n try {\\r\\n const url = b23url[i].trim()\\r\\n const replacedUrl = await this.cleanUrl(url)\\r\\n flag = true\\r\\n\\r\\n if (url !== replacedUrl) {\\r\\n const newText = this.text.replace(url, replacedUrl)\\r\\n this.setContent(newText)\\r\\n }\\r\\n } catch {}\\r\\n }\\r\\n if (!flag) {\\r\\n throw new Error($l10n(\"b23clean.noBiliUrl\"))\\r\\n } else {\\r\\n $ui.toast($l10n(\"b23clean.noChange\"))\\r\\n }\\r\\n }\\r\\n } catch (error) {\\r\\n $ui.clearToast()\\r\\n $delay(0.5, () => $ui.error(error))\\r\\n }\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## B23Clean\\r\\n\\r\\n清除 b23.tv 分享链接中的追踪参数,转换为 BV 视频链接。\"},CleanClipboard:{\"config.json\":'{\\r\\n \"icon\": \"trash\",\\r\\n \"color\": \"#FF0000\",\\r\\n \"name\": \"清除剪切板\"\\r\\n}',\"main.js\":'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n */\\r\\nclass MyAction extends Action {\\r\\n l10n() {\\r\\n return {\\r\\n \"zh-Hans\": {\\r\\n \"clipboard.clean.success\": \"剪切板已清空\"\\r\\n },\\r\\n en: {\\r\\n \"clipboard.clean.success\": \"Clipboard is cleaned\"\\r\\n }\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * 系统会调用 do() 方法\\r\\n */\\r\\n do() {\\r\\n $clipboard.clear()\\r\\n $ui.success($l10n(\"clipboard.clean.success\"))\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## CleanClipboard\\r\\n\\r\\n清空当前剪切板内容。\"},DownloadFromUrl:{\"config.json\":'{\\r\\n \"icon\": \"square.and.arrow.down\",\\r\\n \"color\": \"#FF0099\",\\r\\n \"name\": \"从链接下载\"\\r\\n}',\"main.js\":'class MyAction extends Action {\\r\\n async downloadContent(url) {\\r\\n const response = await $http.get({\\r\\n url,\\r\\n showsProgress: true\\r\\n })\\r\\n if (response.error) {\\r\\n $ui.alert(response.error.localizedDescription)\\r\\n } else {\\r\\n return response\\r\\n }\\r\\n }\\r\\n\\r\\n async do() {\\r\\n const url = this.getUrls()\\r\\n let response = undefined\\r\\n if (url.length > 1) {\\r\\n $ui.menu({\\r\\n items: url,\\r\\n handler: async (title, index) => {\\r\\n response = await this.downloadContent(url[index])\\r\\n }\\r\\n })\\r\\n } else if (url.length === 1) {\\r\\n response = await this.downloadContent(url[0])\\r\\n } else {\\r\\n $ui.warning(\"未检测到链接\")\\r\\n return\\r\\n }\\r\\n $share.sheet([\\r\\n {\\r\\n name: response.response.suggestedFilename,\\r\\n data: response.data\\r\\n }\\r\\n ])\\r\\n return response\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## DownloadFromUrl\\r\\n\\r\\n从链接下载内容,如 js 文件内容等。\"},GetFromWin:{\"config.json\":'{\\r\\n \"icon\": \"square.and.arrow.down\",\\r\\n \"color\": \"#33CC33\",\\r\\n \"name\": \"读取 clipsync\"\\r\\n}',\"main.js\":'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n */\\r\\nclass MyAction extends Action {\\r\\n async getIp(refresh = false) {\\r\\n let address = $cache.get(\"caio.action.clipsync.address\")\\r\\n if (refresh || !address) {\\r\\n address = await $input.text({\\r\\n placeholder: \"Address\",\\r\\n text: $cache.get(\"caio.action.clipsync.address\")\\r\\n })\\r\\n }\\r\\n\\r\\n $cache.set(\"caio.action.clipsync.address\", address)\\r\\n\\r\\n if (!address.startsWith(\"http\")) {\\r\\n address = \"http://\" + address\\r\\n }\\r\\n\\r\\n return address\\r\\n }\\r\\n\\r\\n async do() {\\r\\n let address = await this.getIp()\\r\\n\\r\\n $ui.toast(\"Loading...\", 5)\\r\\n try {\\r\\n const resp = await this.request(address + \"/api/clip\", \"GET\")\\r\\n if (resp.data.status) {\\r\\n $ui.success(\"success\")\\r\\n $clipboard.text = resp.data.data\\r\\n }\\r\\n } catch (error) {\\r\\n $ui.clearToast()\\r\\n $ui.alert({\\r\\n title: \"Error\",\\r\\n message: String(error),\\r\\n actions: [\\r\\n { title: \"OK\" },\\r\\n {\\r\\n title: \"Reset Adress\",\\r\\n handler: () => this.getIp(true)\\r\\n }\\r\\n ]\\r\\n })\\r\\n }\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## GetFromWin\\r\\n\\r\\n通 clipsync 读取 PC 剪切板。\\r\\n\\r\\n服务端:[clipsync](https://github.com/ipuppet/clipsync)\\r\\n\"},OpenUrl:{\"config.json\":'{\\r\\n \"icon\": \"link\",\\r\\n \"color\": \"#FF0099\",\\r\\n \"name\": \"打开链接\"\\r\\n}',\"main.js\":'class MyAction extends Action {\\r\\n l10n() {\\r\\n return {\\r\\n \"zh-Hans\": {\\r\\n \"openLink.nourl\": \"未检测到链接\"\\r\\n },\\r\\n en: {\\r\\n \"openLink.nourl\": \"No link detected\"\\r\\n }\\r\\n }\\r\\n }\\r\\n\\r\\n openUrl(url) {\\r\\n $app.openURL(url.trim())\\r\\n }\\r\\n\\r\\n do() {\\r\\n const url = this.getUrls()\\r\\n if (url.length > 1) {\\r\\n $ui.menu({\\r\\n items: url,\\r\\n handler: (title, index) => {\\r\\n this.openUrl(url[index])\\r\\n }\\r\\n })\\r\\n } else if (url.length === 1) {\\r\\n this.openUrl(url[0])\\r\\n } else {\\r\\n $ui.warning($l10n(\"openLink.nourl\"))\\r\\n }\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## OpenUrl\\r\\n\\r\\n提取文本中的URL并打开。\"},SendToWin:{\"config.json\":'{\\r\\n \"icon\": \"square.and.arrow.up\",\\r\\n \"color\": \"#33CC33\",\\r\\n \"name\": \"推送 clipsync\"\\r\\n}',\"main.js\":'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n */\\r\\nclass MyAction extends Action {\\r\\n async getIp(refresh = false) {\\r\\n let address = $cache.get(\"caio.action.clipsync.address\")\\r\\n if (refresh || !address) {\\r\\n address = await $input.text({\\r\\n placeholder: \"Address\",\\r\\n text: $cache.get(\"caio.action.clipsync.address\")\\r\\n })\\r\\n }\\r\\n\\r\\n $cache.set(\"caio.action.clipsync.address\", address)\\r\\n\\r\\n if (!address.startsWith(\"http\")) {\\r\\n address = \"http://\" + address\\r\\n }\\r\\n\\r\\n return address\\r\\n }\\r\\n\\r\\n async do() {\\r\\n let address = await this.getIp()\\r\\n\\r\\n $ui.toast(\"Loading...\", 5)\\r\\n try {\\r\\n const resp = await this.request(address + \"/api/clip\", \"POST\", {\\r\\n data: $clipboard.text\\r\\n })\\r\\n if (resp.data.status) {\\r\\n $ui.success(\"success\")\\r\\n }\\r\\n } catch (error) {\\r\\n $ui.clearToast()\\r\\n $ui.alert({\\r\\n title: \"Error\",\\r\\n message: String(error),\\r\\n actions: [\\r\\n { title: \"OK\" },\\r\\n {\\r\\n title: \"Reset Adress\",\\r\\n handler: () => this.getIp(true)\\r\\n }\\r\\n ]\\r\\n })\\r\\n }\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## SendToWin\\r\\n\\r\\n通 clipsync 推送剪切板至 PC。\\r\\n\\r\\n服务端:[clipsync](https://github.com/ipuppet/clipsync)\\r\\n\"},Tokenize:{\"config.json\":'{\\r\\n \"icon\": \"pencil.and.ellipsis.rectangle\",\\r\\n \"color\": \"#0099FF\",\\r\\n \"name\": \"分词复制\"\\r\\n}',\"main.js\":'class MyAction extends Action {\\r\\n getView() {\\r\\n const color = {\\r\\n background: {\\r\\n normal: $color(\"#E7F2FF\", \"#E7F2FF\"),\\r\\n highlight: $color(\"##074FF\", \"#BBDAFF\")\\r\\n },\\r\\n text: {\\r\\n normal: $color(\"##074FF\", \"##074FF\"),\\r\\n highlight: $color(\"#FFFFFF\", \"#ADADAD\")\\r\\n }\\r\\n }\\r\\n const fontSize = 16\\r\\n const edges = 10\\r\\n return {\\r\\n type: \"matrix\",\\r\\n layout: $layout.fill,\\r\\n props: {\\r\\n spacing: edges,\\r\\n data: this.results.map(item => ({ label: { text: item } })),\\r\\n template: {\\r\\n views: [{\\r\\n type: \"label\",\\r\\n props: {\\r\\n id: \"label\",\\r\\n align: $align.center,\\r\\n cornerRadius: edges,\\r\\n bgcolor: color.background.normal,\\r\\n font: $font(fontSize),\\r\\n textColor: color.text.normal\\r\\n },\\r\\n layout: $layout.fill\\r\\n }]\\r\\n }\\r\\n },\\r\\n events: {\\r\\n highlighted: () => { },\\r\\n itemSize: (sender, indexPath) => {\\r\\n const width = fontSize * this.results[indexPath.item].length + 1\\r\\n if (this.maxtrixItemHeight === undefined)\\r\\n this.maxtrixItemHeight = fontSize + edges * 2\\r\\n return $size(width + edges * 2, this.maxtrixItemHeight)\\r\\n },\\r\\n didSelect: (sender, indexPath) => {\\r\\n const index = this.selected.indexOf(indexPath.item)\\r\\n const label = sender.cell(indexPath).get(\"label\")\\r\\n if (index === -1) {\\r\\n this.selected.push(indexPath.item)\\r\\n label.bgcolor = color.background.highlight\\r\\n label.textColor = color.text.highlight\\r\\n } else {\\r\\n this.selected.splice(index, 1)\\r\\n label.bgcolor = color.background.normal\\r\\n label.textColor = color.text.normal\\r\\n }\\r\\n }\\r\\n }\\r\\n }\\r\\n }\\r\\n /**\\r\\n * 系统会调用 do() 方法\\r\\n */\\r\\n do() {\\r\\n this.selected = []\\r\\n this.results = []\\r\\n $text.tokenize({\\r\\n text: this.text,\\r\\n handler: results => {\\r\\n this.results = results\\r\\n this.pageSheet({\\r\\n view: this.getView(),\\r\\n done: () => {\\r\\n const result = []\\r\\n this.selected.sort().forEach(i => {\\r\\n result.push(this.results[i])\\r\\n })\\r\\n if (result.length > 0) {\\r\\n const text = result.join(\"\")\\r\\n $clipboard.text = text\\r\\n $ui.alert({\\r\\n title: \"完成\",\\r\\n message: `已复制内容:${text}`\\r\\n })\\r\\n }\\r\\n }\\r\\n })\\r\\n }\\r\\n })\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## Tokenize\\r\\n\\r\\n将文本分词处理后复制。\"}},editor:{PreviewMarkdown:{\"config.json\":'{\\r\\n \"icon\": \"book\",\\r\\n \"color\": \"#9900CC\",\\r\\n \"name\": \"预览Markdown\"\\r\\n}',\"main.js\":'class MyAction extends Action {\\r\\n do() {\\r\\n this.pageSheet({\\r\\n view: {\\r\\n type: \"markdown\",\\r\\n props: { content: this.text },\\r\\n layout: $layout.fill\\r\\n }\\r\\n })\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## PreviewMarkdown\\r\\n\\r\\n预览Markdown。\"},SelectedText:{\"config.json\":'{\\r\\n \"icon\": \"crop\",\\r\\n \"color\": \"#6699CC\",\\r\\n \"name\": \"选中的文本\"\\r\\n}',\"main.js\":\"class MyAction extends Action {\\r\\n do() {\\r\\n if (this.selectedRange.length > 0) {\\r\\n const selectedText = this.text\\r\\n $ui.alert(selectedText)\\r\\n }\\r\\n }\\r\\n}\\r\\n\",\"README.md\":\"## SelectedText\\r\\n\\r\\n显示选中的文本。\"}},uncategorized:{DeleteClips:{\"config.json\":'{\\r\\n \"icon\": \"trash\",\\r\\n \"color\": \"#FF0000\",\\r\\n \"name\": \"删除所有剪切板\"\\r\\n}',\"main.js\":'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n */\\r\\n\\r\\nclass MyAction extends Action {\\r\\n async do() {\\r\\n try {\\r\\n const action = await this.clearAllClips()\\r\\n if (action) {\\r\\n $ui.success($l10n(\"DONE\"))\\r\\n }\\r\\n } catch (error) {\\r\\n $ui.error(error)\\r\\n }\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## DeleteClips\\r\\n\\r\\n删除所有已保存的剪切板(不包括收藏)。\"},DisplayClipboard:{\"config.json\":'{\\r\\n \"icon\": \"option\",\\r\\n \"color\": \"#FF6633\",\\r\\n \"name\": \"显示剪切板\"\\r\\n}',\"main.js\":'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n */\\r\\n\\r\\nclass MyAction extends Action {\\r\\n do() {\\r\\n this.pageSheet({\\r\\n view: {\\r\\n type: \"label\",\\r\\n props: {\\r\\n lines: 0,\\r\\n text: $clipboard.text,\\r\\n align: $align.center\\r\\n },\\r\\n layout: $layout.fill\\r\\n }\\r\\n })\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## DisplayClipboard\\r\\n\\r\\n显示当前剪切板内的内容。\"},ExportAllContent:{\"config.json\":'{\\r\\n \"icon\": \"square.and.arrow.up\",\\r\\n \"color\": \"#FF3300\",\\r\\n \"name\": \"导出数据\"\\r\\n}',\"main.js\":'class MyAction extends Action {\\r\\n do() {\\r\\n const data = this.getAllClips()\\r\\n if (data.clips.length > 0 || data.favorite.length > 0) {\\r\\n $share.sheet(JSON.stringify(data, null, 2))\\r\\n } else {\\r\\n $ui.alert(\"无数据\")\\r\\n }\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## ExportAllContent\\r\\n\\r\\n导出所有保存的数据。\"},Replace:{\"config.json\":'{\\r\\n \"icon\": \"square.and.arrow.up\",\\r\\n \"color\": \"#FF3300\",\\r\\n \"name\": \"查找替换\"\\r\\n}',\"main.js\":'function HtmlTemplate(html) {\\r\\n return `\\r\\n\\r\\n\\r\\n \\r\\n\\r\\n\\r\\n${html}\\r\\n\\r\\n\\r\\n`\\r\\n}\\r\\n\\r\\nclass MyAction extends Action {\\r\\n do() {\\r\\n $ui.menu({\\r\\n items: [\"忽略大小写\", \"大小写敏感\", \"正则表达式\"],\\r\\n handler: async (title, idx) => {\\r\\n const patternText = await $input.text({\\r\\n placeholder: \"查找内容\"\\r\\n })\\r\\n const replaceString = await $input.text({\\r\\n placeholder: \"替换内容\"\\r\\n })\\r\\n let pattern = undefined\\r\\n if (idx === 0) {\\r\\n pattern = new RegExp(`(${patternText})+`, \"gi\")\\r\\n } else if (idx === 1) {\\r\\n pattern = new RegExp(`(${patternText})+`, \"g\")\\r\\n } else if (idx === 2) {\\r\\n pattern = new RegExp(patternText, \"g\")\\r\\n }\\r\\n\\r\\n const matchResultPreview = this.text.replace(pattern, `${replaceString}`)\\r\\n const matchResult = this.text.replace(pattern, replaceString)\\r\\n this.pageSheet({\\r\\n title: \"替换预览\",\\r\\n doneText: \"替换\",\\r\\n view: {\\r\\n type: \"web\",\\r\\n props: {\\r\\n html: HtmlTemplate(matchResultPreview)\\r\\n },\\r\\n layout: $layout.fill\\r\\n },\\r\\n done: () => {\\r\\n this.setContent(matchResult)\\r\\n }\\r\\n })\\r\\n }\\r\\n })\\r\\n // this.setContent(\"Hello world!\")\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## Replace\\r\\n\\r\\n查找替换\"}}};var $8Makm=parcelRequire(\"8Makm\");$8Makm.run()})();" } } } diff --git a/dist/CAIO-zh-Hans.json b/dist/CAIO-zh-Hans.json index 5c855750..4b10dc91 100644 --- a/dist/CAIO-zh-Hans.json +++ b/dist/CAIO-zh-Hans.json @@ -12,7 +12,7 @@ "type": "@flow.javascript", "parameters": { "script": { - "value": "(()=>{var $parcel$global=\"undefined\"!=typeof globalThis?globalThis:\"undefined\"!=typeof self?self:\"undefined\"!=typeof window?window:\"undefined\"!=typeof global?global:{},$parcel$modules={},$parcel$inits={},parcelRequire=$parcel$global.parcelRequire94c2;null==parcelRequire&&(parcelRequire=function(e){if(e in $parcel$modules)return $parcel$modules[e].exports;if(e in $parcel$inits){var t=$parcel$inits[e];delete $parcel$inits[e];var i={id:e,exports:{}};return $parcel$modules[e]=i,t.call(i.exports,i,i.exports),i.exports}var r=new Error(\"Cannot find module '\"+e+\"'\");throw r.code=\"MODULE_NOT_FOUND\",r},parcelRequire.register=function(e,t){$parcel$inits[e]=t},$parcel$global.parcelRequire94c2=parcelRequire),parcelRequire.register(\"8Makm\",(function(e,t){var i=parcelRequire(\"gxpqj\"),r=i.UIKit,s=i.ViewController,a=i.TabBarController,n=i.Kernel,o=i.FileStorage,l=i.Setting,c=i.FileManager,h=parcelRequire(\"hOw2h\"),d=parcelRequire(\"imdB1\"),p=parcelRequire(\"44eiF\"),u=parcelRequire(\"gYDdO\"),g=parcelRequire(\"9RsVy\");const $=new o;class f extends n{constructor(){let e;super(),this.query=$context.query,this.fileStorage=$;try{e=__SETTING__}catch{}this.setting=new l({fileStorage:this.fileStorage,structure:e}),this.setting.loadConfig(),this.storage=new h(this),this.initComponents(),g(this)}addOpenInJsboxButton(){this.useJsboxNav(),this.setNavButtons([{image:$image(\"assets/icon.png\"),handler:()=>this.openInJsbox()}])}initComponents(){this.clips=new d(this),this.actionManager=new p(this),this.fileManager=new c}deleteConfirm(e,t){$ui.alert({title:$l10n(\"CONFIRM_DELETE_TITLE\"),message:e,actions:[{title:$l10n(\"DELETE\"),style:$alertActionType.destructive,handler:()=>{t()}},{title:$l10n(\"CANCEL\")}]})}}class b{static kernel=$app.env!==$env.widget?new f:void 0;static renderMainUI(){const e={clips:{icon:\"doc.on.clipboard\",title:$l10n(\"CLIPS\")},actions:{icon:\"command\",title:$l10n(\"ACTIONS\")},setting:{icon:\"gear\",title:$l10n(\"SETTING\")}};if(this.kernel.setting.setEvent(\"onSet\",(e=>{\"mainUIDisplayMode\"===e&&$delay(.3,(()=>$addin.restart()))})),0===this.kernel.setting.get(\"mainUIDisplayMode\"))this.kernel.useJsboxNav(),this.kernel.setting.useJsboxNav(),this.kernel.setNavButtons([{symbol:e.setting.icon,title:e.setting.title,handler:()=>{r.push({title:e.setting.title,views:[this.kernel.setting.getListView()]})}},{symbol:e.actions.icon,title:e.actions.title,handler:()=>{this.kernel.actionManager.present()}}]),this.kernel.UIRender(this.kernel.clips.getNavigationView().getPage());else{this.kernel.fileManager.setViewController(new s),this.kernel.tabBarController=new a;const t=this.kernel.clips.getNavigationView();this.kernel.tabBarController.setPages({clips:t.getPage(),actions:this.kernel.actionManager.getPage(),setting:this.kernel.setting.getPage()}).setCells({clips:e.clips,actions:e.actions,setting:e.setting}),this.kernel.UIRender(this.kernel.tabBarController.generateView().definition)}}static renderKeyboardUI(){this.kernel.addOpenInJsboxButton();const e=new(parcelRequire(\"7eNYp\"))(this.kernel);this.kernel.UIRender(e.getView())}static renderTodayUI(){this.kernel.addOpenInJsboxButton();const e=new(parcelRequire(\"49je6\"))(this.kernel);this.kernel.UIRender(e.getView())}static renderUnsupported(){$intents.finish(\"不支持在此环境中运行\"),$ui.render({views:[{type:\"label\",props:{text:\"不支持在此环境中运行\",align:$align.center},layout:$layout.fill}]})}}class y{static widgetInstance(e,...t){if($file.exists(`/scripts/widget/${e}.js`)){const{Widget:i}=require(`./widget/${e}.js`);return new i(...t)}return!1}static renderError(){$widget.setTimeline({render:()=>({type:\"text\",props:{text:\"Invalid argument\"}})})}static renderClipboard(){const e=new l;e.loadConfig().setReadonly();y.widgetInstance(\"Clipboard\",e,new h({fileStorage:$})).render()}static render(e=$widget.inputValue){\"Clipboard\"===(e=e??\"Clipboard\")?y.renderClipboard():y.renderError()}}e.exports={Widget:y,run:()=>{u(b.kernel),$app.env===$env.app||$app.env===$env.action?b.renderMainUI():$app.env===$env.keyboard?b.renderKeyboardUI():$app.env===$env.widget?y.render():$app.env===$env.today?b.renderTodayUI():b.renderUnsupported()}}})),parcelRequire.register(\"gxpqj\",(function(module,exports){var $parcel$global=\"undefined\"!=typeof globalThis?globalThis:\"undefined\"!=typeof self?self:\"undefined\"!=typeof window?window:void 0!==$parcel$global?$parcel$global:{},$parcel$modules={},$parcel$inits={},parcelRequire=$parcel$global.parcelRequire94c2;null==parcelRequire&&(parcelRequire=function(e){if(e in $parcel$modules)return $parcel$modules[e].exports;if(e in $parcel$inits){var t=$parcel$inits[e];delete $parcel$inits[e];var i={id:e,exports:{}};return $parcel$modules[e]=i,t.call(i.exports,i,i.exports),i.exports}var r=new Error(\"Cannot find module '\"+e+\"'\");throw r.code=\"MODULE_NOT_FOUND\",r},parcelRequire.register=function(e,t){$parcel$inits[e]=t},$parcel$global.parcelRequire94c2=parcelRequire),parcelRequire.register(\"45Ip7\",(function(e,t){class i{static#e=$objc(\"UIApplication\").$sharedApplication();static#t=$objc(\"UINotificationFeedbackGenerator\").$new();static feedbackSuccess(){i.#t.$notificationOccurred(0)}static feedbackError(){i.#t.$notificationOccurred(2)}static align={left:0,right:1,top:2,bottom:3};static textColor=$color(\"primaryText\");static linkColor=$color(\"systemLink\");static primaryViewBackgroundColor=$color(\"primarySurface\");static scrollViewBackgroundColor=$color(\"insetGroupedBackground\");static scrollViewList=[\"list\",\"matrix\"];static isLargeScreen=$device.isIpad||$device.isIpadPro;static get windowSize(){return $objc(\"UIWindow\").$keyWindow().jsValue().size}static NavigationBarNormalHeight=$objc(\"UINavigationController\").invoke(\"alloc.init\").$navigationBar().jsValue().frame.height;static NavigationBarLargeTitleHeight=$objc(\"UITabBarController\").invoke(\"alloc.init\").$tabBar().jsValue().frame.height+i.NavigationBarNormalHeight;static get isSplitScreenMode(){return i.isLargeScreen&&$device.info.screen.width!==i.windowSize.width}static get topSafeAreaInsets(){return i.#e?.$keyWindow()?.$safeAreaInsets()?.top??0}static get bottomSafeAreaInsets(){return i.#e?.$keyWindow()?.$safeAreaInsets()?.bottom??0}static get statusBarOrientation(){return i.#e.$statusBarOrientation()}static get consoleBarHeight(){if($app.isDebugging){let e=i.#e.$statusBarFrame().height+26;return $device.isIphoneX&&(e+=30),e}return 0}static get isHorizontal(){return 3===i.statusBarOrientation||4===i.statusBarOrientation}static loading(){const e=$ui.create(i.blurBox({cornerRadius:15},[{type:\"spinner\",props:{loading:!0,style:0},layout:(e,t)=>{e.size.equalTo(t.prev),e.center.equalTo(t.super)}}]));return{start:()=>{$ui.controller.view.insertAtIndex(e,0),e.layout(((e,t)=>{e.center.equalTo(t.super);const r=Math.min(.6*Math.min(i.windowSize.width,i.windowSize.height),260);e.size.equalTo($size(r,r))})),e.moveToFront()},end:()=>{e.remove()}}}static defaultBackgroundColor(e){return i.scrollViewList.indexOf(e)>-1?i.scrollViewBackgroundColor:i.primaryViewBackgroundColor}static separatorLine(e={},t=i.align.bottom){return{type:\"canvas\",props:e,layout:(e,r)=>{void 0===r.prev?e.top.equalTo(r.super):t===i.align.bottom?e.top.equalTo(r.prev.bottom):e.top.equalTo(r.prev.top),e.height.equalTo(1/$device.info.screen.scale),e.left.right.inset(0)},events:{draw:(t,i)=>{i.strokeColor=e.bgcolor??$color(\"separatorColor\"),i.setLineWidth(1),i.moveToPoint(0,0),i.addLineToPoint(t.frame.width,0),i.strokePath()}}}}static blurBox(e={},t=[],i=$layout.fill){return{type:\"blur\",props:Object.assign({style:$blurStyle.thinMaterial},e),views:t,layout:i}}static getContentSize(e,t=\"A\",r=i.windowSize.width,s){const a={text:t,width:r,font:e};return void 0!==s&&(a.lineSpacing=s),$text.sizeThatFits(a)}static push({views:e,statusBarStyle:t=0,title:i=\"\",navButtons:r=[{title:\"\"}],bgcolor:s=e[0]?.props?.bgcolor??\"primarySurface\",disappeared:a}={}){$ui.push({props:{statusBarStyle:t,navButtons:r,title:i,bgcolor:\"string\"==typeof s?$color(s):s},events:{disappeared:()=>{void 0!==a&&a()}},views:[{type:\"view\",views:e,layout:(e,t)=>{e.top.equalTo(t.super.safeArea),e.bottom.equalTo(t.super),e.left.right.equalTo(t.super.safeArea)}}]})}}e.exports={UIKit:i}})),parcelRequire.register(\"7D8Kb\",(function(module,exports){var $fYz8N=parcelRequire(\"fYz8N\"),$58e2f5443faff7c0$require$Controller=$fYz8N.Controller,$8aDdQ=parcelRequire(\"8aDdQ\"),$58e2f5443faff7c0$require$FileStorageFileNotFoundError=$8aDdQ.FileStorageFileNotFoundError,$58e2f5443faff7c0$require$FileStorage=$8aDdQ.FileStorage,$cgaQ6=parcelRequire(\"cgaQ6\"),$58e2f5443faff7c0$require$Kernel=$cgaQ6.Kernel,$45Ip7=parcelRequire(\"45Ip7\"),$58e2f5443faff7c0$require$UIKit=$45Ip7.UIKit,$aXWmO=parcelRequire(\"aXWmO\"),$58e2f5443faff7c0$require$Sheet=$aXWmO.Sheet,$12xzj=parcelRequire(\"12xzj\"),$58e2f5443faff7c0$require$NavigationView=$12xzj.NavigationView,$dcStC=parcelRequire(\"dcStC\"),$58e2f5443faff7c0$require$NavigationBar=$dcStC.NavigationBar,$gMc1q=parcelRequire(\"gMc1q\"),$58e2f5443faff7c0$require$ViewController=$gMc1q.ViewController;class SettingLoadConfigError extends Error{constructor(){super(\"Call loadConfig() first.\"),this.name=\"SettingLoadConfigError\"}}class SettingReadonlyError extends Error{constructor(){super(\"Attempted to assign to readonly property.\"),this.name=\"SettingReadonlyError\"}}class Setting extends $58e2f5443faff7c0$require$Controller{name;setting={};userData;fileStorage;imagePath;viewController=new $58e2f5443faff7c0$require$ViewController;method={readme:()=>{const e=(()=>{const e=$device.info?.language?.startsWith(\"zh\")?\"README_CN.md\":\"README.md\";try{return __README__[e]??__README__[\"README.md\"]}catch{return $file.read(e)?.string??$file.read(\"README.md\")?.string}})();(new $58e2f5443faff7c0$require$Sheet).setView({type:\"markdown\",props:{content:e},layout:(e,t)=>{e.size.equalTo(t.super)}}).init().present()}};rowHeight=50;edgeOffset=10;iconSize=30;#i={};#r=!1;#s=!1;#a;constructor(e={}){super(),\"function\"==typeof e.set&&\"function\"==typeof e.get?(this.set=e.set,this.get=e.get,this.userData=e.userData):(this.fileStorage=e.fileStorage??new $58e2f5443faff7c0$require$FileStorage,this.dataFile=e.dataFile??\"setting.json\"),e.structure?this.setStructure(e.structure):this.setStructurePath(e.structurePath??\"setting.json\"),this.isUseJsboxNav=e.isUseJsboxNav??!1,this.imagePath=(e.name??\"default\")+\".image/\",this.setName(e.name??$text.uuid),this.loadL10n()}useJsboxNav(){return this.isUseJsboxNav=!0,this}#n(){if(!this.#s)throw new SettingLoadConfigError}loadConfig(){const e=[\"script\",\"info\"],t=this.userData??this.fileStorage.readAsJSON(this.dataFile,{});return this.setting=function i(r){const s={};for(let a of r)for(let r of a.items)if(\"child\"===r.type){const e=i(r.children);Object.assign(s,e)}else-1===e.indexOf(r.type)?s[r.key]=r.key in t?t[r.key]:r.value:s[r.key]=r.value;return s}(this.structure),this.#s=!0,this}hasSectionTitle(e){return this.#n(),!!e[0]?.title}loadL10n(){$58e2f5443faff7c0$require$Kernel.l10n(\"zh-Hans\",{OK:\"好\",DONE:\"完成\",CANCEL:\"取消\",CLEAR:\"清除\",BACK:\"返回\",ERROR:\"发生错误\",SUCCESS:\"成功\",LOADING:\"加载中\",INVALID_VALUE:\"非法参数\",CONFIRM_CHANGES:\"数据已变化,确认修改?\",SETTING:\"设置\",GENERAL:\"一般\",ADVANCED:\"高级\",TIPS:\"小贴士\",COLOR:\"颜色\",COPY:\"复制\",COPIED:\"复制成功\",JSBOX_ICON:\"JSBox 内置图标\",SF_SYMBOLS:\"SF Symbols\",IMAGE_BASE64:\"图片 / base64\",PREVIEW:\"预览\",SELECT_IMAGE:\"选择图片\",CLEAR_IMAGE:\"清除图片\",NO_IMAGE:\"无图片\",ABOUT:\"关于\",VERSION:\"Version\",AUTHOR:\"作者\",AT_BOTTOM:\"已经到底啦~\"},!1),$58e2f5443faff7c0$require$Kernel.l10n(\"en\",{OK:\"OK\",DONE:\"Done\",CANCEL:\"Cancel\",CLEAR:\"Clear\",BACK:\"Back\",ERROR:\"Error\",SUCCESS:\"Success\",LOADING:\"Loading\",INVALID_VALUE:\"Invalid value\",CONFIRM_CHANGES:\"The data has changed, confirm the modification?\",SETTING:\"Setting\",GENERAL:\"General\",ADVANCED:\"Advanced\",TIPS:\"Tips\",COLOR:\"Color\",COPY:\"Copy\",COPIED:\"Copide\",JSBOX_ICON:\"JSBox in app icon\",SF_SYMBOLS:\"SF Symbols\",IMAGE_BASE64:\"Image / base64\",PREVIEW:\"Preview\",SELECT_IMAGE:\"Select Image\",CLEAR_IMAGE:\"Clear Image\",NO_IMAGE:\"No Image\",ABOUT:\"About\",VERSION:\"Version\",AUTHOR:\"Author\",AT_BOTTOM:\"It's the end~\"},!1)}setUserData(e){this.userData=e}setStructure(e){return this.structure=e,this}setStructurePath(e){return this.structure||this.setStructure($58e2f5443faff7c0$require$FileStorage.readFromRootAsJSON(e)),this}setName(e){return this.name=e,this}setFooter(e){return this.#a=e,this}set footer(e){this.#a=e}get footer(){if(void 0===this.#a){let e=$58e2f5443faff7c0$require$FileStorage.readFromRootAsJSON(\"config.json\",{}).info??{};if(!e.version||!e.author)try{e=__INFO__}catch{}this.#a={},e.version&&e.author&&(this.#a={type:\"view\",props:{height:70},views:[{type:\"label\",props:{font:$font(14),text:`${$l10n(\"VERSION\")} ${e.version} ♥ ${e.author}`,textColor:$color({light:\"#C0C0C0\",dark:\"#545454\"}),align:$align.center},layout:e=>{e.left.right.inset(0),e.top.inset(10)}}]})}return this.#a}setReadonly(){return this.#r=!0,this}set(e,t){if(this.#r)throw new SettingReadonlyError;return this.#n(),this.setting[e]=t,this.fileStorage.write(this.dataFile,$data({string:JSON.stringify(this.setting)})),this.callEvent(\"onSet\",e,t),!0}get(e,t=null){return this.#n(),Object.prototype.hasOwnProperty.call(this.setting,e)?this.setting[e]:t}getColor(e){return\"string\"==typeof e?$color(e):$rgba(e.red,e.green,e.blue,e.alpha)}getImagePath(e,t=!1){let i=$text.MD5(e)+\".jpg\";return t&&(i=\"compress.\"+i),this.imagePath+i}getImage(e,t=!1){try{return this.fileStorage.readSync(this.getImagePath(e,t)).image}catch(e){if(e instanceof $58e2f5443faff7c0$require$FileStorageFileNotFoundError)return null;throw e}}getId(e){return`setting-${this.name}-${e}`}#o(e){$(e).bgcolor=$color(\"systemFill\")}#l(e,t=.3){0===t?$(e).bgcolor=$color(\"clear\"):$ui.animate({duration:t,animation:()=>{$(e).bgcolor=$color(\"clear\")}})}#c(e,t,i=!1,r=0){if(t=Object.assign(t,{touchesBegan:()=>{this.#o(e),this.#i[e]=$delay(1,(()=>this.#l(e,0)))},touchesMoved:()=>{this.#i[e]?.cancel(),this.#l(e,0)}}),i){const i=t.tapped;t.tapped=()=>{this.#o(e),setTimeout((()=>this.#l(e)),1e3*r),\"function\"==typeof i&&i()}}return t}createLineLabel(e,t){return t[1]||(t[1]=\"#00CC00\"),\"object\"!=typeof t[1]&&(t[1]=[t[1],t[1]]),\"object\"!=typeof t[0]&&(t[0]=[t[0],t[0]]),{type:\"view\",views:[{type:\"view\",props:{bgcolor:$color(t[1][0],t[1][1]),cornerRadius:5,smoothCorners:!0},views:[{type:\"image\",props:{tintColor:$color(\"white\"),image:$image(t[0][0],t[0][1])},layout:(e,t)=>{e.center.equalTo(t.super),e.size.equalTo(20)}}],layout:(e,t)=>{e.centerY.equalTo(t.super),e.size.equalTo(this.iconSize),e.left.inset(this.edgeOffset)}},{type:\"label\",props:{text:e,lines:1,textColor:this.textColor,align:$align.left},layout:(e,t)=>{e.centerY.equalTo(t.super),e.height.equalTo(t.super),e.left.equalTo(t.prev.right).offset(this.edgeOffset),e.width.greaterThanOrEqualTo(10)}}],layout:(e,t)=>{e.height.centerY.equalTo(t.super),e.left.inset(0)}}}createInfo(e,t,i){const r=Array.isArray(i),s=r?i[0]:i,a=r?i[1]:i;return{type:\"view\",props:{selectable:!0},views:[this.createLineLabel(t,e),{type:\"label\",props:{text:s,align:$align.right,textColor:$color(\"darkGray\")},layout:(e,t)=>{e.centerY.equalTo(t.prev),e.right.inset(this.edgeOffset),e.width.equalTo(180)}},{type:\"view\",events:{tapped:()=>{$ui.alert({title:t,message:a,actions:[{title:$l10n(\"COPY\"),handler:()=>{$clipboard.text=a,$ui.toast($l10n(\"COPIED\"))}},{title:$l10n(\"OK\")}]})}},layout:(e,t)=>{e.right.inset(0),e.size.equalTo(t.super)}}],layout:$layout.fill}}createSwitch(e,t,i){return{type:\"view\",props:{id:this.getId(e),selectable:!0},views:[this.createLineLabel(i,t),{type:\"switch\",props:{on:this.get(e),onColor:$color(\"#00CC00\")},events:{changed:t=>{try{this.set(e,t.on)}catch(e){throw t.on=!t.on,e}}},layout:(e,t)=>{e.centerY.equalTo(t.prev),e.right.inset(this.edgeOffset)}}],layout:$layout.fill}}createString(e,t,i){return{type:\"view\",props:{id:this.getId(e),selectable:!0},views:[this.createLineLabel(i,t),{type:\"button\",props:{symbol:\"square.and.pencil\",bgcolor:$color(\"clear\"),tintColor:$color(\"primaryText\")},events:{tapped:t=>{const i=$ui.popover({sourceView:t,sourceRect:t.bounds,directions:$popoverDirection.down,size:$size(320,150),views:[{type:\"text\",props:{id:`${this.name}-string-${e}`,align:$align.left,text:this.get(e)},layout:e=>{e.left.right.inset(10),e.top.inset(20),e.height.equalTo(90)}},{type:\"button\",props:{symbol:\"checkmark\",bgcolor:$color(\"clear\"),titleEdgeInsets:10,contentEdgeInsets:0},layout:e=>{e.right.inset(10),e.bottom.inset(25),e.size.equalTo(30)},events:{tapped:()=>{this.set(e,$(`${this.name}-string-${e}`).text),i.dismiss()}}}]})}},layout:(e,t)=>{e.centerY.equalTo(t.prev),e.right.inset(0),e.size.equalTo(50)}}],layout:$layout.fill}}createStepper(e,t,i,r,s){const a=this.getId(e),n=`${a}-label`;return{type:\"view\",props:{id:a,selectable:!0},views:[this.createLineLabel(i,t),{type:\"label\",props:{id:n,text:this.get(e),textColor:this.textColor,align:$align.left},layout:(e,t)=>{e.height.equalTo(t.super),e.right.inset(120)}},{type:\"stepper\",props:{min:r,max:s,value:this.get(e)},events:{changed:t=>{$(n).text=t.value;try{this.set(e,t.value)}catch(t){throw $(n).text=this.get(e),t}}},layout:(e,t)=>{e.centerY.equalTo(t.prev),e.right.inset(this.edgeOffset)}}],layout:$layout.fill}}createScript(key,icon,title,script){const id=this.getId(key),buttonId=`${id}-button`,actionStart=()=>{$(buttonId).alpha=0,$(`${buttonId}-spinner`).alpha=1,this.#o(id)},actionCancel=()=>{$(buttonId).alpha=1,$(`${buttonId}-spinner`).alpha=0,this.#l(id)},actionDone=(e=!0,t=$l10n(\"ERROR\"))=>{$(`${buttonId}-spinner`).alpha=0,this.#l(id);const i=$(buttonId);if(!e)return $ui.toast(t),void(i.alpha=1);i.symbol=\"checkmark\",$ui.animate({duration:.6,animation:()=>{i.alpha=1},completion:()=>{setTimeout((()=>{$ui.animate({duration:.4,animation:()=>{i.alpha=0},completion:()=>{i.symbol=\"chevron.right\",$ui.animate({duration:.4,animation:()=>{i.alpha=1},completion:()=>{i.alpha=1}})}})}),600)}})};return{type:\"view\",props:{id:id},views:[this.createLineLabel(title,icon),{type:\"view\",views:[{type:\"image\",props:{id:buttonId,symbol:\"chevron.right\",tintColor:$color(\"secondaryText\")},layout:(e,t)=>{e.centerY.equalTo(t.super),e.right.inset(0),e.size.equalTo(15)}},{type:\"spinner\",props:{id:`${buttonId}-spinner`,loading:!0,alpha:0},layout:(e,t)=>{e.size.equalTo(t.prev),e.left.top.equalTo(t.prev)}}],layout:(e,t)=>{e.right.inset(this.edgeOffset),e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],events:this.#c(id,{tapped:()=>{const animate={actionStart:actionStart,actionCancel:actionCancel,actionDone:actionDone,touchHighlightStart:()=>this.#o(id),touchHighlightEnd:()=>this.#l(id)};\"function\"==typeof script?script(animate):script.startsWith(\"this\")?eval(`(()=>{return ${script}(animate)})()`):eval(script)}}),layout:$layout.fill}}createTab(key,icon,title,items,values){\"string\"==typeof items?items=eval(`(()=>{return ${items}()})()`):\"function\"==typeof items&&(items=items()),\"string\"==typeof values?values=eval(`(()=>{return ${values}()})()`):\"function\"==typeof values&&(values=values());const id=this.getId(key),isCustomizeValues=items?.length>0&&values?.length===items?.length;return{type:\"view\",props:{id:id,selectable:!0},views:[this.createLineLabel(title,icon),{type:\"tab\",props:{items:items??[],index:isCustomizeValues?values.indexOf(this.get(key)):this.get(key),dynamicWidth:!0},layout:(e,t)=>{e.right.inset(this.edgeOffset),e.centerY.equalTo(t.prev)},events:{changed:e=>{isCustomizeValues?this.set(key,values[e.index]):this.set(key,e.index)}}}],layout:$layout.fill}}createMenu(key,icon,title,items,values){const id=this.getId(key),labelId=`${id}-label`,getItems=()=>{let res;return res=\"string\"==typeof items?eval(`(()=>{return ${items}()})()`):\"function\"==typeof items?items():items??[],res},getValues=()=>{let res;return res=\"string\"==typeof values?eval(`(()=>{return ${values}()})()`):\"function\"==typeof values?values():values,res},tmpItems=getItems(),tmpValues=getValues(),isCustomizeValues=tmpItems?.length>0&&tmpValues?.length===tmpItems?.length;return{type:\"view\",props:{id:id,selectable:!0},views:[this.createLineLabel(title,icon),{type:\"view\",views:[{type:\"label\",props:{text:isCustomizeValues?tmpItems[tmpValues.indexOf(this.get(key))]:tmpItems[this.get(key)],color:$color(\"secondaryText\"),id:labelId},layout:(e,t)=>{e.right.inset(0),e.height.equalTo(t.super)}}],layout:(e,t)=>{e.right.inset(this.edgeOffset),e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],events:{tapped:()=>{const e=getItems(),t=getValues();$ui.menu({items:e,handler:(e,i)=>{isCustomizeValues?this.set(key,t[i]):this.set(key,i),$(labelId).text=$l10n(e)}})}},layout:$layout.fill}}createColor(e,t,i){const r=this.getId(e),s=`${r}-color`;return{type:\"view\",props:{id:r,selectable:!0},views:[this.createLineLabel(i,t),{type:\"view\",views:[{type:\"view\",props:{id:s,bgcolor:this.getColor(this.get(e)),circular:!0,borderWidth:1,borderColor:$color(\"#e3e3e3\")},layout:(e,t)=>{e.centerY.equalTo(t.super),e.right.inset(this.edgeOffset),e.size.equalTo(20)}},{type:\"view\",events:{tapped:async()=>{const t=await $picker.color({color:this.getColor(this.get(e))});this.set(e,t.components),$(s).bgcolor=$rgba(t.components.red,t.components.green,t.components.blue,t.components.alpha)}},layout:(e,t)=>{e.right.inset(0),e.height.width.equalTo(t.super.height)}}],layout:(e,t)=>{e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],layout:$layout.fill}}createDate(e,t,i,r=2){const s=this.getId(e),a=e=>{let t=\"\";switch(\"number\"==typeof e&&(e=new Date(e)),r){case 0:t=e.toLocaleTimeString();break;case 1:t=e.toLocaleDateString();break;case 2:t=e.toLocaleString()}return t};return{type:\"view\",props:{id:s,selectable:!0},views:[this.createLineLabel(i,t),{type:\"view\",views:[{type:\"label\",props:{id:`${s}-label`,color:$color(\"secondaryText\"),text:this.get(e)?a(this.get(e)):\"None\"},layout:(e,t)=>{e.right.inset(0),e.height.equalTo(t.super)}}],events:{tapped:async()=>{const t=this.get(e),i=await $picker.date({props:{mode:r,date:t||Date.now()}});this.set(e,i.getTime()),$(`${s}-label`).text=a(i)}},layout:(e,t)=>{e.right.inset(this.edgeOffset),e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],layout:$layout.fill}}createNumber(e,t,i){return this.createInput(e,t,i,!1,$kbType.decimal,(t=>\"\"!==t&&/^[0-9]+.?[0-9]*$/.test(t)?this.set(e,Number(t)):($ui.toast($l10n(\"INVALID_VALUE\")),!1)))}createInput(e,t,i,r=!1,s=$kbType.default,a){void 0===a&&(a=t=>this.set(e,t));const n=this.getId(e),o=n+\"-input\";return{type:\"view\",props:{id:n,selectable:!0},views:[this.createLineLabel(i,t),{type:\"input\",props:{id:o,type:s,align:$align.right,bgcolor:$color(\"clear\"),textColor:$color(\"secondaryText\"),text:this.get(e),font:$font(16),secure:r,accessoryView:$58e2f5443faff7c0$require$UIKit.blurBox({height:44},[$58e2f5443faff7c0$require$UIKit.separatorLine({},$58e2f5443faff7c0$require$UIKit.align.top),{type:\"button\",props:{title:$l10n(\"DONE\"),bgcolor:$color(\"clear\"),titleColor:$color(\"primaryText\")},layout:(e,t)=>{e.right.inset(this.edgeOffset),e.centerY.equalTo(t.super)},events:{tapped:()=>{$(o).blur()}}},{type:\"button\",props:{title:$l10n(\"CANCEL\"),bgcolor:$color(\"clear\"),titleColor:$color(\"primaryText\")},layout:(e,t)=>{e.left.inset(this.edgeOffset),e.centerY.equalTo(t.super)},events:{tapped:()=>{const t=$(o),i=this.get(e,\"\");t.text!==i&&(t.text=i),t.blur()}}}])},layout:(t,i)=>{t.left.equalTo(i.prev.get(\"label\").right).offset(this.edgeOffset),t.right.inset(this.edgeOffset);const r=$58e2f5443faff7c0$require$UIKit.getContentSize($font(16),this.get(e)).width;t.width.greaterThanOrEqualTo(r+30),t.height.equalTo(i.super)},events:{didBeginEditing:e=>{e.secure=!1,$app.autoKeyboardEnabled||($app.autoKeyboardEnabled=!0)},returned:e=>{e.blur()},didEndEditing:async t=>{const i=this.get(e,\"\");a(t.text)||(t.text=i),r&&(t.secure=r)}}}],layout:$layout.fill}}createIcon(e,t,i,r=\"#000000\"){const s=this.getId(e),a=`${s}-image`;return{type:\"view\",props:{id:s,selectable:!0},views:[this.createLineLabel(i,t),{type:\"view\",views:[{type:\"image\",props:{cornerRadius:8,bgcolor:\"string\"==typeof r?$color(r):r,smoothCorners:!0},layout:(e,t)=>{e.right.inset(this.edgeOffset),e.centerY.equalTo(t.super),e.size.equalTo($size(30,30))}},{type:\"image\",props:{id:a,image:$image(this.get(e)),icon:$icon(this.get(e).slice(5,this.get(e).indexOf(\".\")),$color(\"#ffffff\")),tintColor:$color(\"#ffffff\")},layout:(e,t)=>{e.right.equalTo(t.prev).offset(-5),e.centerY.equalTo(t.super),e.size.equalTo($size(20,20))}}],events:{tapped:()=>{$ui.menu({items:[$l10n(\"JSBOX_ICON\"),$l10n(\"SF_SYMBOLS\"),$l10n(\"IMAGE_BASE64\")],handler:async(t,i)=>{if(0===i){const t=await $ui.selectIcon();this.set(e,t),$(a).icon=$icon(t.slice(5,t.indexOf(\".\")),$color(\"#ffffff\"))}else 1!==i&&2!==i||$input.text({text:\"\",placeholder:t,handler:t=>{\"\"!==t?(this.set(e,t),1===i?$(a).symbol=t:$(a).image=$image(t)):$ui.toast($l10n(\"INVALID_VALUE\"))}})}})}},layout:(e,t)=>{e.right.inset(0),e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],layout:$layout.fill}}createPush(key,icon,title,view,tapped){const id=this.getId(key);return{type:\"view\",layout:$layout.fill,props:{id:id,selectable:!0},views:[this.createLineLabel(title,icon),{type:\"image\",props:{symbol:\"chevron.right\",tintColor:$color(\"secondaryText\")},layout:(e,t)=>{e.centerY.equalTo(t.super),e.right.inset(this.edgeOffset),e.size.equalTo(15)}}],events:{tapped:()=>{const push=view=>{if(\"string\"==typeof view&&view.startsWith(\"this.method\")?view=eval(`(()=>{return ${view}()})()`):\"function\"==typeof view&&(view=view()),this.isUseJsboxNav)$58e2f5443faff7c0$require$UIKit.push({title:title,props:view.props??{},views:[view]});else{const e=new $58e2f5443faff7c0$require$NavigationView;e.setView(view).navigationBarTitle(title),e.navigationBarItems.addPopButton(),e.navigationBar.setLargeTitleDisplayMode($58e2f5443faff7c0$require$NavigationBar.largeTitleDisplayModeNever),this.hasSectionTitle(view)&&e.navigationBar.setContentViewHeightOffset(-10),this.viewController.push(e)}};\"function\"==typeof tapped?tapped(push):push(view)}}}}createChild(e,t,i,r){return this.createPush(e,t,i,void 0,(e=>{this.events?.onChildPush?this.callEvent(\"onChildPush\",this.getListView(r,{}),i):e(this.getListView(r,{}))}))}createImage(e,t,i){const r=this.getId(e),s=`${r}-image`,a=$image(\"questionmark.square.dashed\");return{type:\"view\",props:{id:r,selectable:!0},views:[this.createLineLabel(i,t),{type:\"view\",views:[{type:\"image\",props:{id:s,image:this.getImage(e,!0)??a},layout:(e,t)=>{e.right.inset(this.edgeOffset),e.centerY.equalTo(t.super),e.size.equalTo($size(30,30))}}],events:{tapped:()=>{this.#o(r),$ui.menu({items:[$l10n(\"PREVIEW\"),$l10n(\"SELECT_IMAGE\"),$l10n(\"CLEAR_IMAGE\")],handler:(t,i)=>{if(0===i){const t=this.getImage(e);t?$quicklook.open({image:t}):$ui.toast($l10n(\"NO_IMAGE\"))}else 1===i?$photo.pick({format:\"data\"}).then((t=>{if($ui.toast($l10n(\"LOADING\")),!t.status||!t.data)return void(\"canceled\"!==t?.error?.description&&$ui.toast($l10n(\"ERROR\")));const i=$58e2f5443faff7c0$require$Kernel.compressImage(t.data.image);this.fileStorage.write(this.getImagePath(e,!0),i.jpg(.8)),this.fileStorage.write(this.getImagePath(e),t.data),$(s).image=i,$ui.success($l10n(\"SUCCESS\"))})):2===i&&(this.fileStorage.delete(this.getImagePath(e,!0)),this.fileStorage.delete(this.getImagePath(e)),$(s).image=a,$ui.success($l10n(\"SUCCESS\")))},finished:()=>{this.#l(r)}})}},layout:(e,t)=>{e.right.inset(0),e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],layout:$layout.fill}}#h(e){const t=[];for(let i of e){const e=[];for(let t of i.items){const i=this.get(t.key);let r=null;switch(t.icon||(t.icon=[\"square.grid.2x2.fill\",\"#00CC00\"]),\"object\"==typeof t.items&&(t.items=t.items.map((e=>$l10n(e)))),t.title=$l10n(t.title),t.type){case\"switch\":r=this.createSwitch(t.key,t.icon,t.title);break;case\"stepper\":r=this.createStepper(t.key,t.icon,t.title,t.min??1,t.max??12);break;case\"string\":r=this.createString(t.key,t.icon,t.title);break;case\"info\":r=this.createInfo(t.icon,t.title,i);break;case\"script\":r=this.createScript(t.key,t.icon,t.title,i);break;case\"tab\":r=this.createTab(t.key,t.icon,t.title,t.items,t.values);break;case\"menu\":r=this.createMenu(t.key,t.icon,t.title,t.items,t.values);break;case\"color\":r=this.createColor(t.key,t.icon,t.title);break;case\"date\":r=this.createDate(t.key,t.icon,t.title,t.mode);break;case\"number\":r=this.createNumber(t.key,t.icon,t.title);break;case\"input\":r=this.createInput(t.key,t.icon,t.title,t.secure);break;case\"icon\":r=this.createIcon(t.key,t.icon,t.title,t.bgcolor);break;case\"push\":r=this.createPush(t.key,t.icon,t.title,t.view);break;case\"child\":r=this.createChild(t.key,t.icon,t.title,t.children);break;case\"image\":r=this.createImage(t.key,t.icon,t.title);break;default:continue}e.push(r)}t.push({title:$l10n(i.title??\"\"),rows:e})}return t}getListView(e,t=this.footer){return{type:\"list\",props:{id:this.name,style:2,separatorInset:$insets(0,this.iconSize+2*this.edgeOffset,0,this.edgeOffset),bgcolor:$58e2f5443faff7c0$require$UIKit.scrollViewBackgroundColor,footer:t,data:this.#h(e??this.structure)},layout:$layout.fill,events:{rowHeight:(e,t)=>(e.object(t)?.props?.info??{}).rowHeight??this.rowHeight}}}getPage(){const e=new $58e2f5443faff7c0$require$NavigationView;return e.setView(this.getListView(this.structure)).navigationBarTitle($l10n(\"SETTING\")),this.hasSectionTitle(this.structure)&&e.navigationBar.setContentViewHeightOffset(-10),e.getPage()}}module.exports={Setting:Setting}})),parcelRequire.register(\"fYz8N\",(function(e,t){e.exports={Controller:class{events={};setEvents(e){return Object.keys(e).forEach((t=>this.setEvent(t,e[t]))),this}setEvent(e,t){return this.events[e]=t,this}callEvent(e,...t){\"function\"==typeof this.events[e]&&this.events[e](...t)}}}})),parcelRequire.register(\"8aDdQ\",(function(e,t){class i extends Error{constructor(e){super(`Parameter [${e}] is required.`),this.name=\"FileStorageParameterError\"}}class r extends Error{constructor(e){super(`File not found: ${e}`),this.name=\"FileStorageFileNotFoundError\"}}class s{basePath;constructor({basePath:e=\"storage\"}={}){this.basePath=e,this.#d(this.basePath)}#d(e){$file.isDirectory(e)||$file.mkdir(e)}filePath(e=\"\",t=!0){e.startsWith(\"/\")&&(e=e.substring(1));let i=\"\";if(!(e=`${this.basePath}/${e}`).endsWith(\"/\")){const t=e.lastIndexOf(\"/\");e.lastIndexOf(\".\")>t&&(i=e.substring(t+1),e=e.substring(0,t+1))}return t&&this.#d(e),e+i}exists(e=\"\"){return e=this.filePath(e,!1),!!$file.exists(e)}write(e=\"\",t){return new Promise(((i,r)=>{try{const s=this.writeSync(e,t);s?i(s):r(s)}catch(e){r(e)}}))}writeSync(e=\"\",t){if(!t)throw new i(\"data\");return $file.write({data:t,path:this.filePath(e)})}read(e=\"\"){return new Promise(((t,i)=>{try{const r=this.readSync(e);r?t(r):i()}catch(e){i(e)}}))}readSync(e=\"\"){if(e=this.filePath(e),!$file.exists(e))throw new r(e);return $file.isDirectory(e)?$file.list(e):$file.read(e)}readAsJSON(e=\"\",t=null){try{const t=this.readSync(e)?.string;return JSON.parse(t)}catch(e){return t}}static readFromRoot(e=\"\"){return new Promise(((t,i)=>{try{const r=s.readFromRootSync(e);r?t(r):i()}catch(e){i(e)}}))}static readFromRootSync(e=\"\"){if(!e)throw new i(\"path\");if(!$file.exists(e))throw new r(e);return $file.isDirectory(e)?$file.list(e):$file.read(e)}static readFromRootAsJSON(e=\"\",t=null){try{const t=s.readFromRootSync(e)?.string;return JSON.parse(t)}catch(e){return t}}delete(e=\"\"){return $file.delete(this.filePath(e,!1))}copy(e,t){e=this.filePath(e),t=this.filePath(t),$file.copy({src:e,dst:t})}move(e,t){e=this.filePath(e),t=this.filePath(t),$file.move({src:e,dst:t})}}e.exports={FileStorageParameterError:i,FileStorageFileNotFoundError:r,FileStorage:s}})),parcelRequire.register(\"cgaQ6\",(function(e,t){var i=parcelRequire(\"czAIJ\").VERSION;class r{startTime=Date.now();isUseJsboxNav=!1;title=$addin?.current?.name;constructor(){$app.isDebugging&&this.debug()}static isTaio=$app.info.bundleID.includes(\"taio\");static l10n(e,t,i=!0){if(\"string\"==typeof t){const e={};t.split(\";\").forEach((t=>{if(\"\"!==(t=t.trim())){const i=t.split(\"=\");e[i[0].trim().slice(1,-1)]=i[1].trim().slice(1,-1)}})),t=e}const r=$app.strings;r[e]=i?Object.assign($app.strings[e],t):Object.assign(t,$app.strings[e]),$app.strings=r}static compressImage(e,t=921600){const i=$imagekit.info(e);if(i.height*i.width>t){const r=t/(i.height*i.width);e=$imagekit.scaleBy(e,r)}return e}static objectEqual(e,t){let i=Object.getOwnPropertyNames(e),s=Object.getOwnPropertyNames(t);if(i.length!==s.length)return!1;for(let s=0;se?i[e]:0,s=isNaN(Number(t))?t.charCodeAt():Number(t),n=r.length>e?r[e]:0,o=isNaN(Number(n))?n.charCodeAt():Number(n);if(so){a=1;break}}return a}static deleteConfirm(e,t){$ui.alert({title:$l10n(\"DELETE_CONFIRM_TITLE\"),message:e,actions:[{title:$l10n(\"DELETE\"),style:$alertActionType.destructive,handler:()=>{t()}},{title:$l10n(\"CANCEL\")}]})}static bytesToSize(e){if(0===e)return\"0 B\";const t=Math.floor(Math.log(e)/Math.log(1024));return(e/Math.pow(1024,t)).toPrecision(3)+\" \"+[\"B\",\"KB\",\"MB\",\"GB\",\"TB\",\"PB\",\"EB\",\"ZB\",\"YB\"][t]}debug(e,t){this.debugMode=!0,$app.idleTimerDisabled=!0,\"function\"==typeof e&&(this.debugPrint=e),\"function\"==typeof t&&(this.debugError=t),this.print(\"You are running EasyJsBox in debug mode.\")}print(e){this.debugMode&&(\"function\"==typeof this.debugPrint?this.debugPrint(e):console.log(e))}error(e){this.debugMode&&(\"function\"==typeof this.debugError?this.debugError(e):console.error(e))}useJsboxNav(){return this.isUseJsboxNav=!0,this}setTitle(e){this.isUseJsboxNav&&($ui.title=e),this.title=e}setNavButtons(e){this.navButtons=e}openInJsbox(){$app.openURL(`jsbox://run?name=${this.title}`)}UIRender(e){try{e.props=Object.assign({title:this.title,navBarHidden:!this.isUseJsboxNav,navButtons:this.navButtons??[],statusBarStyle:0},e.props),e.events||(e.events={});const t=e.events.layoutSubviews,{UIKit:i}=parcelRequire(\"45Ip7\");e.events.layoutSubviews=()=>{$app.notify({name:\"interfaceOrientationEvent\",object:{statusBarOrientation:i.statusBarOrientation,isHorizontal:i.isHorizontal}}),\"function\"==typeof t&&t()},$ui.render(e)}catch(e){this.print(e)}}async checkUpdate(){const e=await $http.get(\"https://raw.githubusercontent.com/ipuppet/EasyJsBox/dev/src/version.js\");if(e.error)throw e.error;const t=srcRes.data.match(/.*VERSION.?\\\"([0-9\\.]+)\\\"/)[1];if(this.print(`easy-jsbox latest version: ${t}`),r.versionCompare(t,i)>0){const e=await $http.get(\"https://raw.githubusercontent.com/ipuppet/EasyJsBox/dev/dist/easy-jsbox.js\");if(e.error)throw e.error;return e.data}return!1}}r.l10n(\"zh-Hans\",{DELETE_CONFIRM_TITLE:\"删除前确认\"},!1),r.l10n(\"en\",{DELETE_CONFIRM_TITLE:\"Delete Confirmation\"},!1),e.exports={Kernel:r}})),parcelRequire.register(\"czAIJ\",(function(e,t){e.exports={VERSION:\"1.3.3\"}})),parcelRequire.register(\"aXWmO\",(function(e,t){var i=parcelRequire(\"6Xrbz\").ValidationError,r=parcelRequire(\"liCrE\").View,s=parcelRequire(\"45Ip7\").UIKit,a=parcelRequire(\"12xzj\").NavigationView,n=parcelRequire(\"dcStC\").NavigationBar,o=parcelRequire(\"gAYmG\").BarButtonItem;class l extends Error{constructor(){super(\"Please call setView(view) first.\"),this.name=\"SheetAddNavBarError\"}}class c extends i{constructor(e,t){super(e,t),this.name=\"SheetViewTypeError\"}}class h extends r{#p=()=>{};#u=()=>{};style=h.UIModalPresentationStyle.PageSheet;#g=!1;static UIModalPresentationStyle={Automatic:-2,FullScreen:0,PageSheet:1,FormSheet:2,CurrentContext:3,Custom:4,OverFullScreen:5,OverCurrentContext:6,Popover:7,BlurOverFullScreen:8};navigationView;init(){const{width:e,height:t}=$device.info.screen,i=$objc(\"UIView\").invoke(\"initWithFrame\",$rect(0,0,e,t)),r=$objc(\"UIViewController\").invoke(\"alloc.init\"),a=r.$view();return a.$setBackgroundColor(s.primaryViewBackgroundColor),a.$addSubview(i),r.$setModalPresentationStyle(this.style),r.$setModalInPresentation(this.#g),this.#p=()=>{a.jsValue().add(this.navigationView?.getPage().definition??this.view),$ui.vc.ocValue().invoke(\"presentViewController:animated:completion:\",r,!0,void 0)},this.#u=()=>r.invoke(\"dismissViewControllerAnimated:completion:\",!0,void 0),this}preventDismiss(){return this.#g=!0,this}setStyle(e){return this.style=e,this}setView(e={}){if(\"object\"!=typeof e)throw new c(\"view\",\"object\");return this.view=e,this}addNavBar({title:e=\"\",popButton:t={title:$l10n(\"DONE\")},rightButtons:i=[]}={}){if(void 0===this.view)throw new l;this.navigationView=new a;const r=new o;r.setEvents(Object.assign({tapped:()=>{this.dismiss(),\"function\"==typeof t.tapped&&t.tapped()}},t.events)).setAlign(s.align.left).setSymbol(t.symbol).setTitle(t.title).setColor(t.color).setMenu(t.menu);const c=r.definition.views[0];return c.layout=(e,t)=>{e.left.equalTo(t.super.safeArea).offset(15),e.centerY.equalTo(t.super.safeArea)},this.navigationView.navigationBar.setLargeTitleDisplayMode(n.largeTitleDisplayModeNever).pageSheetMode(),this.navigationView.navigationBarItems.addPopButton(\"\",c).setRightButtons(i),this.navigationView.setView(this.view).navigationBarTitle(e),this.view.props?.bgcolor&&this.navigationView?.getPage().setProp(\"bgcolor\",this.view.props?.bgcolor),this}present(){this.#p()}dismiss(){this.#u()}}e.exports={Sheet:h}})),parcelRequire.register(\"6Xrbz\",(function(e,t){class i extends Error{constructor(e,t){super(`The type of the parameter '${e}' must be '${t}'`),this.name=\"ValidationError\"}}e.exports={ValidationError:i}})),parcelRequire.register(\"liCrE\",(function(e,t){var i=parcelRequire(\"45Ip7\").UIKit;class r{id=$text.uuid;type;props;views;events;layout;#$=void 0;#f=null;constructor({type:e=\"view\",props:t={},views:i=[],events:r={},layout:s=$layout.fill}={}){this.type=e,this.props=t,this.views=i,this.events=r,this.layout=s,this.props.id?this.id=this.props.id:this.props.id=this.id}static create(e){return new this(e)}static createFromViews(e){return new this({views:e})}get scrollableView(){return this.scrollable?this.#f:null}set scrollableView(e){this.#f=e}get scrollable(){if(void 0===this.#$)if(this.#$=!1,i.scrollViewList.indexOf(this.type)>-1)this.scrollableView=this,this.#$=!0;else if(this.views.length>0){const e=t=>{if(!this.#$&&t?.length>0)for(let s=0;s-1)return typeof t[s]!==r&&(t[s]=r.create(t[s])),this.scrollableView=t[s],void(this.#$=!0);e(t[s].views)}};e(this.views)}return this.#$}set scrollable(e){throw new Error(\"[scrollable] is readonly prop.\")}setProps(e){return Object.keys(e).forEach((t=>this.setProp(t,e[t]))),this}setProp(e,t){return\"id\"===e&&(this.id=t),this.props[e]=t,this}setViews(e){return this.views=e,this.#$=void 0,this}setEvents(e){return Object.keys(e).forEach((t=>this.setEvent(t,e[t]))),this}setEvent(e,t){return this.events[e]=t,this}eventMiddleware(e,t){const i=this.events[e];return this.events[e]=(...e)=>{\"function\"==typeof i&&t(i,...e)},this}assignEvent(e,t){const i=this.events[e];return this.events[e]=(...e)=>{\"function\"==typeof i&&i(...e),t(...e)},this}setLayout(e){return this.layout=e,this}getView(){return this}get definition(){return this.getView()}}e.exports={View:r,PageView:class extends r{constructor(e={}){super(e),this.activeStatus=!0}show(){$(this.props.id).hidden=!1,this.activeStatus=!0}hide(){$(this.props.id).hidden=!0,this.activeStatus=!1}setHorizontalSafeArea(e){return this.horizontalSafeArea=e,this}#b(e,t){e.top.bottom.equalTo(t.super),this.horizontalSafeArea?e.left.right.equalTo(t.super.safeArea):e.left.right.equalTo(t.super)}getView(){return this.layout=this.#b,this.props.clipsToBounds=!0,this.props.hidden=!this.activeStatus,super.getView()}}}})),parcelRequire.register(\"12xzj\",(function(e,t){var i=parcelRequire(\"fYz8N\").Controller,r=parcelRequire(\"liCrE\"),s=r.View,a=r.PageView,n=parcelRequire(\"6Xrbz\").ValidationError,o=parcelRequire(\"cgaQ6\").Kernel,l=parcelRequire(\"45Ip7\").UIKit,c=parcelRequire(\"dcStC\"),h=c.NavigationBar,d=c.NavigationBarController,p=parcelRequire(\"gAYmG\").NavigationBarItems;class u extends n{constructor(e,t){super(e,t),this.name=\"NavigationViewTypeError\"}}e.exports={NavigationView:class extends i{page;navigationController=new d;navigationBar=new h;navigationBarItems=new p;constructor(){super(),this.navigationBar.navigationBarItems=this.navigationBarItems,this.navigationController.navigationBar=this.navigationBar}navigationBarTitle(e){return this.navigationBar.setTitle(e),this}setView(e){if(\"object\"!=typeof e)throw new u(\"view\",\"object\");return this.view=s.create(e),this}#y(){if(!(this.view instanceof s))throw new u(\"view\",\"View\");const e=this.view.scrollableView,t=$app.isDebugging||o.isTaio?0:l.topSafeAreaInsets,i=this.navigationBar.largeTitleDisplayMode===h.largeTitleDisplayModeNever?this.navigationBar.navigationBarNormalHeight:this.navigationBar.navigationBarLargeTitleHeight;let r=this.navigationBar.contentViewHeightOffset+i;if(this.navigationBarItems.titleView&&(r+=this.navigationBarItems.titleView.topOffset,r+=this.navigationBarItems.titleView.height,r+=this.navigationBarItems.titleView.bottomOffset),!this.view.scrollable||!1===e.props.associateWithNavigationBar)return void(this.view.layout=(e,i)=>{e.left.right.equalTo(i.super.safeArea),e.bottom.equalTo(i.super);let s=r-this.navigationBar.contentViewHeightOffset;l.isHorizontal&&!l.isLargeScreen||!this.navigationBar.topSafeArea||(s+=t),e.top.equalTo(s)});e.props.stickyHeader&&(r-=i,r+=this.navigationBar.largeTitleFontHeight),e.props.header?e.props.header={type:\"view\",props:{height:r+(e.props.header?.props?.height??0)},views:[{type:\"view\",props:{clipsToBounds:!0},views:[e.props.header],layout:(e,t)=>{e.top.equalTo(r),e.bottom.width.equalTo(t.super)}}]}:e.props.header={props:{height:r}},e.props.footer=Object.assign({props:{}},e.props.footer??{}),e.props.footer.props.height=(this.navigationBarItems.fixedFooterView?.height??0)+(e.props.footer.props?.height??0);const a=this.navigationBarItems.isPinTitleView?this.navigationBarItems.titleView.height+this.navigationBarItems.titleView.bottomOffset+this.navigationBar.contentViewHeightOffset:0;if(e.props.indicatorInsets){const t=e.props.indicatorInsets;e.props.indicatorInsets=$insets(t.top+this.navigationBar.navigationBarNormalHeight+a,t.left,t.bottom+(this.navigationBarItems.fixedFooterView?.height??0),t.right)}else e.props.indicatorInsets=$insets(this.navigationBar.navigationBarNormalHeight+a,0,this.navigationBarItems.fixedFooterView?.height??0,0);e.layout=(t,i)=>{e.props.stickyHeader?t.top.equalTo(i.super.safeArea).offset(this.navigationBar.navigationBarNormalHeight):t.top.equalTo(i.super),t.left.right.equalTo(i.super.safeArea),t.bottom.equalTo(i.super)},e.assignEvent(\"didScroll\",(i=>{let r=i.contentOffset.y;l.isHorizontal&&!l.isLargeScreen||!this.navigationBar.topSafeArea||e.props.stickyHeader||(r+=t),this.navigationController.didScroll(r)})).assignEvent(\"didEndDragging\",((i,r)=>{let s=i.contentOffset.y,a=0;l.isHorizontal&&!l.isLargeScreen||!this.navigationBar.topSafeArea||e.props.stickyHeader||(s+=t,a=t),this.navigationController.didEndDragging(s,r,((...e)=>i.scrollToOffset(...e)),a)})).assignEvent(\"didEndDecelerating\",((...t)=>{t[0].tracking||e.events?.didEndDragging(...t)}))}#m(){if(this.navigationBar.prefersLargeTitles){this.#y();let e={};if(this.navigationBarItems.titleView){const t=this.navigationBar.largeTitleDisplayMode===h.largeTitleDisplayModeNever?1:0;e=s.create({views:[this.navigationBar.backgroundColor?{type:\"view\",props:{alpha:t,bgcolor:this.navigationBar.backgroundColor,id:this.navigationBar.id+\"-title-view-background\"},layout:$layout.fill}:l.blurBox({alpha:t,id:this.navigationBar.id+\"-title-view-background\"}),l.separatorLine({id:this.navigationBar.id+\"-title-view-underline\",alpha:t}),this.navigationBarItems.titleView.definition],layout:(e,t)=>{e.top.equalTo(t.prev.bottom),e.width.equalTo(t.super),e.height.equalTo(this.navigationBarItems.titleView.topOffset+this.navigationBarItems.titleView.height+this.navigationBarItems.titleView.bottomOffset)}})}this.page=a.createFromViews([this.view,this.navigationBar.getLargeTitleView(),e,this.navigationBar.getNavigationBarView(),this.navigationBarItems.fixedFooterView?.definition??{}])}else this.page=a.createFromViews([this.view]);this.view.props?.bgcolor?this.page.setProp(\"bgcolor\",this.view.props.bgcolor):this.page.setProp(\"bgcolor\",l.defaultBackgroundColor(this.view.type))}getPage(){return this.page||this.#m(),this.page}}}})),parcelRequire.register(\"dcStC\",(function(e,t){var i=parcelRequire(\"liCrE\").View,r=parcelRequire(\"fYz8N\").Controller,s=parcelRequire(\"45Ip7\").UIKit;parcelRequire(\"gAYmG\").BarButtonItem;class a extends i{static largeTitleDisplayModeAutomatic=0;static largeTitleDisplayModeAlways=1;static largeTitleDisplayModeNever=2;static pageSheetNavigationBarHeight=56;navigationBarItems;title=\"\";prefersLargeTitles=!0;largeTitleDisplayMode=a.largeTitleDisplayModeAutomatic;largeTitleFontSize=34;largeTitleFontFamily=\"bold\";largeTitleFontHeight=$text.sizeThatFits({text:\"A\",width:100,font:$font(this.largeTitleFontFamily,this.largeTitleFontSize)}).height;navigationBarTitleFontSize=17;topSafeArea=!0;contentViewHeightOffset=10;navigationBarNormalHeight=s.NavigationBarNormalHeight;navigationBarLargeTitleHeight=s.NavigationBarLargeTitleHeight;pageSheetMode(){return this.navigationBarLargeTitleHeight-=this.navigationBarNormalHeight,this.navigationBarNormalHeight=a.pageSheetNavigationBarHeight,this.navigationBarLargeTitleHeight+=this.navigationBarNormalHeight,this.topSafeArea=!1,this}setTopSafeArea(){return this.topSafeArea=!0,this}removeTopSafeArea(){return this.topSafeArea=!1,this}setLargeTitleDisplayMode(e){return this.largeTitleDisplayMode=e,this}setBackgroundColor(e){return this.backgroundColor=e,this}setTitle(e){return this.title=e,this}setPrefersLargeTitles(e){return this.prefersLargeTitles=e,this}setContentViewHeightOffset(e){return this.contentViewHeightOffset=e,this}getLargeTitleView(){return this.prefersLargeTitles&&this.largeTitleDisplayMode!==a.largeTitleDisplayModeNever?{type:\"label\",props:{id:this.id+\"-large-title\",text:this.title,textColor:s.textColor,align:$align.left,font:$font(this.largeTitleFontFamily,this.largeTitleFontSize),line:1},layout:(e,t)=>{e.left.equalTo(t.super.safeArea).offset(15),e.height.equalTo(this.largeTitleFontHeight),e.top.equalTo(t.super.safeAreaTop).offset(this.navigationBarNormalHeight)}}:{props:{id:this.id+\"-large-title\"},layout:(e,t)=>{e.left.top.right.inset(0),e.bottom.equalTo(t.super.safeAreaTop).offset(this.navigationBarNormalHeight)}}}getNavigationBarView(){const e=(e,t)=>{let i=0;const r=[];return e.forEach((e=>{i+=e.width,r.push(e.definition)})),i+=e[0]?.edges??0,e.length>0?{type:\"view\",views:r,layout:(e,r)=>{e.top.equalTo(r.super.safeAreaTop),e.bottom.equalTo(r.super.safeAreaTop).offset(this.navigationBarNormalHeight),t===s.align.left?e.left.equalTo(r.super.safeArea):e.right.equalTo(r.super.safeArea),e.width.equalTo(i)}}:{}},t=e(this.navigationBarItems.rightButtons,s.align.right),i=this.navigationBarItems.popButtonView??e(this.navigationBarItems.leftButtons,s.align.left),r=this.prefersLargeTitles,n=!this.prefersLargeTitles||this.largeTitleDisplayMode===a.largeTitleDisplayModeNever;return{type:\"view\",props:{id:this.id+\"-navigation\",bgcolor:$color(\"clear\")},layout:(e,t)=>{e.left.top.right.inset(0),e.bottom.equalTo(t.super.safeAreaTop).offset(this.navigationBarNormalHeight)},views:[this.backgroundColor?{type:\"view\",props:{hidden:r,bgcolor:this.backgroundColor,id:this.id+\"-background\"},layout:$layout.fill}:s.blurBox({hidden:r,id:this.id+\"-background\"}),s.separatorLine({id:this.id+\"-underline\",alpha:r?0:1}),{type:\"view\",props:{alpha:0,bgcolor:$color(\"clear\"),id:this.id+\"-large-title-mask\"},events:{ready:e=>{e.bgcolor=$(this.id+\"-large-title\")?.prev.bgcolor}},layout:$layout.fill},{type:\"label\",props:{id:this.id+\"-small-title\",alpha:n?1:0,text:this.title,font:$font(this.largeTitleFontFamily,this.navigationBarTitleFontSize),align:$align.center,bgcolor:$color(\"clear\"),textColor:s.textColor},layout:(e,t)=>{e.left.right.inset(0),e.height.equalTo(20),e.centerY.equalTo(t.super.safeArea)}}].concat(t,i)}}}class n extends r{static largeTitleViewSmallMode=0;static largeTitleViewLargeMode=1;navigationBar;updateSelector(){this.selector={navigation:$(this.navigationBar.id+\"-navigation\"),largeTitleView:$(this.navigationBar.id+\"-large-title\"),smallTitleView:$(this.navigationBar.id+\"-small-title\"),underlineView:this.navigationBar.navigationBarItems.isPinTitleView?$(this.navigationBar.id+\"-title-view-underline\"):$(this.navigationBar.id+\"-underline\"),largeTitleMaskView:$(this.navigationBar.id+\"-large-title-mask\"),backgroundView:$(this.navigationBar.id+\"-background\"),titleViewBackgroundView:$(this.navigationBar.id+\"-title-view-background\")}}toNormal(e=!0){this.updateSelector(),this.selector.backgroundView.hidden=!1,$ui.animate({duration:.2,animation:()=>{this.selector.underlineView.alpha=1,this.selector.smallTitleView.alpha=1,this.selector.largeTitleView.alpha=0}}),e&&this.navigationBar.navigationBarItems&&(this.navigationBar.largeTitleDisplayMode=a.largeTitleDisplayModeNever)}toLargeTitle(e=!0){this.updateSelector(),this.selector.backgroundView.hidden=!0,$ui.animate({duration:.2,animation:()=>{this.selector.underlineView.alpha=0,this.selector.smallTitleView.alpha=0,this.selector.largeTitleView.alpha=1}}),e&&this.navigationBar.navigationBarItems&&(this.navigationBar.largeTitleDisplayMode=a.largeTitleDisplayModeAlways)}#v(e){const t=e===n.largeTitleViewSmallMode;this.selector.largeTitleView.alpha=t?0:1,$ui.animate({duration:.2,animation:()=>{this.selector.smallTitleView.alpha=t?1:0}})}#w(e){if(this.selector.largeTitleView.updateLayout(((t,i)=>{this.navigationBar.navigationBarNormalHeight-e>0?t.top.equalTo(i.super.safeAreaTop).offset(this.navigationBar.navigationBarNormalHeight-e):t.top.equalTo(i.super.safeAreaTop).offset(0)})),e>0)e>=this.navigationBar.navigationBarNormalHeight?this.#v(n.largeTitleViewSmallMode):this.#v(n.largeTitleViewLargeMode);else{this.#v(n.largeTitleViewLargeMode);let t=this.navigationBar.largeTitleFontSize-.04*e;t>40&&(t=40),this.selector.largeTitleView.font=$font(this.navigationBar.largeTitleFontFamily,t)}}#T(e){const t=this.navigationBar.largeTitleDisplayMode===a.largeTitleDisplayModeNever?5:this.navigationBar.navigationBarNormalHeight,i=void 0!==this.selector.titleViewBackgroundView;if(e>t){this.selector.backgroundView.hidden=!1;const r=()=>{i&&this.navigationBar.navigationBarItems.isPinTitleView&&(this.selector.titleViewBackgroundView.alpha=1),this.selector.largeTitleMaskView.alpha=0,this.selector.underlineView.alpha=1};(e-t)/3>=1?r():$ui.animate({duration:.2,animation:()=>{r()}})}else this.selector.largeTitleMaskView.alpha=e>0?1:0,this.selector.underlineView.alpha=0,i&&(this.selector.titleViewBackgroundView.alpha=0),this.selector.backgroundView.hidden=!0}didScroll(e){if(!this.navigationBar.prefersLargeTitles)return;const t=this.navigationBar.largeTitleDisplayMode;t!==a.largeTitleDisplayModeAlways&&(this.updateSelector(),t===a.largeTitleDisplayModeAutomatic?(!this.navigationBar.navigationBarItems?.isPinTitleView&&(this.navigationBar.navigationBarItems?.titleView?.controller.didScroll(e),e>0)&&(e-=this.navigationBar.navigationBarItems?.titleView?.height??0)<0&&(e=0),this.#w(e),this.#T(e)):t===a.largeTitleDisplayModeNever&&this.#T(e))}didEndDragging(e,t,i,r){if(!this.navigationBar.prefersLargeTitles)return;const s=this.navigationBar.largeTitleDisplayMode;if(s!==a.largeTitleDisplayModeAlways&&(this.updateSelector(),s===a.largeTitleDisplayModeAutomatic)){let s=0;this.navigationBar.navigationBarItems?.isPinTitleView||(this.navigationBar.navigationBarItems?.titleView?.controller.didEndDragging(e,t,i,r),s=this.navigationBar.navigationBarItems?.titleView?.height??0,e-=s),e>=0&&e<=this.navigationBar.largeTitleFontHeight&&i($point(0,e>=this.navigationBar.largeTitleFontHeight/2?this.navigationBar.navigationBarNormalHeight+s-r:s-r))}}}e.exports={NavigationBar:a,NavigationBarController:n}})),parcelRequire.register(\"gAYmG\",(function(e,t){var i=parcelRequire(\"liCrE\").View,r=parcelRequire(\"45Ip7\").UIKit;class s extends i{static#E;edges=15;iconSize=$size(23,23);fontSize=16;color=r.textColor;title;symbol;align=r.align.right;get width(){if(this.title){const e=$text.sizeThatFits({text:this.title,width:r.windowSize.width,font:$font(this.fontSize)});return Math.ceil(e.width)+this.edges}return this.iconSize.width+this.edges}static get style(){return void 0===this.#E&&(this.#E=new s),this.#E}setEdges(e){return this.edges=e,this}setFontSize(e){return this.fontSize=e,this}setColor(e=r.textColor){return this.color=e,this}setTitle(e){return this.title=e,this}setSymbol(e){return this.symbol=e,this}setMenu(e){return this.menu=e,this}setAlign(e){return this.align=e,this}#I(){$(this.id).hidden=!0,$(\"spinner-\"+this.id).hidden=!1}#C(){const e=$(`icon-button-${this.id}`),t=$(`icon-checkmark-${this.id}`);e.alpha=0,$(this.id).hidden=!1,$(\"spinner-\"+this.id).hidden=!0,$ui.animate({duration:.6,animation:()=>{t.alpha=1},completion:()=>{$delay(.3,(()=>$ui.animate({duration:.6,animation:()=>{t.alpha=0},completion:()=>{$ui.animate({duration:.4,animation:()=>{e.alpha=1},completion:()=>{e.alpha=1}})}})))}})}#A(){$(this.id).hidden=!1,$(\"spinner-\"+this.id).hidden=!0}getView(){const e=this.events.tapped;return this.events.tapped=t=>{e&&e({start:()=>this.#I(),done:()=>this.#C(),cancel:()=>this.#A()},t)},{type:\"view\",props:{info:{align:this.align}},views:[{type:\"button\",props:Object.assign({id:this.id,bgcolor:$color(\"clear\"),font:$font(this.fontSize),titleColor:this.color,contentEdgeInsets:$insets(0,0,0,0),titleEdgeInsets:$insets(0,0,0,0),imageEdgeInsets:$insets(0,0,0,0)},this.menu?{menu:this.menu}:{},this.title?{title:this.title}:{},this.props),views:[{type:\"image\",props:Object.assign({id:`icon-button-${this.id}`,hidden:void 0===this.symbol,tintColor:this.color},void 0===this.symbol?{}:\"string\"==typeof this.symbol?{symbol:this.symbol}:{data:this.symbol.png}),layout:(e,t)=>{e.center.equalTo(t.super),e.size.equalTo(this.iconSize)}},{type:\"image\",props:{id:`icon-checkmark-${this.id}`,alpha:0,tintColor:this.color,symbol:\"checkmark\"},layout:(e,t)=>{e.center.equalTo(t.super),e.size.equalTo(this.iconSize)}}],events:this.events,layout:$layout.fill},{type:\"spinner\",props:{id:\"spinner-\"+this.id,loading:!0,hidden:!0},layout:$layout.fill}],layout:(e,t)=>{if(e.size.equalTo($size(this.width,r.NavigationBarNormalHeight)),e.centerY.equalTo(t.super),t.prev&&t.prev?.info?.align===this.align)this.align===r.align.right?e.right.equalTo(t.prev.left):e.left.equalTo(t.prev.right);else{const t=this.edges/2;this.align===r.align.right?e.right.inset(t):e.left.inset(t)}}}}static creat({symbol:e,title:t,tapped:i,menu:a,events:n,color:o,align:l=r.align.right}={}){const c=new s;return c.setEvents(Object.assign({tapped:i},n)).setAlign(l).setSymbol(e).setTitle(t).setColor(o).setMenu(a),c}}e.exports={BarTitleView:class extends i{controller={};setController(e){return this.controller=e,this}},BarButtonItem:s,NavigationBarItems:class{rightButtons=[];leftButtons=[];hasbutton=!1;isPinTitleView=!1;setTitleView(e){return this.titleView=e,this}pinTitleView(){return this.isPinTitleView=!0,this}setFixedFooterView(e){return this.fixedFooterView=e,this}setRightButtons(e){return e.forEach((e=>this.addRightButton(e))),this.hasbutton||(this.hasbutton=!0),this}setLeftButtons(e){return e.forEach((e=>this.addLeftButton(e))),this.hasbutton||(this.hasbutton=!0),this}addRightButton({symbol:e,title:t,tapped:i,menu:a,events:n,color:o}={}){return this.rightButtons.push(s.creat({symbol:e,title:t,tapped:i,menu:a,events:n,color:o,align:r.align.right})),this.hasbutton||(this.hasbutton=!0),this}addLeftButton({symbol:e,title:t,tapped:i,menu:a,events:n,color:o}={}){return this.leftButtons.push(s.creat({symbol:e,title:t,tapped:i,menu:a,events:n,color:o,align:r.align.left})),this.hasbutton||(this.hasbutton=!0),this}addPopButton(e,t,i){return e||(e=$l10n(\"BACK\")),this.popButtonView=t??{type:\"button\",props:{bgcolor:$color(\"clear\"),symbol:\"chevron.left\",tintColor:r.linkColor,title:` ${e}`,titleColor:r.linkColor,font:$font(\"bold\",16)},layout:(e,t)=>{e.left.equalTo(t.super.safeArea).offset(s.style.edges),e.centerY.equalTo(t.super.safeArea)},events:{tapped:()=>{$ui.pop(),\"function\"==typeof i&&i()}}},this}removePopButton(){return this.popButtonView=void 0,this}}}})),parcelRequire.register(\"gMc1q\",(function(e,t){var i=parcelRequire(\"fYz8N\").Controller;e.exports={ViewController:class extends i{#S=[];#x(e){e.callEvent(\"onPop\"),this.callEvent(\"onPop\",e),this.#S.pop()}push(e){const t=this.#S[this.#S.length-1];e.navigationBarItems.addPopButton(t?.navigationBar.title),this.#S.push(e),$ui.push({props:{statusBarStyle:0,navBarHidden:!0},events:{dealloc:()=>{this.#x(e)}},views:[e.getPage().definition],layout:$layout.fill})}}}})),String.prototype.trim=function(e,t){return e?\"l\"===t?this.replace(new RegExp(\"^\\\\\"+e+\"+\",\"g\"),\"\"):\"r\"===t?this.replace(new RegExp(\"\\\\\"+e+\"+$\",\"g\"),\"\"):this.replace(new RegExp(\"^\\\\\"+e+\"+|\\\\\"+e+\"+$\",\"g\"),\"\"):this.replace(/^\\s+|\\s+$/g,\"\")};var $czAIJ=parcelRequire(\"czAIJ\"),$bb0fea222fc5aea5$require$VERSION=$czAIJ.VERSION,$fYz8N=parcelRequire(\"fYz8N\"),$bb0fea222fc5aea5$require$Controller=$fYz8N.Controller,$272f042430a952c6$exports={},$45Ip7=parcelRequire(\"45Ip7\"),$272f042430a952c6$require$UIKit=$45Ip7.UIKit,$aXWmO=parcelRequire(\"aXWmO\"),$272f042430a952c6$require$Sheet=$aXWmO.Sheet,$cgaQ6=parcelRequire(\"cgaQ6\"),$272f042430a952c6$require$Kernel=$cgaQ6.Kernel,$12xzj=parcelRequire(\"12xzj\"),$272f042430a952c6$require$NavigationView=$12xzj.NavigationView,$dcStC=parcelRequire(\"dcStC\"),$272f042430a952c6$require$NavigationBar=$dcStC.NavigationBar;class $272f042430a952c6$var$FileManager{viewController;constructor(){this.listId=\"file-manager-list\",this.edges=10,this.iconSize=25,this.loadL10n()}loadL10n(){$272f042430a952c6$require$Kernel.l10n(\"zh-Hans\",{FILE_MANAGER_DELETE_CONFIRM_MSG:\"确认要删除吗\",DELETE:\"删除\",CANCEL:\"取消\",CLOSE:\"关闭\",SHARE:\"分享\",SAVE:\"保存\",SAVE_SUCCESS:\"保存成功\"},!1),$272f042430a952c6$require$Kernel.l10n(\"en\",{FILE_MANAGER_DELETE_CONFIRM_MSG:\"Are you sure you want to delete\",DELETE:\"Delete\",CANCEL:\"Cancel\",CLOSE:\"Close\",SHARE:\"Share\",SAVE:\"Save\",SAVE_SUCCESS:\"Save Success\"},!1)}setViewController(e){this.viewController=e}get menu(){return{items:[{title:$l10n(\"SHARE\"),symbol:\"square.and.arrow.up\",handler:async(e,t)=>{const i=e.object(t).info.info;$share.sheet([$file.absolutePath(i.path)])}}]}}delete(e){$file.delete(e.path)}edit(e){const t=$file.read(e.path);if(t.image)$quicklook.open({image:t.image});else{const i=new $272f042430a952c6$require$Sheet,r=$text.uuid;i.setView({type:\"code\",layout:$layout.fill,props:{id:r,lineNumbers:!0,theme:$device.isDarkMode?\"atom-one-dark\":\"atom-one-light\",text:t.string,insets:$insets(15,15,15,15)}}).addNavBar({title:e.file,popButton:{title:$l10n(\"CLOSE\")},rightButtons:[{title:$l10n(\"SAVE\"),tapped:()=>{$file.write({data:$data({string:$(r).text}),path:e.path}),$ui.success($l10n(\"SAVE_SUCCESS\"))}}]}),i.init().present()}}getFiles(e=\"\"){return $file.list(e).map((t=>{const i=e+\"/\"+t,r=$file.isDirectory(i);return{info:{info:{path:i,file:t,isDirectory:r}},icon:{symbol:r?\"folder.fill\":\"doc\"},name:{text:t},size:{text:r?\"\":\"--\"}}})).sort(((e,t)=>e.info.info.isDirectory!==t.info.info.isDirectory?e.info.info.isDirectory?-1:1:e.info.info.isDirectory===t.info.info.isDirectory?e.info.info.file.localeCompare(t.info.info.file):void 0))}async loadFileSize(e){return e.map(((t,i)=>{const r=t.info.info;if(!r.isDirectory)try{e[i].size.text=$272f042430a952c6$require$Kernel.bytesToSize($file.read(r.path).info.size)}catch(t){e[i].size.text=t}})),e}get listTemplate(){return{props:{bgcolor:$color(\"clear\")},views:[{props:{id:\"info\"}},{type:\"image\",props:{id:\"icon\"},layout:(e,t)=>{e.centerY.equalTo(t.super),e.left.inset(this.edges),e.size.equalTo(this.iconSize)}},{type:\"label\",props:{id:\"name\",lines:1},layout:(e,t)=>{e.centerY.equalTo(t.super),e.left.equalTo(t.prev.right).offset(this.edges)}},{type:\"label\",props:{id:\"size\",color:$color(\"secondaryText\"),lines:1},layout:(e,t)=>{e.centerY.equalTo(t.super),e.right.inset(this.edges)}}]}}#k(e,t){if(this.viewController){const i=new $272f042430a952c6$require$NavigationView;i.setView(t).navigationBarTitle(e),i.navigationBar.setLargeTitleDisplayMode($272f042430a952c6$require$NavigationBar.largeTitleDisplayModeNever),this.viewController.push(i)}else $272f042430a952c6$require$UIKit.push({title:e,views:[t]})}getListView(e=\"\"){return{type:\"list\",props:{id:this.listId,menu:this.menu,info:{basePath:e},bgcolor:$272f042430a952c6$require$UIKit.primaryViewBackgroundColor,separatorInset:$insets(0,this.edges,0,0),data:[],template:this.listTemplate,actions:[{title:\" \"+$l10n(\"DELETE\")+\" \",color:$color(\"red\"),handler:(e,t)=>{const i=e.object(t).info.info;$272f042430a952c6$require$Kernel.deleteConfirm($l10n(\"FILE_MANAGER_DELETE_CONFIRM_MSG\")+' \"'+i.file+'\" ?',(()=>{this.delete(i),e.delete(t)}))}}]},layout:$layout.fill,events:{ready:()=>{const t=this.getFiles(e);$(this.listId).data=t,this.loadFileSize(t).then((e=>{$(this.listId).data=e}))},pulled:async e=>{const t=this.getFiles($(this.listId).info.basePath);$(this.listId).data=t,$(this.listId).data=await this.loadFileSize(t),$delay(.5,(()=>{e.endRefreshing()}))},didSelect:(e,t,i)=>{const r=i.info.info;r.isDirectory?this.#k(r.file,this.getListView(r.path)):this.edit(r)}}}}push(e=\"\"){const t=e.substring(e.lastIndexOf(\"/\"));this.#k(t,this.getListView(e))}}$272f042430a952c6$exports={FileManager:$272f042430a952c6$var$FileManager};var $bb0fea222fc5aea5$require$FileManager=$272f042430a952c6$exports.FileManager,$8aDdQ=parcelRequire(\"8aDdQ\"),$bb0fea222fc5aea5$require$FileStorageParameterError=$8aDdQ.FileStorageParameterError,$bb0fea222fc5aea5$require$FileStorageFileNotFoundError=$8aDdQ.FileStorageFileNotFoundError,$bb0fea222fc5aea5$require$FileStorage=$8aDdQ.FileStorage,$4c192cc93140b629$exports={},$liCrE=parcelRequire(\"liCrE\"),$4c192cc93140b629$require$View=$liCrE.View,$45Ip7=parcelRequire(\"45Ip7\"),$4c192cc93140b629$require$UIKit=$45Ip7.UIKit;class $4c192cc93140b629$var$FixedFooterView extends $4c192cc93140b629$require$View{height=60;getView(){return this.type=\"view\",this.setProp(\"bgcolor\",$4c192cc93140b629$require$UIKit.primaryViewBackgroundColor),this.layout=(e,t)=>{e.left.right.bottom.equalTo(t.super),e.top.equalTo(t.super.safeAreaBottom).offset(-this.height)},this.views=[$4c192cc93140b629$require$View.create({props:this.props,views:this.views,layout:(e,t)=>{e.left.right.top.equalTo(t.super),e.height.equalTo(this.height)}})],this}}$4c192cc93140b629$exports={FixedFooterView:$4c192cc93140b629$var$FixedFooterView};var $bb0fea222fc5aea5$require$FixedFooterView=$4c192cc93140b629$exports.FixedFooterView,$cgaQ6=parcelRequire(\"cgaQ6\"),$bb0fea222fc5aea5$require$Kernel=$cgaQ6.Kernel,$50aa538fe0dbd3b0$exports={},$liCrE=parcelRequire(\"liCrE\"),$50aa538fe0dbd3b0$require$View=$liCrE.View;class $50aa538fe0dbd3b0$var$Matrix extends $50aa538fe0dbd3b0$require$View{titleStyle={font:$font(\"bold\",21),height:30};#B;#q;templateIdByIndex(e){return void 0===this.props.template.views[e]?.props?.id&&(void 0===this.props.template.views[e].props&&(this.props.template.views[e].props={}),this.props.template.views[e].props.id=$text.uuid),this.props.template.views[e].props.id}get templateHiddenStatus(){if(!this.#q){this.#q={};for(let e=0;e(e.items=e.items.map((e=>(Object.keys(e).forEach((t=>{e[t].hidden=this.templateHiddenStatus[t]??!1})),Object.keys(this.templateHiddenStatus).forEach((t=>{e[t]||(e[t]={}),e[t].hidden=this.templateHiddenStatus[t]})),e.__templateProps={hidden:!1},e.__title={hidden:!0},e))),e.title&&e.items.unshift(this.#R(e.title)),e)))}rebuildTemplate(){let e={};void 0!==this.props.template.props&&(e=Object.assign(this.props.template.props,{id:\"__templateProps\",hidden:!1})),this.props.template.props={};const t=[{type:\"view\",props:e,layout:$layout.fill},{type:\"label\",props:{id:\"__title\",hidden:!0,font:this.titleStyle.font},layout:(e,t)=>{e.top.inset(-this.titleStyle.height/4*3),e.height.equalTo(this.titleStyle.height),e.width.equalTo(t.super.safeArea)}}].concat(this.props.template.views);this.props.template.views=t}insert(e,t=!0){return e.indexPath=this.indexPath(e.indexPath,t),$(this.id).insert(e)}delete(e,t=!0){return e=this.indexPath(e,t),$(this.id).delete(e)}object(e,t=!0){return e=this.indexPath(e,t),$(this.id).object(e)}cell(e,t=!0){return e=this.indexPath(e,t),$(this.id).cell(e)}indexPath(e,t){let i=t?0:1;return\"number\"==typeof e&&(e=$indexPath(0,e)),$indexPath(e.section,e.row+i)}update(e){this.props.data=this.rebuildData(e),$(this.id).data=this.props.data}getView(){return this.props.data=this.rebuildData(this.props.data),this.rebuildTemplate(),this.setEvent(\"itemSize\",((e,t)=>{const i=e.object(t)?.__title?.info;if(i?.title)return $size(Math.max($device.info.screen.width,$device.info.screen.height),0);const r=this.props.columns??2,s=this.props.spacing??15,a=this.props.itemWidth??this.props.itemSize?.width??(e.super.frame.width-s*(r+1))/r,n=this.props.itemHeight??this.props.itemSize?.height??100;return $size(a,n)})),this}}$50aa538fe0dbd3b0$exports={Matrix:$50aa538fe0dbd3b0$var$Matrix};var $bb0fea222fc5aea5$require$Matrix=$50aa538fe0dbd3b0$exports.Matrix,$619319e3f3656d3f$exports={};class $619319e3f3656d3f$var$Request{static method={get:\"GET\",post:\"POST\",delete:\"DELETE\",patch:\"PATCH\",head:\"HEAD\"};cacheContainerKey=$addin?.current?.name+\".request.cache\";#D=!1;#O=!1;cacheLife=2592e6;isLogRequest=!1;timeout=5;logger;constructor(e){\"function\"==typeof e&&(this.logger=e)}get cache(){return $cache.get(this.cacheContainerKey)??{}}#N(e){this.isLogRequest&&\"function\"==typeof logger&&this.logger(e)}logRequest(e){return this.isLogRequest=!0,\"function\"==typeof e&&(this.logger=e),this}getCacheKey(e){return $text.MD5(e)}getCache(e,t=null){return this.cache[e]??t}setCache(e,t){if(!t)return;const i=this.cache;i[e]=t,$cache.set(this.cacheContainerKey,i)}removeCache(e){let t=this.cache;delete t[e],$cache.set(this.cacheContainerKey,t)}clearCache(){$cache.remove(this.cacheContainerKey)}useCache(){return this.#D=!0,this}ignoreCacheExp(){this.#O=!0}async request(e,t,i={},r={},s=this.cacheLife){let a;const n=this.#D&&t===$619319e3f3656d3f$var$Request.method.get;if(n){a=this.getCacheKey(e);const t=this.getCache(a);if(t&&(this.#O||t.exp>Date.now()))return this.#N(\"get data from cache: \"+e),t.data}try{this.#N(`sending request [${t}]: ${e}`);const o=await $http.request({header:r,url:e,method:t,body:i,timeout:this.timeout});if(o.error)throw o.error;if(o?.response?.statusCode>=400){let e=o.data;throw\"object\"==typeof e&&(e=JSON.stringify(e)),new Error(\"http error: [\"+o.response.statusCode+\"] \"+e)}return n&&this.setCache(a,{exp:Date.now()+s,data:o}),o}catch(e){throw e.code&&(e=new Error(\"network error: [\"+e.code+\"] \"+e.localizedDescription)),e}}}$619319e3f3656d3f$exports={Request:$619319e3f3656d3f$var$Request};var $bb0fea222fc5aea5$require$Request=$619319e3f3656d3f$exports.Request,$7D8Kb=parcelRequire(\"7D8Kb\"),$bb0fea222fc5aea5$require$Setting=$7D8Kb.Setting,$aXWmO=parcelRequire(\"aXWmO\"),$bb0fea222fc5aea5$require$Sheet=$aXWmO.Sheet,$7dfcabb1e936a92c$exports={},$liCrE=parcelRequire(\"liCrE\"),$7dfcabb1e936a92c$require$View=$liCrE.View,$7dfcabb1e936a92c$require$PageView=$liCrE.PageView,$fYz8N=parcelRequire(\"fYz8N\"),$7dfcabb1e936a92c$require$Controller=$fYz8N.Controller,$45Ip7=parcelRequire(\"45Ip7\"),$7dfcabb1e936a92c$require$UIKit=$45Ip7.UIKit;class $7dfcabb1e936a92c$var$TabBarCellView extends $7dfcabb1e936a92c$require$View{constructor(e={}){super(e),this.setIcon(e.icon),this.setTitle(e.title),void 0!==e.activeStatus&&(this.activeStatus=e.activeStatus)}setIcon(e){return this.icon=e instanceof Array?e:[e,e],this}setTitle(e){return this.title=e,this}active(){$(`${this.props.id}-icon`).image=$image(this.icon[1]),$(`${this.props.id}-icon`).tintColor=$color(\"systemLink\"),$(`${this.props.id}-title`).textColor=$color(\"systemLink\"),this.activeStatus=!0}inactive(){$(`${this.props.id}-icon`).image=$image(this.icon[0]),$(`${this.props.id}-icon`).tintColor=$color(\"lightGray\"),$(`${this.props.id}-title`).textColor=$color(\"lightGray\"),this.activeStatus=!1}getView(){return this.views=[{type:\"image\",props:{id:`${this.props.id}-icon`,image:$image(this.activeStatus?this.icon[1]:this.icon[0]),bgcolor:$color(\"clear\"),tintColor:$color(this.activeStatus?\"systemLink\":\"lightGray\")},layout:(e,t)=>{e.centerX.equalTo(t.super);const i=$7dfcabb1e936a92c$var$TabBarController.tabBarHeight/2;e.size.equalTo(i),e.top.inset(($7dfcabb1e936a92c$var$TabBarController.tabBarHeight-i-13)/2)}},{type:\"label\",props:{id:`${this.props.id}-title`,text:this.title,font:$font(10),textColor:$color(this.activeStatus?\"systemLink\":\"lightGray\")},layout:(e,t)=>{e.centerX.equalTo(t.prev),e.top.equalTo(t.prev.bottom).offset(3)}}],this}}class $7dfcabb1e936a92c$var$TabBarHeaderView extends $7dfcabb1e936a92c$require$View{height=60;getView(){return this.type=\"view\",this.setProp(\"bgcolor\",this.props.bgcolor??$7dfcabb1e936a92c$require$UIKit.primaryViewBackgroundColor),this.layout=(e,t)=>{e.left.right.bottom.equalTo(t.super),e.top.equalTo(t.super.safeAreaBottom).offset(-this.height-$7dfcabb1e936a92c$var$TabBarController.tabBarHeight)},this.views=[$7dfcabb1e936a92c$require$View.create({props:this.props,views:this.views,layout:(e,t)=>{e.left.right.top.equalTo(t.super),e.height.equalTo(this.height)}})],this}}class $7dfcabb1e936a92c$var$TabBarController extends $7dfcabb1e936a92c$require$Controller{static tabBarHeight=50;#L={};#_={};#V;#P;#M=$text.uuid;#F=$text.uuid;bottomSafeAreaInsets=$app.isDebugging?0:$7dfcabb1e936a92c$require$UIKit.bottomSafeAreaInsets;get selected(){return this.#P}set selected(e){this.switchPageTo(e)}get contentOffset(){return $7dfcabb1e936a92c$var$TabBarController.tabBarHeight+(this.#V?.height??0)}setPages(e={}){return Object.keys(e).forEach((t=>this.setPage(t,e[t]))),this}setPage(e,t){return void 0===this.#P&&(this.#P=e),this.#L[e]=t instanceof $7dfcabb1e936a92c$require$PageView?t:$7dfcabb1e936a92c$require$PageView.create(t),this.#P!==e&&(this.#L[e].activeStatus=!1),this}switchPageTo(e){if(this.#L[e]){if(this.#P===e)return;$ui.animate({duration:.4,animation:()=>{this.#_[e].active()}}),this.#_[this.#P].inactive(),this.#L[this.#P].hide(),this.#L[e].show(),this.callEvent(\"onChange\",this.#P,e),this.#P=e,this.initBackground()}}hideBackground(e=!0){$(this.#F).hidden=!0,$ui.animate({duration:e?.2:1e-4,animation:()=>{$(this.#M).alpha=0}})}showBackground(e=!0){$(this.#F).hidden=!1,$ui.animate({duration:e?.2:1e-4,animation:()=>{$(this.#M).alpha=1}})}initBackground(){const e=this.#L[this.selected];e.scrollable&&$delay(0,(()=>{const t=$(e.id).get(e.scrollableView.id),i=t.contentOffset.y;t.contentSize.height+this.bottomSafeAreaInsets-t.frame.height-i<=0?this.hideBackground(!1):this.showBackground(!1)}))}setCells(e={}){return Object.keys(e).forEach((t=>this.setCell(t,e[t]))),this}setCell(e,t){return void 0===this.#P&&(this.#P=e),t instanceof $7dfcabb1e936a92c$var$TabBarCellView||(t=new $7dfcabb1e936a92c$var$TabBarCellView({props:{info:{key:e}},icon:t.icon,title:t.title,activeStatus:this.#P===e})),this.#_[e]=t,this}setHeader(e){return this.#V=e,this}#H(){const e=[];return Object.values(this.#_).forEach((t=>{t.setEvent(\"tapped\",(e=>{const t=e.info.key;this.switchPageTo(t)})),e.push(t.getView())})),e}#U(){return Object.values(this.#L).map((e=>{if(e.scrollable){const t=e.scrollableView;if(t.props.indicatorInsets){const e=t.props.indicatorInsets;t.props.indicatorInsets=$insets(e.top,e.left,e.bottom+this.contentOffset,e.right)}else t.props.indicatorInsets=$insets(0,0,this.contentOffset,0);t.props.footer=Object.assign({props:{}},t.props.footer??{}),t.props.footer.props.height?t.props.footer.props.height+=this.contentOffset:t.props.footer.props.height=this.contentOffset,\"function\"==typeof t.assignEvent&&t.assignEvent(\"didScroll\",(e=>{const t=e.contentOffset.y;e.contentSize.height+this.bottomSafeAreaInsets-e.frame.height-t<=1?this.hideBackground():this.showBackground()}))}return e.definition}))}generateView(){const e={type:\"view\",layout:(e,t)=>{e.centerX.equalTo(t.super),e.width.equalTo(t.super),e.top.equalTo(t.super.safeAreaBottom).offset(-$7dfcabb1e936a92c$var$TabBarController.tabBarHeight),e.bottom.equalTo(t.super)},views:[$7dfcabb1e936a92c$require$UIKit.blurBox({id:this.#M}),{type:\"stack\",layout:$layout.fillSafeArea,props:{axis:$stackViewAxis.horizontal,distribution:$stackViewDistribution.fillEqually,spacing:0,stack:{views:this.#H()}}},$7dfcabb1e936a92c$require$UIKit.separatorLine({id:this.#F},$7dfcabb1e936a92c$require$UIKit.align.top)],events:{ready:()=>this.initBackground()}};return $7dfcabb1e936a92c$require$View.createFromViews(this.#U().concat(this.#V?.definition??[],e))}}$7dfcabb1e936a92c$exports={TabBarCellView:$7dfcabb1e936a92c$var$TabBarCellView,TabBarHeaderView:$7dfcabb1e936a92c$var$TabBarHeaderView,TabBarController:$7dfcabb1e936a92c$var$TabBarController};var $bb0fea222fc5aea5$require$TabBarCellView=$7dfcabb1e936a92c$exports.TabBarCellView,$bb0fea222fc5aea5$require$TabBarHeaderView=$7dfcabb1e936a92c$exports.TabBarHeaderView,$bb0fea222fc5aea5$require$TabBarController=$7dfcabb1e936a92c$exports.TabBarController,$3839e9f9bae78bdd$exports={};class $3839e9f9bae78bdd$var$Tasks{#z={};addTask(e,t=0){const i=$text.uuid;return this.#z[i]=$delay(t,(async()=>{await e(),delete this.#z[i]})),i}cancelTask(e){this.#z[e].cancel()}clearTasks(){Object.values(this.#z).forEach((e=>e.cancel()))}}$3839e9f9bae78bdd$exports={Tasks:$3839e9f9bae78bdd$var$Tasks};var $bb0fea222fc5aea5$require$Tasks=$3839e9f9bae78bdd$exports.Tasks,$895b2d75ea56b5f0$exports={},$45Ip7=parcelRequire(\"45Ip7\"),$895b2d75ea56b5f0$require$UIKit=$45Ip7.UIKit;class $895b2d75ea56b5f0$var$Toast{static type={info:void 0,success:\"checkmark\",warning:\"exclamationmark.triangle\",error:\"xmark.circle\"};static edges=40;static iconSize=100;static labelTopMargin=10;width=Math.min(.6*$895b2d75ea56b5f0$require$UIKit.windowSize.width,260);labelWidth=this.width-2*$895b2d75ea56b5f0$var$Toast.edges;id=$text.uuid;#j=\"\";type=$895b2d75ea56b5f0$var$Toast.type.info;labelLines=2;font=$font(\"default\",26);constructor(e,t=$895b2d75ea56b5f0$var$Toast.type.info,i=2,r=$font(\"default\",26)){this.type=t,this.message=e,this.labelLines=i,this.font=r}get message(){return this.#j}set message(e){this.#j=e,this.fontHeight=$895b2d75ea56b5f0$require$UIKit.getContentSize(this.font,this.message,this.labelWidth,this.labelLines).height,this.height=(this.hasIcon?$895b2d75ea56b5f0$var$Toast.labelTopMargin+$895b2d75ea56b5f0$var$Toast.iconSize:0)+this.fontHeight+2*$895b2d75ea56b5f0$var$Toast.edges}get hasIcon(){return void 0!==this.type}get blurBox(){const e=$895b2d75ea56b5f0$require$UIKit.blurBox({id:this.id,cornerRadius:15,alpha:0},[{type:\"image\",props:{symbol:this.type,hidden:!this.hasIcon,tintColor:$color(\"lightGray\")},layout:(e,t)=>{e.top.inset($895b2d75ea56b5f0$var$Toast.edges),e.size.equalTo($895b2d75ea56b5f0$var$Toast.iconSize),e.centerX.equalTo(t.super)}},{type:\"label\",props:{font:this.font,text:this.message,align:$align.center,lines:this.labelLines,color:$color(\"lightGray\")},layout:(e,t)=>{e.bottom.equalTo(t.supper).offset(-$895b2d75ea56b5f0$var$Toast.edges),e.width.equalTo(this.labelWidth),e.height.equalTo(this.fontHeight),e.centerX.equalTo(t.super)}}]);return e.events={tapped:()=>{this.remove()}},e}show(){$ui.controller.view.insertAtIndex($ui.create(this.blurBox),0);const e=$(this.id);e.layout(((e,t)=>{e.center.equalTo(t.super),e.size.equalTo($size(this.width,this.height))})),e.moveToFront(),$ui.animate({duration:.2,animation:()=>{e.alpha=1}})}remove(){const e=$(this.id);e&&$ui.animate({duration:.2,animation:()=>{e.alpha=0},completion:()=>{e.remove()}})}static toast({message:e,type:t=$895b2d75ea56b5f0$var$Toast.type.info,displayTime:i=2,labelLines:r=2,font:s=$font(\"default\",26)}){const a=new $895b2d75ea56b5f0$var$Toast(e,t,r,s);a.show(),$delay(i,(()=>{a.remove()}))}static info(e,t={}){$895b2d75ea56b5f0$var$Toast.toast(Object.assign({message:e,type:$895b2d75ea56b5f0$var$Toast.type.info},t))}static success(e,t={}){$895b2d75ea56b5f0$var$Toast.toast(Object.assign({message:e,type:$895b2d75ea56b5f0$var$Toast.type.success},t))}static warning(e,t={}){$895b2d75ea56b5f0$var$Toast.toast(Object.assign({message:e,type:$895b2d75ea56b5f0$var$Toast.type.warning},t))}static error(e,t={}){$895b2d75ea56b5f0$var$Toast.toast(Object.assign({message:e,type:$895b2d75ea56b5f0$var$Toast.type.error},t))}}$895b2d75ea56b5f0$exports={Toast:$895b2d75ea56b5f0$var$Toast};var $bb0fea222fc5aea5$require$Toast=$895b2d75ea56b5f0$exports.Toast,$45Ip7=parcelRequire(\"45Ip7\"),$bb0fea222fc5aea5$require$UIKit=$45Ip7.UIKit,$86d2ffde19fb8791$exports={};class $86d2ffde19fb8791$var$UILoading{#K;text=\"\";interval;fullScreen=!1;#Y=()=>{};constructor(){this.#K=$text.uuid}updateText(e){$(this.#K).text=e}setLoop(e){if(\"function\"!=typeof e)throw\"loop must be a function\";this.#Y=e}done(){clearInterval(this.interval)}load(){$ui.render({props:{navBarHidden:this.fullScreen},views:[{type:\"spinner\",props:{loading:!0},layout:(e,t)=>{e.centerY.equalTo(t.super).offset(-15),e.width.equalTo(t.super)}},{type:\"label\",props:{id:this.#K,align:$align.center,text:\"\"},layout:(e,t)=>{e.top.equalTo(t.prev.bottom).offset(10),e.left.right.equalTo(t.super)}}],layout:$layout.fill,events:{appeared:()=>{this.interval=setInterval((()=>{this.#Y()}),100)}}})}}$86d2ffde19fb8791$exports={UILoading:$86d2ffde19fb8791$var$UILoading};var $bb0fea222fc5aea5$require$UILoading=$86d2ffde19fb8791$exports.UILoading,$6Xrbz=parcelRequire(\"6Xrbz\"),$bb0fea222fc5aea5$require$ValidationError=$6Xrbz.ValidationError,$liCrE=parcelRequire(\"liCrE\"),$bb0fea222fc5aea5$require$View=$liCrE.View,$bb0fea222fc5aea5$require$PageView=$liCrE.PageView,$gMc1q=parcelRequire(\"gMc1q\"),$bb0fea222fc5aea5$require$ViewController=$gMc1q.ViewController,$12xzj=parcelRequire(\"12xzj\"),$bb0fea222fc5aea5$require$NavigationView=$12xzj.NavigationView,$dcStC=parcelRequire(\"dcStC\"),$bb0fea222fc5aea5$require$NavigationBar=$dcStC.NavigationBar,$bb0fea222fc5aea5$require$NavigationBarController=$dcStC.NavigationBarController,$gAYmG=parcelRequire(\"gAYmG\"),$bb0fea222fc5aea5$require$NavigationBarItems=$gAYmG.NavigationBarItems,$bb0fea222fc5aea5$require$BarButtonItem=$gAYmG.BarButtonItem,$ee5e1f8d12d987dc$exports={},$fYz8N=parcelRequire(\"fYz8N\"),$ee5e1f8d12d987dc$require$Controller=$fYz8N.Controller,$gAYmG=parcelRequire(\"gAYmG\"),$ee5e1f8d12d987dc$require$BarTitleView=$gAYmG.BarTitleView;class $ee5e1f8d12d987dc$var$SearchBar extends $ee5e1f8d12d987dc$require$BarTitleView{height=35;topOffset=15;bottomOffset=10;kbType=$kbType.search;placeholder=$l10n(\"SEARCH\");inputEvents={};keyboardView;accessoryView;constructor(e){super(e),this.setController(new $ee5e1f8d12d987dc$var$SearchBarController),this.controller.setSearchBar(this)}setEvent(e,t){return this.inputEvents[e]=t,this}setPlaceholder(e){return this.placeholder=e,this}setKbType(e){return this.kbType=e,this}setKeyboardView(e){return this.keyboardView=e,this}setAccessoryView(e){return this.accessoryView=e,this}getView(){return this.props={id:this.id,smoothCorners:!0,cornerRadius:6,bgcolor:$color(\"#EEF1F1\",\"#212121\")},this.views=[{type:\"input\",props:{id:this.id+\"-input\",type:this.kbType,bgcolor:$color(\"clear\"),placeholder:this.placeholder,keyboardView:this.keyboardView,accessoryView:this.accessoryView},layout:$layout.fill,events:Object.assign({changed:e=>this.controller.callEvent(\"onChange\",e.text),returned:e=>this.controller.callEvent(\"onReturn\",e.text)},this.inputEvents)}],this.layout=(e,t)=>{e.height.equalTo(this.height),e.top.equalTo(t.super.safeArea).offset(this.topOffset),e.left.equalTo(t.super.safeArea).offset(15),e.right.equalTo(t.super.safeArea).offset(-15)},this}}class $ee5e1f8d12d987dc$var$SearchBarController extends $ee5e1f8d12d987dc$require$Controller{setSearchBar(e){return this.searchBar=e,this}updateSelector(){this.selector={inputBox:$(this.searchBar.id),input:$(this.searchBar.id+\"-input\")}}hide(){this.updateSelector(),this.selector.inputBox.updateLayout((e=>{e.height.equalTo(0)}))}show(){this.updateSelector(),this.selector.inputBox.updateLayout((e=>{e.height.equalTo(this.searchBar.height)}))}didScroll(e){this.updateSelector();let t=this.searchBar.height-e;if(t=t>0?t>this.searchBar.height?this.searchBar.height:t:0,this.selector.inputBox.updateLayout((e=>{e.height.equalTo(t)})),e>0){const t=(this.searchBar.height/2-5-e)/10;this.selector.input.alpha=t}else this.selector.input.alpha=1}didEndDragging(e,t,i){this.updateSelector(),e>=0&&e<=this.searchBar.height&&i($point(0,e>=this.searchBar.height/2?this.searchBar.height:0))}}$ee5e1f8d12d987dc$exports={SearchBar:$ee5e1f8d12d987dc$var$SearchBar,SearchBarController:$ee5e1f8d12d987dc$var$SearchBarController};var $bb0fea222fc5aea5$require$SearchBar=$ee5e1f8d12d987dc$exports.SearchBar,$bb0fea222fc5aea5$require$SearchBarController=$ee5e1f8d12d987dc$exports.SearchBarController;module.exports={VERSION:$bb0fea222fc5aea5$require$VERSION,Controller:$bb0fea222fc5aea5$require$Controller,FileManager:$bb0fea222fc5aea5$require$FileManager,FileStorageParameterError:$bb0fea222fc5aea5$require$FileStorageParameterError,FileStorageFileNotFoundError:$bb0fea222fc5aea5$require$FileStorageFileNotFoundError,FileStorage:$bb0fea222fc5aea5$require$FileStorage,FixedFooterView:$bb0fea222fc5aea5$require$FixedFooterView,Kernel:$bb0fea222fc5aea5$require$Kernel,Matrix:$bb0fea222fc5aea5$require$Matrix,Request:$bb0fea222fc5aea5$require$Request,Setting:$bb0fea222fc5aea5$require$Setting,Sheet:$bb0fea222fc5aea5$require$Sheet,TabBarCellView:$bb0fea222fc5aea5$require$TabBarCellView,TabBarHeaderView:$bb0fea222fc5aea5$require$TabBarHeaderView,TabBarController:$bb0fea222fc5aea5$require$TabBarController,Tasks:$bb0fea222fc5aea5$require$Tasks,Toast:$bb0fea222fc5aea5$require$Toast,UIKit:$bb0fea222fc5aea5$require$UIKit,UILoading:$bb0fea222fc5aea5$require$UILoading,ValidationError:$bb0fea222fc5aea5$require$ValidationError,View:$bb0fea222fc5aea5$require$View,PageView:$bb0fea222fc5aea5$require$PageView,ViewController:$bb0fea222fc5aea5$require$ViewController,NavigationView:$bb0fea222fc5aea5$require$NavigationView,NavigationBar:$bb0fea222fc5aea5$require$NavigationBar,NavigationBarController:$bb0fea222fc5aea5$require$NavigationBarController,NavigationBarItems:$bb0fea222fc5aea5$require$NavigationBarItems,BarButtonItem:$bb0fea222fc5aea5$require$BarButtonItem,SearchBar:$bb0fea222fc5aea5$require$SearchBar,SearchBarController:$bb0fea222fc5aea5$require$SearchBarController}})),parcelRequire.register(\"hOw2h\",(function(e,t){var i=parcelRequire(\"gxpqj\").Kernel;class r{sqlite;constructor(e){this.kernel=e,this.dbName=\"CAIO.db\",this.localDb=`/${this.dbName}`,this.imagePath=\"/image\",this.imageOriginalPath=`${this.imagePath}/original`,this.imagePreviewPath=`${this.imagePath}/preview`,this.tempPath=\"/temp\",this.tempDbFile=`${this.tempPath}/${this.dbName}`,this.tempImagePath=`${this.tempPath}/image`,this.exportFileName=\"CAIO.zip\",this.init()}init(){this.sqlite=$sqlite.open(this.kernel.fileStorage.filePath(this.localDb)),this.sqlite.update(\"CREATE TABLE IF NOT EXISTS clips(uuid TEXT PRIMARY KEY NOT NULL, text TEXT, md5 TEXT, prev TEXT, next TEXT)\"),this.sqlite.update(\"CREATE TABLE IF NOT EXISTS pin(uuid TEXT PRIMARY KEY NOT NULL, text TEXT, md5 TEXT, prev TEXT, next TEXT)\"),this.sqlite.update(\"CREATE TABLE IF NOT EXISTS tag(uuid TEXT PRIMARY KEY NOT NULL, tag TEXT)\")}rebuild(){const e=this.tempPath+\"/rebuild.db\";this.kernel.fileStorage.delete(e);const t=new r(this.kernel);t.localDb=e,t.init();const i=(e,i)=>{const r=[];e.forEach((e=>{const s={uuid:e.uuid,text:e.text,md5:e.md5,tag:e.tag,image:e.image,prev:null,next:r[0]?.uuid??null};t.beginTransaction();try{t.insert(i,s),s.next&&(r[0].prev=s.uuid,t.update(i,r[0])),t.commit(),r.unshift(s)}catch(e){throw t.rollback(),this.kernel.error(e),e}}))};[\"clips\",\"pin\"].map((e=>{let t=this.all(e);try{const e=this.sort(JSON.parse(JSON.stringify(t)));if(e.length>t.length)throw new Error;t=e.reverse()}catch{}i(t,e)}));const s=this.sqlite.query(\"SELECT * FROM tag\");this.parseTag(s).forEach((e=>{t.beginTransaction();try{t.setTag(e.uuid,e.tag),t.commit()}catch(e){throw t.rollback(),this.kernel.error(e),e}})),this.kernel.fileStorage.copy(e,this.localDb)}deleteAllData(){this.kernel.fileStorage.delete(this.imagePath),this.kernel.fileStorage.delete(this.localDb)}clearTemp(){this.kernel.fileStorage.delete(this.tempPath)}async export(e){this.clearTemp(),this.kernel.fileStorage.copy(this.localDb,this.tempDbFile),this.kernel.fileStorage.copy(this.imagePath,this.tempImagePath);const t=this.tempPath+\"/\"+this.exportFileName;await $archiver.zip({directory:this.kernel.fileStorage.filePath(this.tempPath),dest:this.kernel.fileStorage.filePath(t)}),$share.sheet({items:[{name:this.exportFileName,data:$data({path:this.kernel.fileStorage.filePath(t)})}],handler:i=>{this.kernel.fileStorage.delete(t),e(i)}})}async import(e){if(\"db\"===e.fileName.slice(-2)){if(!this.kernel.fileStorage.writeSync(this.localDb,e))throw new Error(\"WRITE_DB_FILE_FAILED\")}else if(\"zip\"===e.fileName.slice(-3)){if(!await $archiver.unzip({file:e,dest:this.kernel.fileStorage.filePath(this.tempPath)}))throw new Error(\"UNZIP_FAILED\");this.kernel.fileStorage.move(this.tempDbFile,this.localDb),this.kernel.fileStorage.move(this.tempImagePath,this.imagePath)}}sort(e,t=9e3){const i={};let r=0,s=null;e.forEach((e=>{i[e.uuid]=e,null===e.prev&&(s=e.uuid),r++}));const a=[];if(r>0)try{let e=i[s];for(;null!==e.next&&t>0;)t--,a.push(e),e=i[e.next];a.push(e)}catch(e){throw\"Unable to sort: \"+e}return a}parse(e){const t=e.result,i=e.error;if(null!==i)throw new Error(`Code [${i.code}] ${i.domain} ${i.localizedDescription}`);const r=[];for(;t.next();)r.push({uuid:t.get(\"uuid\"),section:t.get(\"section\"),text:t.get(\"text\"),md5:t.get(\"md5\"),tag:t.get(\"tag\")??\"\",prev:t.get(\"prev\")??null,next:t.get(\"next\")??null});return t.close(),r}parseTag(e){if(null!==e.error)throw e.error;const t=[];for(;e.result.next();)t.push({uuid:e.result.get(\"uuid\"),tag:e.result.get(\"tag\")});return e.result.close(),t}beginTransaction(){this.sqlite.beginTransaction()}commit(){this.sqlite.commit()}rollback(){this.sqlite.rollback()}getByUUID(e){e=e.replace(\"'\",\"\");const t=this.sqlite.query({sql:`\\n SELECT *, 'clips' AS section FROM clips WHERE uuid = '${e}'\\n UNION\\n SELECT *, 'pin' AS section FROM pin WHERE uuid = '${e}'\\n `});return this.parse(t)[0]}getByMD5(e){e=e.replace(\"'\",\"\");const t=this.sqlite.query({sql:`\\n SELECT *, 'clips' AS section FROM clips WHERE md5 = '${e}'\\n UNION\\n SELECT *, 'pin' AS section FROM pin WHERE md5 = '${e}'\\n `});return this.parse(t)[0]}search(e){const t=this.sqlite.query({sql:\"SELECT * from\\n (SELECT clips.*, 'clips' AS section FROM clips WHERE text like ?\\n UNION\\n SELECT pin.*, 'pin' AS section FROM pin WHERE text like ?) a\\n LEFT JOIN tag ON a.uuid = tag.uuid\\n \",args:[`%${e}%`,`%${e}%`]});return this.parse(t)}isImage(e){return e?.startsWith(\"@image=\")}pathToKey(e){return`@image=${e=JSON.stringify(e)}`}keyToPath(e){return!!this.isImage(e)&&JSON.parse(e.slice(7))}deleteTable(e){const t=this.sqlite.update(`DELETE FROM ${e}`);if(!t.result)throw t.error}all(e){const t=this.sqlite.query(`SELECT ${e}.*, tag, '${e}' AS section FROM ${e} LEFT JOIN tag ON ${e}.uuid = tag.uuid`);return this.parse(t)}insert(e,t){if(t.image){const e=t.image,r=$text.uuid,s={original:`${this.imageOriginalPath}/${r}.png`,preview:`${this.imagePreviewPath}/${r}.jpg`};this.kernel.fileStorage.write(s.original,e.png),this.kernel.fileStorage.write(s.preview,i.compressImage(e).jpg(.8)),t.text=this.pathToKey(s)}const r=this.sqlite.update({sql:`INSERT INTO ${e} (uuid, text, md5, prev, next) values (?, ?, ?, ?, ?)`,args:[t.uuid,t.text,$text.MD5(t.text),t.prev,t.next]});if(!r.result)throw r.error}update(e,t){if(Object.keys(t).length<4||\"string\"!=typeof t.uuid)return;const i=this.sqlite.update({sql:`UPDATE ${e} SET text = ?, md5 = ?, prev = ?, next = ? WHERE uuid = ?`,args:[t.text,$text.MD5(t.text),t.prev,t.next,t.uuid]});if(!i.result)throw i.error}updateText(e,t,i){if(\"string\"!=typeof t)return;const r=this.sqlite.update({sql:`UPDATE ${e} SET text = ?, md5 = ? WHERE uuid = ?`,args:[i,$text.MD5(i),t]});if(!r.result)throw r.error}delete(e,t){const i=this.getByUUID(t);this.beginTransaction();try{const i=this.sqlite.update({sql:`DELETE FROM ${e} WHERE uuid = ?`,args:[t]});if(!i.result)throw i.error;this.deleteTag(t),this.commit()}catch(e){throw this.rollback(),e}const r=this.keyToPath(i?.text);r&&(this.kernel.fileStorage.delete(r.original),this.kernel.fileStorage.delete(r.preview))}setTag(e,t){const i=this.sqlite.update({sql:\"INSERT OR REPLACE INTO tag (uuid, tag) values (?, ?)\",args:[e,t]});if(!i.result)throw i.error}deleteTag(e){const t=this.sqlite.update({sql:\"DELETE FROM tag WHERE uuid = ?\",args:[e]});if(!t.result)throw t.error}}e.exports=r})),parcelRequire.register(\"imdB1\",(function(e,t){var i=parcelRequire(\"gxpqj\"),r=i.View,s=i.Kernel,a=i.UIKit,n=i.Sheet,o=i.ViewController,l=i.NavigationView,c=i.NavigationBar,h=i.Toast,d=parcelRequire(\"f0nX9\"),p=parcelRequire(\"4ZHFw\"),u=parcelRequire(\"ay4Kj\"),g=parcelRequire(\"9LqeL\"),f=parcelRequire(\"eSp9Z\"),b=f.ActionData,y=f.ActionEnv;e.exports=class extends p{listId=\"clips-list\";#G=!1;#W=-1;left_right=20;top_bottom=20;containerMargin=0;fontSize=16;copiedIndicatorSize=7;imageContentHeight=50;tagFontSize=14;tagContainerHeight=25;menuItemActionMaxCount=5;tabHeight=44;copied=$cache.get(\"clips.copied\")??{};#J={};constructor(e){super(e),this.viewController=new o,this.search=new u(this.kernel),this.search.setCallback((e=>{(new n).setView(this.getListView(this.listId+\"-search-result\",e.map((e=>this.lineData(e))))).addNavBar({title:$l10n(\"SEARCH_RESULT\"),popButton:{title:$l10n(\"DONE\"),tapped:()=>this.search.dismiss()}}).init().present()}))}get singleLineHeight(){return this.#W<0&&(this.#W=$text.sizeThatFits({text:\"A\",width:this.fontSize,font:$font(this.fontSize)}).height),this.#W}setSingleLine(){this.#G=!0,this.imageContentHeight=this.singleLineHeight}getTextHeight(e){return this.#J[e]||(this.#J[e]=this.#G?this.singleLineHeight:Math.min($text.sizeThatFits({text:e,width:a.windowSize.width-2*(this.left_right+this.containerMargin),font:$font(this.fontSize)}).height,2*this.singleLineHeight)),this.#J[e]}appListen(){s.isTaio||$app.listen({resume:()=>{this.loadAllClips(),this.updateList(),$delay(.5,(()=>{this.readClipboard()}))}})}listReady(){this.updateList(),s.isTaio||($delay(.5,(()=>{if($context.query.copy){const e=$context.query.copy,t=this.kernel.storage.getByUUID(e);this.setClipboardText(t.text),this.setCopied(e,this.getRowByUUID(e)),$ui.success($l10n(\"COPIED\"))}else $context.query.add?this.getAddTextView():$context.query.actions&&(this.kernel.isUseJsboxNav?this.kernel.actionManager.present():this.kernel.tabBarController.switchPageTo(\"actions\"))})),$delay(.5,(()=>{this.readClipboard()})),this.appListen())}updateList(){$(this.listId).data=this.clips.map((e=>this.lineData(e,this.copied.uuid===e.uuid))),this.updateListBackground()}updateListBackground(){$(this.listId+\"-empty-list-background\").hidden=this.clips.length>0}updateCopied(e={}){Object.assign(this.copied,e),this.kernel.print(`this.copied: ${JSON.stringify(this.copied,null,2)}`),$cache.set(\"clips.copied\",this.copied)}setCopied(e,t,i=!0){if(!e||e===this.copied.uuid&&this.tabIndex===this.copied?.tabIndex&&t===this.copied?.row)return;let r={};this.copied.uuid!==e&&(r=this.kernel.storage.getByUUID(e)??{}),r.tabIndex=this.tabIndex,r.row=t;const s=this.copied.row;if(this.updateCopied(r),i){const e=$(this.listId);$delay(.3,(()=>{e.cell($indexPath(0,s)).get(\"copied\").hidden=!0,e.cell($indexPath(0,t)).get(\"copied\").hidden=!1}))}}readClipboard(e=!1){if(e||this.kernel.setting.get(\"clipboard.autoSave\")){if(this.kernel.print(\"read clipboard\"),!this.isChanged)return void(e&&$ui.toast($l10n(\"CLIPBOARD_NO_CHANGE\")));if(this.switchTab(1,!0),$clipboard.images?.length>0)return!!e&&($clipboard.images.forEach((e=>{this.add(e)})),!0);const t=$clipboard.text;if(!t||\"\"===t)return!1;if(this.copied.text===t)return!1;const i=$text.MD5(t);if(this.savedClipboardIndex[i]){const e=this.kernel.storage.getByMD5(i);this.setCopied(e.uuid,this.getRowByUUID(e.uuid))}else{const e=this.add(t);this.copy(t,e.uuid,0)}}return!1}add(e,t){try{const i=super.add(e);return\"function\"==typeof t?t(i):($(this.listId).insert({indexPath:$indexPath(0,0),value:this.lineData(i)}),this.copied?.tabIndex===this.tabIndex&&this.setCopied(this.copied.uuid,this.copied?.row+1,!1)),i}catch(e){$ui.alert(e)}}delete(e,t){try{super.delete(e,t),this.copied.uuid===e&&(this.copied={},$clipboard.clear())}catch(e){$ui.alert(e)}}update(e,t,i){return!!super.update(e,t,i)&&(this.updateList(),e===this.copied.uuid&&(this.setClipboardText(t),this.updateCopied({text:t})),!0)}move(e,t,i=!0){if(e!==t)try{if(super.move(e,t),!i)return;const r=$(this.listId);ee&&this.copied.rowt||this.copied.row===t)&&this.setCopied(this.copied.uuid,e{i.text?$share.sheet(i.text):$ui.warning($l10n(\"NONE\"))}}];if(this.kernel.isUseJsboxNav)i.uikitPush(e,(e=>t(e)),r);else{const s=i.getNavigationView(e,(e=>t(e)),r);this.viewController.push(s)}}getAddTextView(){this.edit(\"\",(e=>{\"\"!==e&&this.add(e)}))}menuItems(e=!1){const t=[{inline:!0,items:[{title:$l10n(\"TAG\"),symbol:\"tag\",handler:(e,t)=>{const i=this.clips[t.row].uuid;$input.text({placeholder:$l10n(\"ADD_TAG\"),text:e.text,handler:e=>{(e=e.trim()).length>0?this.kernel.storage.setTag(i,e):this.kernel.storage.deleteTag(i),this.loadAllClips(),this.updateList()}})}}]},{inline:!0,items:[{title:$l10n(\"SHARE\"),symbol:\"square.and.arrow.up\",handler:(e,t)=>{const i=this.clips[t.row].text;let r=i;const s=this.kernel.storage.keyToPath(i);if(s&&this.kernel.fileStorage.exists(s.original)){const e=this.kernel.fileStorage.readSync(s.original)?.image?.png;r={name:e.fileName,data:e}}$share.sheet([r])}},{title:$l10n(\"COPY\"),symbol:\"square.on.square\",handler:(e,t)=>{const i=this.clips[t.row];this.copy(i.text,i.uuid,t.row)}},{title:$l10n(\"DELETE\"),symbol:\"trash\",destructive:!0,handler:(e,t)=>{this.kernel.deleteConfirm($l10n(\"CONFIRM_DELETE_MSG\"),(()=>{const i=this.clips[t.row];this.delete(i.uuid,t.row),e.delete(t)}))}}]}];if(e)return t;const i=e=>{const t=this.kernel.actionManager.getActionHandler(e.type,e.dir);return e.handler=(e,i)=>{const r=this.clips[i.row],s=new b({env:y.clipboard,text:r.text,uuid:r.uuid});t(s)},e.title=e.name,e.symbol=e.icon,e},r=this.kernel.actionManager.getActions(\"clipboard\"),s={inline:!0,items:r.slice(0,this.menuItemActionMaxCount).map(i)};return r.length>this.menuItemActionMaxCount&&s.items.push({title:$l10n(\"MORE_ACTIONS\"),symbol:\"square.grid.2x2\",items:r.slice(this.menuItemActionMaxCount).map(i)}),[s,...t]}switchTab(e,t=!1){this.tabIndex=e,this.updateList(),t&&($(this.listId+\"-tab\").index=this.tabIndex)}tabView(){return{type:\"tab\",props:{id:this.listId+\"-tab\",items:this.tabItems,index:this.tabIndex,dynamicWidth:!0},events:{changed:e=>this.switchTab(e.index)},layout:(e,t)=>{e.centerY.equalTo(t.super),t.prev?e.left.equalTo(t.prev.right).offset(this.left_right):e.left.inset(this.left_right)}}}lineData(e,t=!1){const i={hidden:!0},r={text:\"\"},s=this.kernel.storage.keyToPath(e.text);return s?(i.src=s.preview,i.hidden=!1):r.text=e.text,{copied:{hidden:!t},image:i,tag:{text:e.tag},content:r}}listTemplate(){return{props:{bgcolor:$color(\"clear\")},views:[{type:\"view\",views:[{type:\"view\",props:{id:\"copied\",circular:this.copiedIndicatorSize,hidden:!0,bgcolor:$color(\"green\")},layout:(e,t)=>{e.centerY.equalTo(t.super),e.size.equalTo(this.copiedIndicatorSize),e.left.equalTo(t.super).inset(this.left_right/2-this.copiedIndicatorSize/2)}},{type:\"label\",props:{id:\"content\",lines:this.#G?1:2,font:$font(this.fontSize)},layout:(e,t)=>{e.left.right.equalTo(t.super).inset(this.left_right),this.#G?e.top.inset(this.imageContentHeight/2):e.top.inset(this.top_bottom)}},{type:\"image\",props:{id:\"image\",hidden:!0},layout:$layout.fill}],layout:$layout.fill},{type:\"label\",props:{id:\"tag\",color:$color(\"systemGray2\"),font:$font(this.tagFontSize)},layout:(e,t)=>{e.bottom.width.equalTo(t.super),e.left.inset(this.left_right),e.height.equalTo(this.tagContainerHeight)}}]}}getListView(e=this.listId,t=[]){const i={type:\"list\",props:{id:e,associateWithNavigationBar:!1,bgcolor:$color(\"clear\"),separatorInset:$insets(0,this.left_right,0,0),menu:{items:this.menuItems()},data:t,template:this.listTemplate(),actions:[{title:$l10n(\"COPY\"),color:$color(\"systemLink\"),handler:(e,t)=>{const i=this.clips[t.row];this.copy(i.text,i.uuid,t.row)}},{title:$l10n(\"PIN\"),color:$color(\"orange\"),handler:(e,t)=>{const i=this.clips[t.row];this.pin(i,t.row)}}]},layout:$layout.fill,events:{ready:()=>this.listReady(),rowHeight:(e,t)=>{const i=e.object(t),r=i.tag.text?this.tagContainerHeight:this.top_bottom;return(this.kernel.storage.isImage(i.content.text)?this.imageContentHeight:this.getTextHeight(i.content.text))+this.top_bottom+r},didSelect:(e,t,i)=>{const r=this.clips[t.row],s=r.text,a=this.kernel.storage.keyToPath(s);a&&this.kernel.fileStorage.exists(a.original)?$quicklook.open({image:this.kernel.fileStorage.readSync(a.original)?.image}):this.edit(r.text,(e=>{r.md5!==$text.MD5(e)&&this.update(r.uuid,e,t.row)}))},pulled:e=>{this.loadAllClips(),this.updateList(),$delay(.5,(()=>e.endRefreshing()))}}},s={type:\"label\",props:{id:e+\"-empty-list-background\",color:$color(\"secondaryText\"),hidden:this.clips.length>0,text:$l10n(\"NONE\"),align:$align.center},layout:$layout.center};return r.createFromViews([i,s])}getNavigationView(){const e=this.tabView();e.type=\"menu\",e.layout=(e,t)=>{e.top.left.right.equalTo(t.super),e.height.equalTo(this.tabHeight)};const t=this.getListView();t.views.unshift(e),t.views[1].layout=(e,t)=>{e.bottom.left.right.equalTo(t.super),e.top.equalTo(t.prev.bottom)},t.views.push(this.search.getSearchHistoryView());const i=(new l).navigationBarTitle($l10n(\"CLIPS\")).setView(t);return i.navigationBarItems.setTitleView(this.search.getSearchBarView()).pinTitleView().setRightButtons([{symbol:\"plus.circle\",tapped:()=>this.getAddTextView()}]).setLeftButtons([{title:$l10n(\"EDIT\"),tapped:()=>{new g(this).presentSheet()}},{symbol:\"square.and.arrow.down.on.square\",tapped:e=>{e.start(),this.readClipboard(!0),e.done()}}]),i.navigationBar.setBackgroundColor(a.primaryViewBackgroundColor).setLargeTitleDisplayMode(c.largeTitleDisplayModeNever),this.kernel.isUseJsboxNav&&i.navigationBar.removeTopSafeArea(),i}}})),parcelRequire.register(\"f0nX9\",(function(e,t){var i=parcelRequire(\"gxpqj\"),r=i.UIKit,s=i.NavigationBar,a=i.NavigationView,n=i.Sheet,o=parcelRequire(\"eSp9Z\"),l=o.ActionEnv,c=o.ActionData;e.exports=class{#X=\"\";constructor(e){this.kernel=e,this.id=\"editor\",this.originalContent=void 0}set text(e=\"\"){void 0===this.originalContent&&(this.originalContent=e),this.#X=e}get text(){return this.#X}getActionButton(){return{symbol:\"bolt.circle\",tapped:(e,t)=>{t&&(e=t);const i=$(this.id).selectedRange,r=new c({env:l.editor,editor:{setContent:e=>this.setContent(e)},text:i.length>0?this.text.slice(i.location,i.location+i.length):this.text,selectedRange:i}),s=$ui.popover({sourceView:e,directions:$popoverDirection.up,size:$size(200,300),views:[this.kernel.actionManager.getActionListView((e=>{s.dismiss(),$delay(.5,(()=>e(r)))}))]})}}}setContent(e){this.text=e,$(this.id).text=e}getView(e=\"text\"){return{type:e,layout:$layout.fill,props:{id:this.id,lineNumbers:this.kernel.setting.get(\"editor.code.lineNumbers\"),theme:this.kernel.setting.get($device.isDarkMode?\"editor.code.darkTheme\":\"editor.code.lightTheme\"),text:this.text,insets:$insets(15,15,\"text\"===e?this.kernel.setting.get(\"editor.text.insets\"):15,15)},events:{ready:e=>{\"\"===this.text&&setTimeout((()=>e.focus()),500)},didChange:e=>{this.text=e.text}}}}pageSheet(e=\"\",t,i,r=[],s=\"text\"){this.text=e,r.unshift(this.getActionButton());const a=new n;a.setView(this.getView(s)).addNavBar({title:i,popButton:{title:$l10n(\"DONE\"),tapped:()=>t(this.text)},rightButtons:r}),a.navigationView.navigationBar.contentViewHeightOffset=0,a.init().present()}uikitPush(e=\"\",t,i=[],s=\"text\"){this.text=e,i.unshift(this.getActionButton()),r.push({title:\"\",navButtons:i.map((e=>(e.handler=e.tapped,e.tapped=void 0,e))),views:[this.getView(s)],disappeared:()=>t(this.text)})}getNavigationView(e=\"\",t,i=[],r=\"text\"){this.text=e,i.unshift(this.getActionButton());const n=new a;return n.navigationBar.contentViewHeightOffset=0,n.navigationBar.setLargeTitleDisplayMode(s.largeTitleDisplayModeNever),n.navigationBarItems.setRightButtons(i),n.setView(this.getView(r)).navigationBarTitle(\"\"),n.setEvent(\"onPop\",(()=>t(this.text))),n}}})),parcelRequire.register(\"eSp9Z\",(function(e,t){var i=parcelRequire(\"gxpqj\"),r=i.Kernel,s=i.Sheet;class a{static keyboard=0;static today=0;static editor=1;static clipboard=2;static action=3}e.exports={ActionEnv:a,ActionData:class{env;args;text;originalContent;uuid;selectedRange;textBeforeInput;textAfterInput;editor;constructor({env:e,args:t,text:i,uuid:r=null,selectedRange:s=null,textBeforeInput:a=null,textAfterInput:n=null,editor:o=null}={}){this.env=e,this.args=t,this.text=i,this.originalContent=i,this.uuid=r,this.selectedRange=s,this.textBeforeInput=a,this.textAfterInput=n,this.editor=o}},Action:class{#Q;constructor(e,t,i){this.#Q=e,this.config=t,Object.assign(this,i),this.originalContent=this.text;const s=this.l10n();Object.keys(s).forEach((e=>{r.l10n(e,s[e])}))}l10n(){return{}}pageSheet({view:e,title:t=\"\",done:i,doneText:r=$l10n(\"DONE\"),rightButtons:a=[]}){(new s).setView(e).addNavBar({title:t,popButton:{title:r,tapped:()=>{i&&i()}},rightButtons:a}).init().present()}getAllClips(){return{pin:this.#Q.storage.all(\"pin\").map((e=>e.text)),clips:this.#Q.storage.all(\"clips\").map((e=>e.text))}}async clearAllClips(){if(0!==(await $ui.alert({title:$l10n(\"DELETE_DATA\"),message:$l10n(\"DELETE_TABLE\").replace(\"${table}\",$l10n(\"CLIPS\")),actions:[{title:$l10n(\"DELETE\"),style:$alertActionType.destructive},{title:$l10n(\"CANCEL\")}]})).index)return!1;try{return this.#Q.storage.deleteTable(\"clips\"),!0}catch(e){throw this.#Q.error(e),e}}setContent(e){this.text=e,this.env===a.editor&&this.editor.setContent(e)}getAction(e,t,i){return this.#Q.actionManager.getAction(e,t,i)}async runAction(e,t){const i=this.getAction(e,t);return await i.do()}async request(e,t,i={},r={}){try{this.#Q.print(`sending request [${t}]: ${e}`);const s=await $http.request({header:r,url:e,method:t,body:i,timeout:5});if(s.error)throw s.error;if(s?.response?.statusCode>=400){let e=s.data;throw\"object\"==typeof e&&(e=JSON.stringify(e)),new Error(\"http error: [\"+s.response.statusCode+\"] \"+e)}return s}catch(e){throw e.code&&(e=new Error(\"network error: [\"+e.code+\"] \"+e.localizedDescription)),e}}getUrls(){return(this.text??\"\").match(/(https?:\\/\\/)([\\da-z\\.-]+)\\.([a-z\\.]{2,6})([:0-9])*([\\/\\w\\#\\.\\-\\?\\=\\&])*\\s?/gi)??[]}}}})),parcelRequire.register(\"4ZHFw\",(function(e,t){var i=parcelRequire(\"gxpqj\").UIKit;e.exports=class{kernel;pasteboard=$objc(\"UIPasteboard\").$generalPasteboard();#Z=[];savedClipboardIndex={};tabItems=[$l10n(\"PIN\"),$l10n(\"CLIPS\")];tabItemsIndex=[\"pin\",\"clips\"];constructor(e){this.kernel=e}set tabIndex(e){$cache.set(\"caio.main.tab.index\",e)}get tabIndex(){return $cache.get(\"caio.main.tab.index\")??0}get table(){return this.tabItemsIndex[this.tabIndex]}get tableL10n(){return this.tabItems[this.tabIndex]}get allClips(){return 0===this.#Z.length&&this.loadAllClips(),this.#Z}set allClips(e){this.#Z=e.map((e=>new Proxy(e??[],{set:(e,t,i)=>Reflect.set(e,t,i)})))}get clips(){return this.allClips[this.tabIndex]}get isChanged(){const e=this.pasteboard.$changeCount(),t=$cache.get(\"clipboard.changeCount\");return $cache.set(\"clipboard.changeCount\",e),t!==e}getRowByUUID(e){let t=this.clips.length;for(let i=0;i{const i=JSON.parse(JSON.stringify(e));return Object.assign(i,t)},r=this.table;this.clips[t]||(this.clips[t]={uuid:null,text:\"\",next:null,prev:this.clips[t-1].uuid});try{this.kernel.storage.beginTransaction();const s=i(this.clips[e]),a=i(this.clips[t]);if(this.clips[e-1]){const t=i(this.clips[e-1],{next:this.clips[e].next});this.kernel.storage.update(r,t),this.clips[e-1]=t}if(this.clips[e+1]){const t=i(this.clips[e+1],{prev:this.clips[e].prev});this.kernel.storage.update(r,t),this.clips[e+1]=t}if(this.clips[t-1]){const s=i(this.clips[t-1],{next:this.clips[e].uuid});this.kernel.storage.update(r,s),this.clips[t-1]=s}const n=i(a,{prev:s.uuid,next:this.clips[t].next});this.kernel.storage.update(r,n);const o=i(s,{prev:this.clips[t].prev,next:a.uuid});this.kernel.storage.update(r,o),this.clips[t]=n,this.clips[e]=o,this.clips.splice(t,0,this.clips[e]),this.clips.splice(e>t?e+1:e,1),this.kernel.storage.commit()}catch(e){throw this.kernel.error(e),this.kernel.storage.rollback(),e}finally{null===this.clips[t].uuid&&this.clips.splice(t,1)}}pin(e,t){e.next=this.allClips[0][0]?.uuid??null,e.prev=null;try{this.kernel.storage.beginTransaction(),this.kernel.storage.insert(\"pin\",e),e.next&&(this.allClips[0][0].prev=e.uuid,this.kernel.storage.update(\"pin\",this.allClips[0][0])),this.kernel.storage.commit(),\"pin\"!==e?.section&&(e.section=\"pin\",this.delete(e.uuid,t)),this.allClips[0].unshift(e),this.savedClipboardIndex[e.md5]=1}catch(e){throw this.kernel.error(e),this.kernel.storage.rollback(),e}}loadAllClips(){this.kernel.print(\"load all clips\");const e=e=>{try{return this.kernel.storage.sort(e,this.kernel.setting.get(\"clipboard.maxItemLength\")).map((e=>(this.savedClipboardIndex[e.md5]=1,e)))}catch(e){$ui.alert({title:$l10n(\"REBUILD_DATABASE\"),message:$l10n(\"CLIPS_STRUCTURE_ERROR\"),actions:[{title:$l10n(\"OK\"),handler:()=>{const e=i.loading();e.start(),this.kernel.storage.rebuild(),e.end(),$delay(.8,(()=>$addin.restart()))}},{title:$l10n(\"CANCEL\")}]}),this.kernel.error(e)}};this.allClips=[e(this.kernel.storage.all(this.tabItemsIndex[0])),e(this.kernel.storage.all(this.tabItemsIndex[1]))]}}})),parcelRequire.register(\"ay4Kj\",(function(e,t){var i=parcelRequire(\"gxpqj\"),r=i.UIKit,s=i.SearchBar;e.exports=class{listId=\"clips-list-search\";kernel;callback=()=>{};onBegin=()=>{};onDismiss=()=>{};constructor(e){this.kernel=e,this.searchBar=new s,this.searchBarId=this.searchBar.id+\"-input\"}get searchHistoryView(){return{hide:()=>$(this.listId+\"-history\").hidden=!0,show:()=>$(this.listId+\"-history\").hidden=!1}}get searchHistory(){return[{title:$l10n(\"SEARCH_HISTORY\"),rows:$cache.get(\"caio.search.history\")?.reverse()??[]}]}getAccessoryView(){return r.blurBox({height:50},[{type:\"button\",props:{bgcolor:$color(\"clear\"),tintColor:$color(\"primaryText\"),symbol:\"xmark.circle\"},layout:(e,t)=>{e.right.inset(0),e.height.equalTo(t.super),e.width.equalTo(t.super.height)},events:{tapped:()=>this.dismiss()}},{type:\"button\",props:{bgcolor:$color(\"clear\"),tintColor:$color(\"primaryText\"),symbol:\"keyboard.chevron.compact.down\"},layout:(e,t)=>{e.right.equalTo(t.prev.left),e.height.equalTo(t.super),e.width.equalTo(t.super.height)},events:{tapped:()=>$(this.searchBarId).blur()}}])}getSearchHistoryView(){return{type:\"list\",props:{id:this.listId+\"-history\",hidden:!0,stickyHeader:!0,data:this.searchHistory,separatorInset:$insets(0,13,0,0),actions:[{title:$l10n(\"DELETE\"),handler:(e,t)=>{const i=e.data;this.updateSearchHistory(i[0].rows.reverse())}}]},events:{didSelect:(e,t,i)=>{this.searchAction(i),$(this.searchBarId).text=i}},layout:$layout.fill}}setCallback(e){this.callback=e}setOnBegin(e){this.onBegin=e}setOnDismiss(e){this.onDismiss=e}begin(){this.searchHistoryView.show(),this.onBegin()}dismiss(){$(this.searchBarId).blur(),$(this.searchBarId).text=\"\",this.searchHistoryView.hide(),this.onDismiss()}searchAction(e){try{if(\"\"!==e){const t=this.kernel.storage.search(e);t&&t.length>0?($(this.searchBarId).blur(),this.callback(t)):$ui.toast($l10n(\"NO_SEARCH_RESULT\")),this.pushSearchHistory(e)}}catch(e){throw e}}pushSearchHistory(e){let t=$cache.get(\"caio.search.history\")??[];-1===t.indexOf(e)&&(t.push(e),t.length>20&&(t=t.slice(-20)),$(this.listId+\"-history\").data=this.searchHistory,$cache.set(\"caio.search.history\",t))}updateSearchHistory(e=[]){$cache.set(\"caio.search.history\",e)}getSearchBarView(){return this.searchBar.controller.setEvent(\"onReturn\",(e=>{\"\"!==e?this.searchAction(e):this.searchHistoryView.show()})),this.searchBar.controller.setEvent(\"onChange\",(e=>{\"\"===e&&this.searchHistoryView.show()})),this.searchBar.setEvent(\"didBeginEditing\",(e=>{\"\"===e.text&&this.begin()})),this.searchBar.setAccessoryView(this.getAccessoryView()),this.searchBar}}})),parcelRequire.register(\"9LqeL\",(function(e,t){var i=parcelRequire(\"gxpqj\"),r=i.View,s=i.UIKit,a=i.Sheet;class n{static symbol={selected:\"checkmark.circle.fill\",unselected:\"circle\"};listId=\"clips-list-editor\";reorder={};toolBarHeight=44;#ee=void 0;#te={};constructor(e){this.clipsInstance=e,this.kernel=e.kernel}get editorSelectedIsEmpty(){let e=!0;const t=this.editorSelected;for(const i of Object.keys(t))if(t[i]){e=!1;break}return e}get editorSelectedIsFull(){let e=0,t=0;const i=this.editorSelected;for(const r of Object.keys(i))++t,i[r]&&++e;return t===e}get editorSelected(){return void 0===this.#ee&&(Array(this.clipsInstance.clips.length).fill(0).map(((e,t)=>this.#te[t]=!1)),this.#ee=new Proxy(this.#te,{set:(e,t,i,r)=>{Reflect.set(e,t,i,r),t=Number(t);const s=this.editorSelectedIsEmpty,a=$(this.listId+\"-select-button\"),o=$(this.listId+\"-delete-button\");a.title=this.editorSelectedIsFull?$l10n(\"DESELECT_ALL\"):$l10n(\"SELECT_ALL\"),o.hidden=s;const l=$(this.listId);return l.data=this.clipsInstance.clips.map(((t,i)=>{const r=this.lineData(t);return r.checkmark={symbol:e[i]?n.symbol.selected:n.symbol.unselected},r})),l.reorder=s,!0}})),this.#ee}set editorSelected(e){this.#ee=e}selectAll(){const e=this.editorSelectedIsFull;this.clipsInstance.clips.forEach(((t,i)=>{this.editorSelected[i]=!e}))}deleteSelected(){this.kernel.deleteConfirm($l10n(\"CONFIRM_DELETE_MSG\"),(()=>{const e=$(this.listId),t=$(this.clipsInstance.listId);Object.keys(this.editorSelected).reverse().forEach((i=>{if(this.editorSelected[i]){i=Number(i);const r=this.clipsInstance.clips[i];this.kernel.print(`delete selected: [${i}]\\n${r.text}`),this.clipsInstance.delete(r.uuid,i),t.delete(i),e.delete(i)}}))}))}getToolBarView(){return s.blurBox({},[s.separatorLine(),{type:\"view\",views:[{type:\"button\",props:{id:this.listId+\"-select-button\",title:$l10n(\"SELECT_ALL\"),titleColor:$color(\"tint\"),bgcolor:$color(\"clear\")},layout:(e,t)=>{e.left.inset(this.clipsInstance.left_right),e.centerY.equalTo(t.super)},events:{tapped:()=>this.selectAll()}},{type:\"button\",props:{id:this.listId+\"-delete-button\",symbol:\"trash\",hidden:!0,tintColor:$color(\"red\"),bgcolor:$color(\"clear\")},layout:(e,t)=>{e.right.inset(this.clipsInstance.left_right),e.centerY.equalTo(t.super)},events:{tapped:()=>this.deleteSelected()}}],layout:(e,t)=>{e.left.right.top.equalTo(t.super),e.bottom.equalTo(t.super.safeAreaBottom)}}],((e,t)=>{e.left.right.bottom.equalTo(t.super),e.top.equalTo(t.super.safeAreaBottom).offset(-this.toolBarHeight)}))}lineData(e){const t=this.clipsInstance.lineData(e);return t.checkmark={symbol:n.symbol.unselected},t}listTemplate(){const e=this.clipsInstance.listTemplate();return e.views[0].layout=(e,t)=>{e.height.right.equalTo(t.super),e.left.inset(30)},e.views.push({type:\"image\",props:{id:\"checkmark\",symbol:n.symbol.unselected,contentMode:$contentMode.scaleAspectFit},layout:(e,t)=>{e.centerY.equalTo(t.super),e.left.inset(15),e.size.equalTo($size(25,25))}}),e}getListEditerView(){return{type:\"list\",props:{id:this.listId,bgcolor:s.primaryViewBackgroundColor,separatorInset:$insets(0,this.clipsInstance.left_right,0,0),indicatorInsets:$insets(0,0,this.toolBarHeight,0),data:this.clipsInstance.clips.map((e=>this.lineData(e))),template:this.listTemplate(),reorder:!0,footer:{height:this.toolBarHeight},crossSections:!1},events:{rowHeight:(e,t)=>{const i=this.clipsInstance.clips[t.row].text;return(this.kernel.storage.isImage(i)?this.imageContentHeight:this.clipsInstance.getTextHeight(i))+2*this.clipsInstance.top_bottom},reorderBegan:e=>{this.reorder.began=!0,this.reorder.from=e.row,this.reorder.to=void 0},reorderMoved:(e,t)=>{this.reorder.to=t.row},reorderFinished:()=>{this.reorder.began=!1,void 0!==this.reorder.to&&this.clipsInstance.move(this.reorder.from,this.reorder.to)},didSelect:(e,t,i)=>{this.editorSelected[t.row]=!this.editorSelected[t.row]}},layout:$layout.fill}}presentSheet(){const e=new a;e.setView(r.createFromViews([this.getListEditerView(),this.getToolBarView()])).addNavBar({title:\"\",popButton:{title:$l10n(\"CLOSE\")},rightButtons:[{title:$l10n(\"CLEAR\"),color:$color(\"red\"),tapped:async()=>{if(0===(await $ui.alert({title:$l10n(\"DELETE_DATA\"),message:$l10n(\"DELETE_TABLE\").replace(\"${table}\",this.clipsInstance.tableL10n),actions:[{title:$l10n(\"DELETE\"),style:$alertActionType.destructive},{title:$l10n(\"CANCEL\")}]})).index)try{this.kernel.storage.deleteTable(this.clipsInstance.table),e.dismiss(),this.clipsInstance.loadAllClips(),this.clipsInstance.updateList()}catch(e){this.kernel.error(e),$ui.error(e)}}}]}).init().present()}}e.exports=n})),parcelRequire.register(\"44eiF\",(function(e,t){var i=parcelRequire(\"gxpqj\"),r=i.Matrix,s=i.Setting,a=i.NavigationView,n=i.BarButtonItem,o=i.Sheet,l=i.UIKit,c=parcelRequire(\"f0nX9\"),h=parcelRequire(\"eSp9Z\"),d=h.ActionEnv,p=h.ActionData,u=h.Action;e.exports=class{matrixId=\"actions\";matrix;reorder={};constructor(e){this.kernel=e,this.actionPath=\"scripts/action\",this.actionOrderFile=\"order.json\",this.userActionPath=`${this.kernel.fileStorage.basePath}/user_action`,this.typeNameMap={},this.checkUserAction()}importExampleAction(){try{Object.keys(__ACTIONS__).forEach((e=>{const t=`${this.userActionPath}/${e}`;Object.keys(__ACTIONS__[e]).forEach((i=>{$file.exists(`${t}/${i}/main.js`)||($file.mkdir(t),$file.mkdir(`${t}/${i}`),$file.write({data:$data({string:__ACTIONS__[e][i][\"main.js\"]}),path:`${t}/${i}/main.js`}),$file.write({data:$data({string:__ACTIONS__[e][i][\"config.json\"]}),path:`${t}/${i}/config.json`}),$file.write({data:$data({string:__ACTIONS__[e][i][\"README.md\"]}),path:`${t}/${i}/README.md`}))}))}))}catch{$file.list(this.actionPath).forEach((e=>{const t=`${this.actionPath}/${e}`;if($file.isDirectory(t)){const i=`${this.userActionPath}/${e}`;$file.list(t).forEach((e=>{$file.exists(`${i}/${e}/main.js`)||($file.mkdir(i),$file.copy({src:`${t}/${e}`,dst:`${i}/${e}`}))}))}}))}}checkUserAction(){$file.exists(this.userActionPath)&&0!==$file.list(this.userActionPath).length||($file.mkdir(this.userActionPath),this.importExampleAction())}getActionTypes(){const e=[\"clipboard\",\"editor\"];return e.concat($file.list(this.userActionPath).filter((t=>{if($file.isDirectory(`${this.userActionPath}/${t}`)&&e.indexOf(t)<0)return t})))}getActionOrder(e){const t=`${this.userActionPath}/${e}/${this.actionOrderFile}`;return $file.exists(t)?JSON.parse($file.read(t).string):[]}getActionPath(e,t){return`${this.userActionPath}/${e}/${t}`}getAction(e,t,i){const r=this.getActionPath(e,t),s=JSON.parse($file.read(`${r}/config.json`).string);try{const e=$file.read(`${r}/main.js`).string,t=new Function(\"Action\",\"ActionEnv\",\"ActionData\",`${e}\\n return MyAction`)(u,d,p);return new t(this.kernel,s,i)}catch(e){$ui.error(e),this.kernel.error(e)}}getActionHandler(e,t){return async i=>{try{const r=this.getAction(e,t,i);return await r.do()}catch(e){$ui.error(e),this.kernel.error(e)}}}getActions(e){const t=[],i=`${this.userActionPath}/${e}`;if(!$file.exists(i))return[];const r=r=>{const s=`${i}/${r}/`;if($file.isDirectory(s)){const i=JSON.parse($file.read(s+\"config.json\").string);t.push(Object.assign(i,{dir:r,type:e,name:i.name??r,icon:i.icon}))}},s=this.getActionOrder(e);return s.forEach((e=>r(e))),$file.list(i).forEach((e=>{-1===s.indexOf(e)&&r(e)})),t}getTypeName(e){const t=e.toUpperCase(),i=$l10n(t),r=i===t?e:i;return this.typeNameMap[r]=e,r}getTypeDir(e){return this.typeNameMap[e]??e}editActionInfoPageSheet(e,t){const i=this.getActionTypes(),r={};i.forEach(((e,t)=>{r[e]=t})),this.editingActionInfo=e??{type:\"clipboard\",name:\"MyAction\",color:\"#CC00CC\",icon:\"icon_062.png\",description:\"\"};const a=new s({structure:{},set:(e,t)=>(this.editingActionInfo[e]=\"type\"===e?t[1]:t,!0),get:(e,t=null)=>\"type\"===e?r[this.editingActionInfo.type]:Object.prototype.hasOwnProperty.call(this.editingActionInfo,e)?this.editingActionInfo[e]:t}),n=a.createInput(\"name\",[\"pencil.circle\",\"#FF3366\"],$l10n(\"NAME\")),l=a.createColor(\"color\",[\"pencil.tip.crop.circle\",\"#0066CC\"],$l10n(\"COLOR\")),c=a.createIcon(\"icon\",[\"star.circle\",\"#FF9933\"],$l10n(\"ICON\"),this.kernel.setting.getColor(this.editingActionInfo.color)),h=a.createMenu(\"type\",[\"tag.circle\",\"#33CC33\"],$l10n(\"TYPE\"),i,!0),d={type:\"view\",views:[{type:\"text\",props:{id:\"action-text\",textColor:$color(\"#000000\",\"secondaryText\"),bgcolor:$color(\"systemBackground\"),text:this.editingActionInfo.description,insets:$insets(10,10,10,10)},layout:$layout.fill,events:{tapped:t=>{$(\"actionInfoPageSheetList\").scrollToOffset($point(0,e?230:280)),setTimeout((()=>t.focus()),200)},didChange:e=>{this.editingActionInfo.description=e.text}}}],layout:$layout.fill},p=[{title:$l10n(\"INFORMATION\"),rows:[n,l,c]},{title:$l10n(\"DESCRIPTION\"),rows:[d]}];e||(p[0].rows=p[0].rows.concat(h));(new o).setView({type:\"list\",props:{id:\"actionInfoPageSheetList\",bgcolor:$color(\"insetGroupedBackground\"),style:2,separatorInset:$insets(0,50,0,10),data:p},layout:$layout.fill,events:{rowHeight:(e,t)=>1===t.section?120:50}}).addNavBar({title:\"\",popButton:{title:$l10n(\"DONE\"),tapped:()=>{this.editingActionInfo.dir||(this.editingActionInfo.dir=$text.MD5(this.editingActionInfo.name)),this.saveActionInfo(this.editingActionInfo),t&&t(this.editingActionInfo)}}}).init().present()}editActionMainJs(e=\"\",t){new c(this.kernel).pageSheet(e,(e=>{this.saveMainJs(t,e)}),t.name,[{symbol:\"book.circle\",tapped:()=>{const e=$file.read(\"scripts/action/README.md\").string;(new o).setView({type:\"markdown\",props:{content:e},layout:(e,t)=>{e.size.equalTo(t.super)}}).init().present()}}],\"code\")}saveActionInfo(e){const t=`${this.userActionPath}/${e.type}/${e.dir}`;$file.exists(t)||$file.mkdir(t),$file.write({data:$data({string:JSON.stringify({icon:e.icon,color:e.color,name:e.name,description:e.description})}),path:`${t}/config.json`})}saveMainJs(e,t){const i=`${this.userActionPath}/${e.type}/${e.dir}`,r=`${i}/main.js`;$file.exists(i)||$file.mkdir(i),$text.MD5(t)!==$text.MD5($file.read(r)?.string??\"\")&&$file.write({data:$data({string:t}),path:r})}saveOrder(e,t){$file.write({data:$data({string:JSON.stringify(t)}),path:`${this.userActionPath}/${e}/${this.actionOrderFile}`})}move(e,t,i){if(e.section===t.section&&e.row===t.row)return;const r=(i=i.map((e=>(e.rows=e.rows.map((e=>e.info.info)),e))))[e.section],s=i[t.section],a=e=>{const t=[];return i[e].rows.forEach((e=>t.push(e.dir))),t},n=this.getTypeDir(r.title),o=this.getTypeDir(s.title);e.section===t.section?this.saveOrder(n,a(e.section)):(this.saveOrder(n,a(e.section)),this.saveOrder(o,a(t.section)),$file.move({src:`${this.userActionPath}/${n}/${s.rows[t.row].dir}`,dst:`${this.userActionPath}/${o}/${s.rows[t.row].dir}`})),((i=!0,r)=>{const a=this.matrix,n=this.actionToData(Object.assign(s.rows[t.row],{type:r}));i?(a.insert({indexPath:$indexPath(t.section,t.row+1),value:n},!1),a.delete(e,!1)):(a.delete(e,!1),a.insert({indexPath:t,value:n},!1))})(e.row{const i=e.cell(t),r=i.get(\"info\").info;this.editActionInfoPageSheet(r,(e=>{i.get(\"info\").info=e,i.get(\"color\").bgcolor=this.kernel.setting.getColor(e.color),i.get(\"name\").text=e.name,\"icon_\"===e.icon.slice(0,5)?i.get(\"icon\").icon=$icon(e.icon.slice(5,e.icon.indexOf(\".\")),$color(\"#ffffff\")):i.get(\"icon\").image=$image(e.icon)}))}},{title:$l10n(\"EDIT_SCRIPT\"),symbol:\"square.and.pencil\",handler:(e,t,i)=>{const r=i.info.info;if(!r)return;const s=`${this.userActionPath}/${r.type}/${r.dir}/main.js`,a=$file.read(s).string;this.editActionMainJs(a,r)}},{inline:!0,items:[{title:\"README\",symbol:\"book\",handler:(e,t)=>{const i=e.cell(t).get(\"info\").info;let r;try{r=__ACTIONS__[i.type][i.dir][\"README.md\"]}catch{const e=this.getActionPath(i.type,i.dir);r=$file.read(e+\"/README.md\").string}(new o).setView({type:\"markdown\",props:{content:r},layout:(e,t)=>{e.size.equalTo(t.super)}}).init().present()}}]},{inline:!0,items:[{title:$l10n(\"DELETE\"),symbol:\"trash\",destructive:!0,handler:(e,t,i)=>{this.kernel.deleteConfirm($l10n(\"CONFIRM_DELETE_MSG\"),(()=>{this.delete(i.info.info),e.delete(t)}))}}]}]}getNavButtons(){return[{symbol:\"plus.circle\",menu:{pullDown:!0,asPrimary:!0,items:[{title:$l10n(\"CREATE_NEW_ACTION\"),handler:()=>{this.editActionInfoPageSheet(null,(e=>{this.matrix.insert({indexPath:$indexPath(this.getActionTypes().indexOf(e.type),0),value:this.actionToData(e)});const t=$file.read(`${this.actionPath}/template.js`).string;this.saveMainJs(e,t),this.editActionMainJs(t,e)}))}},{title:$l10n(\"CREATE_NEW_TYPE\"),handler:()=>{$input.text({text:\"\",placeholder:$l10n(\"CREATE_NEW_TYPE\"),handler:e=>{if(\"\"===(e=e.trim()))return void $ui.toast($l10n(\"INVALID_VALUE\"));const t=`${this.userActionPath}/${e}`;$file.isDirectory(t)?$ui.warning($l10n(\"TYPE_ALREADY_EXISTS\")):($file.mkdir(t),$ui.success($l10n(\"SUCCESS\")))}})}}]}},{symbol:\"arrow.up.arrow.down.circle\",tapped:(e,t)=>{$ui.popover({sourceView:t,directions:$popoverDirection.up,size:$size(200,300),views:[this.getActionListView(void 0,{reorder:!0,actions:[{title:\"delete\",handler:(e,t)=>{const i=this.matrix,r=i.object(t,!1).info.info;this.delete(r),i.delete(t,!1)}}]},{reorderBegan:e=>{this.reorder.from=e,this.reorder.to=void 0},reorderMoved:(e,t)=>{this.reorder.to=t},reorderFinished:e=>{void 0!==this.reorder.to&&this.move(this.reorder.from,this.reorder.to,e)}})]})}}]}actionToData(e){return{name:{text:e.name},icon:\"icon_\"===e.icon.slice(0,5)?{icon:$icon(e.icon.slice(5,e.icon.indexOf(\".\")),$color(\"#ffffff\"))}:{image:$image(e.icon)},color:{bgcolor:this.kernel.setting.getColor(e.color)},info:{info:e}}}actionsToData(){return this.getActionTypes().map((e=>{const t=[];return this.getActions(e).forEach((e=>{t.push(this.actionToData(e))})),{title:this.getTypeName(e),items:t,rows:t}}))}getActionListView(e,t={},i={}){return e&&(i.didSelect=(t,i,r)=>{const s=r.info.info,a=this.kernel.actionManager.getActionHandler(s.type,s.dir);e(a)}),{type:\"list\",layout:(e,t)=>{e.top.width.equalTo(t.super.safeArea),e.bottom.inset(0)},events:i,props:Object.assign({reorder:!1,bgcolor:$color(\"clear\"),rowHeight:60,sectionTitleHeight:30,stickyHeader:!0,data:this.actionsToData(),template:{props:{bgcolor:$color(\"clear\")},views:[{type:\"image\",props:{id:\"color\",cornerRadius:8,smoothCorners:!0},layout:(e,t)=>{e.centerY.equalTo(t.super),e.left.inset(15),e.size.equalTo($size(30,30))}},{type:\"image\",props:{id:\"icon\",tintColor:$color(\"#ffffff\")},layout:(e,t)=>{e.centerY.equalTo(t.super),e.left.inset(20),e.size.equalTo($size(20,20))}},{type:\"label\",props:{id:\"name\",lines:1,font:$font(16)},layout:(e,t)=>{e.height.equalTo(30),e.centerY.equalTo(t.super),e.left.equalTo(t.prev.right).offset(15)}},{type:\"label\",props:{id:\"info\"}}]}},t)}}getMatrixView({columns:e=2,spacing:t=15,itemHeight:i=100}={}){return this.matrix=r.create({type:\"matrix\",props:{id:this.matrixId,columns:e,itemHeight:i,spacing:t,bgcolor:l.scrollViewBackgroundColor,menu:{items:this.menuItems()},data:this.actionsToData(),template:{props:{smoothCorners:!0,cornerRadius:10,bgcolor:$color(\"#ffffff\",\"#242424\")},views:[{type:\"image\",props:{id:\"color\",cornerRadius:8,smoothCorners:!0},layout:e=>{e.top.left.inset(10),e.size.equalTo($size(30,30))}},{type:\"image\",props:{id:\"icon\",tintColor:$color(\"#ffffff\")},layout:e=>{e.top.left.inset(15),e.size.equalTo($size(20,20))}},{type:\"button\",props:{bgcolor:$color(\"clear\"),tintColor:l.textColor,titleColor:l.textColor,contentEdgeInsets:$insets(0,0,0,0),titleEdgeInsets:$insets(0,0,0,0),imageEdgeInsets:$insets(0,0,0,0)},views:[{type:\"image\",props:{symbol:\"ellipsis.circle\"},layout:(e,t)=>{e.center.equalTo(t.super),e.size.equalTo(n.style.iconSize)}}],events:{tapped:e=>{const t=e.next.info;if(!t)return;const i=`${this.userActionPath}/${t.type}/${t.dir}/main.js`,r=$file.read(i).string;this.editActionMainJs(r,t)}},layout:e=>{e.top.right.inset(0),e.size.equalTo(n.style.width)}},{type:\"view\",props:{id:\"info\",hidden:!0}},{type:\"label\",props:{id:\"name\",font:$font(16)},layout:(e,t)=>{e.bottom.left.inset(10),e.width.equalTo(t.super)}}]}},layout:$layout.fill,events:{didSelect:(e,t,i)=>{const r=i.info.info,s=new p({env:d.action,text:\"clipboard\"===r.type||\"uncategorized\"===r.type?$clipboard.text:null});this.getActionHandler(r.type,r.dir)(s)},pulled:e=>{$delay(.5,(()=>{e.endRefreshing(),this.matrix.update(this.actionsToData())}))}}}),this.matrix.definition}getPage(){const e=new a;return e.navigationBarItems.setRightButtons(this.getNavButtons()),e.setView(this.getMatrixView()).navigationBarTitle($l10n(\"ACTIONS\")),e.getPage()}present(){(new o).setView(this.getMatrixView()).addNavBar({title:$l10n(\"ACTIONS\"),popButton:{symbol:\"xmark.circle\"},rightButtons:this.getNavButtons()}).init().present()}}})),parcelRequire.register(\"gYDdO\",(function(e,t){async function i(e){!function(e,t=[]){t.forEach((t=>{$file.exists(t)&&(e.print(`delete file: ${t}`),$file.delete(t))}))}(e,[\"scripts/action/clipboard/ClearClipboard\",\"scripts/ui/clipboard.js\",\"scripts/ui/clipboard-data.js\",\"scripts/ui/clipboard-search.js\"]),function(e){const t=e.storage.sqlite.query('SELECT count(*), name FROM sqlite_master WHERE type = \"table\" AND name = \"clipboard\"');if(null!==t.error)throw new Error(`Code [${t.error.code}] ${t.error.domain} ${t.error.localizedDescription}`);t.result.next();const i=t.result.get(0);t.result.close(),i>0&&(e.print(\"copy data from old table: clipboard\"),e.storage.sqlite.update(\"INSERT INTO clips SELECT * FROM clipboard\"),e.print(\"drop table: clipboard\"),e.storage.sqlite.update(\"DROP TABLE clipboard\"))}(e),await async function(e,t={}){const i=\"scripts/action\",r=`${e.fileStorage.basePath}/user_action`,s=[];for(let e of Object.keys(t))t[e].forEach((t=>{const r=JSON.parse($file.read(`${i}/${e}/${t}/config.json`).string);s.push(r.name)}));if(1!==(await $ui.alert({title:$l10n(\"compatibility.rebuildUserAction.alert.title\"),message:$l10n(\"compatibility.rebuildUserAction.alert.message\")+\"\\n\"+JSON.stringify(s,null,2)+\"\\n\"+$l10n(\"compatibility.rebuildUserAction.alert.message2\"),actions:[{title:$l10n(\"OK\")},{title:$l10n(\"CANCEL\")}]})).index)for(let s of Object.keys(t))t[s].forEach((t=>{$file.exists(`${r}/${s}/${t}`)&&(e.print(`rebuild user action: ${s}/${t}`),$file.copy({src:`${i}/${s}/${t}/main.js`,dst:`${r}/${s}/${t}/main.js`}))}))}(e,{uncategorized:[\"ExportAllContent\",\"DisplayClipboard\"],clipboard:[\"B23Clean\"]}),$cache.get(\"caio.keyboard.height\")&&(e.setting.set(\"keyboard.previewAndHeight\",$cache.get(\"caio.keyboard.height\")),$cache.remove(\"caio.keyboard.height\"))}e.exports=async function(e){if(!e)return;const t=$cache.get(\"compatibility.version\")??0;try{t<1&&(e.print(`compatibility: userVersion [${t}] lower than [1], start action`),await i(e))}catch(t){throw e.error(t),t}$cache.set(\"compatibility.version\",1)}})),parcelRequire.register(\"9RsVy\",(function(e,t){var i=parcelRequire(\"gxpqj\"),r=i.Kernel,s=i.UIKit,a=parcelRequire(\"2aNLD\"),n=parcelRequire(\"ilpYs\");let o;function l(){o.setting.method.exportClipboard=e=>{e.actionStart(),o.storage.export((t=>{t?e.actionDone():e.actionCancel()}))},o.setting.method.importClipboard=e=>{e.actionStart(),$ui.alert({title:$l10n(\"ALERT_INFO\"),message:$l10n(\"OVERWRITE_ALERT\"),actions:[{title:$l10n(\"OK\"),handler:()=>{$drive.open({handler:t=>{void 0!==t?\"db\"===t.fileName.slice(-2)||\"zip\"===t.fileName.slice(-3)?o.storage.import(t).then((()=>{e.actionDone(),$delay(.3,(()=>{$addin.restart()}))})).catch((t=>{$ui.error(t),o.print(t),e.actionCancel()})):($ui.warning($l10n(\"FILE_TYPE_ERROR\")),e.actionCancel()):e.actionCancel()}})}},{title:$l10n(\"CANCEL\"),handler:()=>e.actionCancel()}]})},o.setting.method.rebuildDatabase=e=>{e.actionStart();$ui.alert({title:$l10n(\"REBUILD_DATABASE_ALERT\"),actions:[{title:$l10n(\"REBUILD\"),style:$alertActionType.destructive,handler:()=>{(()=>{try{o.storage.rebuild(),e.actionDone(),$delay(.8,(()=>$addin.restart()))}catch(t){e.actionCancel(),$ui.alert(t)}})()}},{title:$l10n(\"CANCEL\"),handler:()=>{e.actionCancel()}}]})},o.setting.method.deleteAllData=e=>{e.actionStart(),$ui.alert({title:$l10n(\"DELETE_ALL_DATA_ALERT\"),actions:[{title:$l10n(\"DELETE\"),style:$alertActionType.destructive,handler:()=>{o.storage.deleteAllData(),e.actionDone(),$delay(.5,(()=>$addin.restart()))}},{title:$l10n(\"CANCEL\"),handler:()=>{e.actionCancel()}}]})}}e.exports=function(e){o=e,o.setting.method.checkUpdate=async e=>{e.actionStart();const t=\"scripts/libs/easy-jsbox.js\";if($file.exists(t))try{const e=await o.checkUpdate();e&&($file.write({data:$data({string:e}),path:t}),$ui.toast(\"The framework has been updated.\"))}catch{}$http.get({url:\"https://raw.githubusercontent.com/ipuppet/CAIO/master/config.json\",handler:t=>{const i=t.data?.info.version;let s;try{s=__INFO__}catch{s=JSON.parse($file.read(\"config.json\").string).info}r.versionCompare(i,s.version)>0?$ui.alert({title:\"New Version\",message:`New version found: ${i}\\nUpdate via Github or click the button to open Erots.`,actions:[{title:$l10n(\"CANCEL\")},{title:\"Erots\",handler:()=>{$addin.run({name:\"Erots\",query:{q:\"show\",objectId:\"603e6eaaca0dd64fcef93e2d\"}})}}]}):$ui.toast(\"No need to update\"),e.actionDone()}})},o.setting.method.previewWidget=e=>{const{Widget:t}=parcelRequire(\"8Makm\"),i={};try{JSON.parse($file.read(\"widget-options.json\").string).forEach((e=>{i[e.name]=e.value}))}catch(e){return void $ui.error(e)}$ui.menu({items:Object.keys(i),handler:e=>{t.render(i[e])}})},o.setting.method.fileManager=()=>{o.fileManager.push(\"storage\")},l(),o.setting.method.exportAction=e=>{e.actionStart();const t=\"actions.zip\",i=\"/actions.zip\",r=o.fileStorage.filePath(i);$archiver.zip({directory:o.actionManager.userActionPath,dest:r,handler:()=>{$share.sheet({items:[{name:t,data:$data({path:r})}],handler:t=>{t?e.actionDone():e.actionCancel(),o.fileStorage.delete(i)}})}})},o.setting.method.importAction=e=>{e.actionStart(),$drive.open({handler:t=>{if(void 0!==t)if(\"zip\"===t.fileName.slice(-3)){const i=`${o.fileStorage.basePath}/action_import`;$archiver.unzip({file:t,dest:i,handler:()=>{$file.list(i).forEach((e=>{$file.isDirectory(`${i}/${e}`)&&$file.copy({src:`${i}/${e}`,dst:`${o.actionManager.userActionPath}/${e}`})})),$file.delete(i),e.actionDone()}})}else $ui.warning($l10n(\"FILE_TYPE_ERROR\")),e.actionCancel();else e.actionCancel()}})},o.setting.method.importExampleAction=e=>{e.actionStart(),o.actionManager.importExampleAction(),e.actionDone()},o.setting.method.rebuildAction=e=>{e.actionStart(),$ui.alert({title:$l10n(\"REBUILD_ACTION_DATABASE_ALERT\"),actions:[{title:$l10n(\"REBUILD\"),style:$alertActionType.destructive,handler:()=>{$file.delete(o.actionManager.userActionPath),e.actionDone(),$delay(.8,(()=>$addin.restart()))}},{title:$l10n(\"CANCEL\")}]})},function(){const e=parcelRequire(\"7eNYp\"),t=200;o.setting.method.previewKeyboard=()=>{const i=new e(o),r=$text.uuid,s=e=>{$(r).updateLayout((t=>{t.height.equalTo(e)})),i.keyboardHeight=e},a=e=>(e-t)/200;return{views:[{type:\"label\",layout:(e,t)=>{e.top.inset(20),e.centerX.equalTo(t.super)},events:{ready:e=>e.text=i.keyboardHeight,tapped:e=>{$input.text({type:$kbType.number,text:i.keyboardHeight,handler:i=>{if(/^[0-9]+$/.test(i)){let r=Number(i);r=Math.min(r,400),r=Math.max(r,t),e.text=r,e.next.value=a(r),s(r)}else $ui.toast(\"Only integers can be entered.\")}})}}},{type:\"slider\",props:{max:1,min:0},layout:(e,t)=>{e.top.equalTo(t.prev.bottom),e.right.inset(20),e.width.equalTo(t.super).offset(-40)},events:{ready:e=>e.value=a(i.keyboardHeight),changed:e=>{const i=Math.floor(200*e.value+t);e.prev.text=i,s(i)}}},{type:\"view\",props:{id:r},views:[i.getView()],layout:(e,t)=>{e.width.equalTo(t.super),e.height.equalTo(i.keyboardHeight),e.bottom.inset(0)}}],layout:$layout.fill}},o.setting.method.setKeyboardQuickStart=()=>a.sheet()}(),o.setting.method.previewTodayWidget=e=>{e.touchHighlightStart();const t=new(parcelRequire(\"49je6\"))(o).getView();s.push({views:[t],disappeared:()=>e.touchHighlightEnd()})},o.setting.method.setTodayWidgetActions=e=>{n.sheet(o)}}})),parcelRequire.register(\"2aNLD\",(function(e,t){var i=parcelRequire(\"gxpqj\").Sheet;class r{constructor(){this.listId=\"keyboard-script-list\"}static getAddins(){const e=$cache.get(\"keyboard.addins\");return void 0===e?(this.setAddins(),[]):JSON.parse(e)}static setAddins(e=[]){e.map(((t,i)=>{null===t&&e.splice(i,1)})),$cache.set(\"keyboard.addins\",JSON.stringify(e))}getUnsetAddins(){const e=$addin.current.name,t=r.getAddins(),i=[];return $addin.list?.forEach((r=>{const s=r.displayName;-1===t.indexOf(s)&&e!==s&&i.push(s)})),i}add(){const e={type:\"list\",props:{data:this.getUnsetAddins()},events:{didSelect:(e,t,i)=>{const s=r.getAddins();s.unshift(i),r.setAddins(s),$(this.listId).insert({indexPath:$indexPath(0,0),value:i}),e.delete(t)}},layout:$layout.fill};(new i).setView(e).addNavBar({title:$l10n(\"ADD\")}).init().present()}getNavButtons(){return[{symbol:\"plus\",tapped:()=>this.add()}]}getListView(){return{type:\"list\",props:{id:this.listId,reorder:!0,data:r.getAddins(),actions:[{title:\"delete\",handler:(e,t)=>{r.setAddins(e.data)}}]},events:{reorderFinished:e=>{r.setAddins(e)}},layout:$layout.fill}}static sheet(){const e=new i,t=new r;e.setView(t.getListView()).addNavBar({title:$l10n(\"QUICK_START_SCRIPTS\"),popButton:{title:$l10n(\"CLOSE\")},rightButtons:t.getNavButtons()}),e.init().present()}}e.exports=r})),parcelRequire.register(\"ilpYs\",(function(e,t){var i=parcelRequire(\"gxpqj\").Sheet;class r{constructor(e){this.listId=\"today-action-list\",this.kernel=e}getActions(){let e=$cache.get(\"today.actions\")??[];\"string\"==typeof e&&(e=JSON.parse(e),this.setActions(e));const t={};this.kernel.actionManager.getActionTypes().forEach((e=>{this.kernel.actionManager.getActions(e).forEach((e=>{t[e.type+e.dir]=e}))}));const i=[];let r=!1;return e.forEach((e=>{const s=t[e.type+e.dir];s?i.push(s):r=!0})),r&&this.setActions(i),i}setActions(e=[]){e.map(((t,i)=>{t||e.splice(i,1)})),$cache.set(\"today.actions\",e)}getAllActions(){let e=[];return this.kernel.actionManager.getActionTypes().forEach((t=>{e=e.concat(this.kernel.actionManager.getActions(t))})),e}getUnsetActions(){const e=this.getActions().map((e=>e.name)),t=[];return this.getAllActions().forEach((i=>{const r=i.name;-1===e.indexOf(r)&&t.push(i)})),t}getListData(e){return e.map((e=>({action:{text:e.name,info:e},icon:\"icon_\"===e.icon.slice(0,5)?{icon:$icon(e.icon.slice(5,e.icon.indexOf(\".\")),$color(\"#ffffff\"))}:{image:$image(e.icon)},color:{bgcolor:this.kernel.setting.getColor(e.color)}})))}getListTemplate(){return{views:[{type:\"image\",props:{id:\"color\",cornerRadius:8,smoothCorners:!0},layout:e=>{e.top.left.inset(10),e.size.equalTo($size(30,30))}},{type:\"image\",props:{id:\"icon\",tintColor:$color(\"#ffffff\")},layout:e=>{e.top.left.inset(15),e.size.equalTo($size(20,20))}},{type:\"label\",props:{id:\"action\"},layout:(e,t)=>{e.bottom.top.inset(10),e.left.equalTo(t.prev.prev.right).offset(10),e.right.inset(10)}}]}}add(){const e={type:\"list\",props:{data:this.getListData(this.getUnsetActions()),template:this.getListTemplate(),rowHeight:50},events:{didSelect:(e,t,i)=>{const r=i.action.info,s=this.getActions();s.unshift(r),this.setActions(s),$(this.listId).insert({indexPath:$indexPath(0,0),value:this.getListData([r])[0]}),e.delete(t)}},layout:$layout.fill};(new i).setView(e).addNavBar({title:$l10n(\"ADD\"),popButton:{title:$l10n(\"CLOSE\")}}).init().present()}getNavButtons(){return[{symbol:\"plus\",tapped:()=>this.add()}]}getListView(){return{type:\"list\",props:{id:this.listId,data:this.getListData(this.getActions()),template:this.getListTemplate(),rowHeight:50,reorder:!0,actions:[{title:\"delete\",handler:(e,t)=>{this.setActions(e.data.map((e=>e.action.info)))}}]},events:{reorderFinished:e=>{const t=[];e.forEach((e=>{t.push(e.action.info)})),this.setActions(t)}},layout:$layout.fill}}static sheet(e){const t=new i,s=new r(e);t.setView(s.getListView()).addNavBar({title:$l10n(\"ACTIONS\"),popButton:{title:$l10n(\"CLOSE\")},rightButtons:s.getNavButtons()}),t.init().present()}}e.exports=r})),parcelRequire.register(\"7eNYp\",(function(e,t){var i=parcelRequire(\"eSp9Z\"),r=i.ActionData,s=i.ActionEnv,a=parcelRequire(\"gxpqj\"),n=a.UIKit,o=a.BarButtonItem,l=parcelRequire(\"imdB1\"),c=parcelRequire(\"2aNLD\");e.exports=class extends l{#ie;deleteTimer=void 0;continuousDeleteTimer=void 0;deleteDelay=this.kernel.setting.get(\"keyboard.deleteDelay\");continuousDeleteDelay=.5;left_right=15;top_bottom=10;containerMargin=5;fontSize=14;navHeight=50;menuItemActionMaxCount=3;constructor(e){super(e),this.listId=\"keyboard-clips-list\",this.keyboardSwitchLockId=\"keyboard-switch-lock\",this.keyboardSwitchLockKey=\"caio.keyboard.switch.lock\",this.backgroundImage=this.kernel.setting.getImage(\"keyboard.background.image\"),this.backgroundColor=this.kernel.setting.getColor(this.kernel.setting.get(\"keyboard.background.color\")),this.backgroundColorDark=this.kernel.setting.getColor(this.kernel.setting.get(\"keyboard.background.color.dark\")),this.keyboardSetting(),\"boolean\"!=typeof $cache.get(this.keyboardSwitchLockKey)&&$cache.set(this.keyboardSwitchLockKey,!1)}get keyboardHeight(){return this.kernel.setting.get(\"keyboard.previewAndHeight\")}set keyboardHeight(e){this.kernel.setting.set(\"keyboard.previewAndHeight\",e)}getKeyboardSwitchLock(){const e=$cache.get(this.keyboardSwitchLockKey);return\"boolean\"!=typeof e&&$cache.set(this.keyboardSwitchLockKey,!0),e}switchKeyboardSwitchLock(){const e=$cache.get(this.keyboardSwitchLockKey);$cache.set(this.keyboardSwitchLockKey,!e),$(this.keyboardSwitchLockId).symbol=e?\"lock.open\":\"lock\"}listReady(){this.updateList(),this.appListen(),this.kernel.setting.get(\"clipboard.autoSave\")&&$app.env===$env.keyboard&&(this.#ie=$timer.schedule({interval:1,handler:()=>{this.kernel.setting.get(\"clipboard.autoSave\")?this.readClipboard():this.#ie.invalidate()}}))}keyboardSetting(){if($app.env!==$env.keyboard)return;const e=$timer.schedule({interval:0,handler:()=>{$keyboard.height!==this.keyboardHeight?$keyboard.height=this.keyboardHeight:e.invalidate()}});this.kernel.setting.get(\"keyboard.showJSBoxToolbar\")||($keyboard.barHidden=!0)}keyboardTapped(e,t=!0,i=1){return(...r)=>{t&&this.kernel.setting.get(\"keyboard.tapticEngine\")&&$device.taptic(i),e(...r)}}getTopButtons(){const e=[{symbol:\"keyboard.chevron.compact.down\",tapped:this.keyboardTapped((()=>$keyboard.dismiss()))},{symbol:\"square.and.arrow.down.on.square\",tapped:this.keyboardTapped((e=>{e.start(),this.readClipboard(!0),e.done()}))},{symbol:\"bolt.circle\",tapped:this.keyboardTapped(((e,t)=>{const i=$ui.popover({sourceView:t,directions:$popoverDirection.up,size:$size(200,300),views:[this.kernel.actionManager.getActionListView((e=>{i.dismiss(),$delay(.5,(async()=>{const t=new r({env:s.keyboard,textBeforeInput:$keyboard.textBeforeInput,textAfterInput:$keyboard.textAfterInput,text:$keyboard.selectedText??await $keyboard.getAllText()});e(t)}))}))]})}))}];return{type:\"view\",views:e.map(((e,t)=>(new o).setAlign(n.align.right).setSymbol(e.symbol).setEvent(\"tapped\",e.tapped).definition)),layout:(t,i)=>{const r=new o;t.height.equalTo(i.super),t.right.inset(this.containerMargin-r.edges),t.width.equalTo(r.width*e.length+r.edges)}}}getTopBarView(){return{type:\"view\",views:[{type:\"view\",layout:$layout.fill,views:[{type:\"label\",props:{text:$l10n(\"CAIO\"),font:$font(\"bold\",20)},events:{tapped:()=>this.kernel.openInJsbox(),ready:e=>{$cache.get(\"tips.keyboard.title\")||($cache.set(\"tips.keyboard.title\",!0),$ui.popover({sourceView:e,size:$size(200,60),directions:$popoverDirection.up,views:[{type:\"label\",props:{lines:0,text:$l10n(\"CLICK_TO_OPEN_JSBOX\"),align:$align.center},layout:$layout.fillSafeArea}]}))}},layout:(e,t)=>{e.centerY.equalTo(t.super),e.left.equalTo(t.super).offset(this.containerMargin)}}].concat(this.tabView(),this.getTopButtons())}],layout:(e,t)=>{e.top.width.equalTo(t.super),e.height.equalTo(this.navHeight)}}}getButtonView(e,t){const i=$size(38,38),r=this.containerMargin;return n.blurBox({info:{align:t},smoothCorners:!0,cornerRadius:5},[{type:\"button\",props:Object.assign({symbol:e.symbol,title:e.title,id:e.id??$text.uuid,font:$font(16),bgcolor:this.backgroundImage?$color($rgba(172,176,184,.3),$rgba(71,71,73,.3)):$color(\"#ACB0B8\",\"#474749\"),tintColor:n.textColor,titleColor:n.textColor,info:{align:t}},e.menu?{menu:e.menu}:{}),events:Object.assign({},e.tapped?{tapped:e.tapped}:{},e.events),layout:$layout.fill}],((s,a)=>{if(e.title){const t=$text.sizeThatFits({text:e.title,width:n.windowSize.width,font:$font(16)}),a=Math.ceil(t.width)+2*r;s.size.equalTo($size(a,i.height))}else s.size.equalTo(i);s.centerY.equalTo(a.super),a.prev&&a.prev.info.align===t?t===n.align.right?s.right.equalTo(a.prev.left).offset(-r):s.left.equalTo(a.prev.right).offset(r):t===n.align.right?s.right.inset(r):s.left.inset(r)}))}getBottomBarView(){const e=[],t=[];return $device.hasFaceID&&!$device.isIpadPro||e.push({symbol:\"globe\",tapped:this.keyboardTapped((()=>$keyboard.next())),menu:{pullDown:!0,items:[{title:$l10n(\"SWITCH_KEYBOARD\"),handler:this.keyboardTapped((()=>$keyboard.next()))},{title:$l10n(\"OPEN_IN_JSBOX\"),handler:()=>this.kernel.openInJsbox()}]}}),this.kernel.setting.get(\"keyboard.switchAfterInsert\")&&e.push({symbol:this.getKeyboardSwitchLock()?\"lock\":\"lock.open\",id:this.keyboardSwitchLockId,tapped:this.keyboardTapped((()=>this.switchKeyboardSwitchLock()))}),e.push({symbol:\"paperplane\",menu:{pullDown:!0,asPrimary:!0,items:c.getAddins().reverse().map((e=>({title:e,handler:this.keyboardTapped((()=>$addin.run(e)))})))}}),t.push({title:$l10n(\"SEND\"),tapped:this.keyboardTapped((()=>$keyboard.send()))},{symbol:\"delete.left\",events:{touchesBegan:this.keyboardTapped((()=>{$keyboard.delete(),this.continuousDeleteTimer=$delay(this.continuousDeleteDelay,(()=>{this.deleteTimer=$timer.schedule({interval:this.deleteDelay,handler:this.keyboardTapped((()=>$keyboard.delete()),this.kernel.setting.get(\"keyboard.tapticEngineForDelete\"),0)})}))})),touchesEnded:()=>{this.deleteTimer?.invalidate(),this.continuousDeleteTimer?.cancel(),this.deleteTimer=void 0,this.continuousDeleteTimer=void 0}}}),{type:\"view\",views:[...e.map((e=>this.getButtonView(e,n.align.left))),...t.map((e=>this.getButtonView(e,n.align.right)))],layout:(e,t)=>{e.bottom.left.right.equalTo(t.super.safeArea),e.top.equalTo(t.prev.bottom)}}}menuItems(){const e=super.menuItems();return[e[0],e[2]]}getListView(){const e=super.getListView();e.layout=(e,t)=>{e.top.equalTo(this.navHeight),e.width.equalTo(t.super),e.bottom.equalTo(t.super.safeAreaBottom).offset(-this.navHeight)};const t=e.views[0];t.events.didSelect=(e,t)=>{const i=this.clips[t.row],r=this.kernel.storage.keyToPath(i.text);r&&this.kernel.fileStorage.exists(r.original)?$quicklook.open({image:this.kernel.fileStorage.readSync(r.original)?.image}):($keyboard.insert(i.text),this.kernel.setting.get(\"keyboard.switchAfterInsert\")&&!this.getKeyboardSwitchLock()&&$keyboard.next())},t.props.separatorInset=$insets(0,this.left_right,0,this.left_right);const i=n.blurBox({style:$blurStyle.ultraThinMaterial,smoothCorners:!0,cornerRadius:2*this.containerMargin},[t],((e,t)=>{e.bottom.top.equalTo(t.super),e.left.right.inset(this.containerMargin)}));return e.views[0]=i,e}getView(){return{type:\"view\",props:{id:\"keyboard.main\",bgcolor:$color(this.backgroundColor,this.backgroundColorDark)},views:[{type:\"image\",props:{image:this.backgroundImage,hidden:null===this.backgroundImage},layout:$layout.fill},this.getTopBarView(),this.getListView(),this.getBottomBarView()],layout:$layout.fill}}}})),parcelRequire.register(\"49je6\",(function(e,t){var i=parcelRequire(\"eSp9Z\"),r=i.ActionData,s=i.ActionEnv,a=parcelRequire(\"gxpqj\"),n=a.View,o=a.UIKit,l=a.BarButtonItem,c=a.NavigationBarItems,h=a.NavigationBar,d=parcelRequire(\"imdB1\"),p=parcelRequire(\"ilpYs\");e.exports=class extends d{left_right=8;top_bottom=10;fontSize=14;navHeight=38;taptic=1;tagFontSize=10;tagContainerHeight=12;matrixItemHeight=50;tabItems=[$l10n(\"PIN\"),$l10n(\"CLIPS\"),$l10n(\"ACTIONS\")];inLauncher=$app.env===$env.today&&-1===$app.widgetIndex;launcherNavHeight=44;constructor(e){super(e),this.actionsId=\"today-list-actions\",this.listContainerId=\"today-list-container\",this.readClipboardButtonId=\"today-nav-readClipboard\",this.listId=\"today-list\",this.navigationBarItems=new c,this.bottomBar=new h,this.bottomBar.navigationBarItems=this.navigationBarItems,this.todayActions=new p(this.kernel),this.setClipboarPageSize($widget.mode),this.listPageNow=[0,0],this.listSection=Math.min(this.tabIndex,1),this.setSingleLine()}get isActionPage(){return 2===this.tabIndex}set tabIndex(e){$cache.set(\"caio.today.tab.index\",e)}get tabIndex(){return $cache.get(\"caio.today.tab.index\")??0}listReady(){$widget.modeChanged=e=>{this.setClipboarPageSize(e),this.updateList()},this.setClipboarPageSize($widget.mode),this.loadAllClips(),this.updateList(),this.appListen(),$delay(.5,(()=>this.readClipboard()))}readClipboard(e=!1){return!this.isActionPage&&$app.env===$env.today&&(super.readClipboard(e),!0)}setClipboarPageSize(e){if(0===e)this.listPageSize=1;else{const e=(($app.env===$env.app?o.windowSize.height:$widget.height)-2*this.navHeight-(this.inLauncher?this.launcherNavHeight:0))/(this.singleLineHeight+2*this.top_bottom),t=Math.floor(e);this.listPageSize=t,e-t>=.6&&this.listPageSize++}}buttonTapped(e,t=!0){return(...i)=>{t&&this.kernel.setting.get(\"keyboard.tapticEngine\")&&$device.taptic(this.taptic),e(...i)}}navButtons(){return[{symbol:\"square.and.arrow.down.on.square\",props:{id:this.readClipboardButtonId,hidden:this.isActionPage},tapped:this.buttonTapped((e=>{e.start(),this.readClipboard(!0)?e.done():e.cancel()}))}].map((e=>{const t=new l;return t.setAlign(o.align.right).setSymbol(e.symbol).setEvent(\"tapped\",e.tapped).setProps(e.props??{}),t.definition}))}switchTab(e){this.tabIndex=e,2===e?($(this.listContainerId).hidden=!0,$(this.actionsId).hidden=!1,$(this.readClipboardButtonId).hidden=!0):(this.listSection=e,$(this.actionsId).hidden=!0,$(this.listContainerId).hidden=!1,$(this.readClipboardButtonId).hidden=!1,this.updateList())}getNavBarView(){return{type:\"view\",views:[{type:\"view\",layout:$layout.fill,views:[this.tabView(),{type:\"label\"},...this.navButtons()]}],layout:(e,t)=>{e.top.width.equalTo(t.super),e.height.equalTo(this.navHeight)}}}getBottomBarView(){this.navigationBarItems.setLeftButtons([{symbol:\"chevron.backward.circle\",tapped:this.buttonTapped((()=>{this.clipboardPrevPage()}))}]).setRightButtons([{symbol:\"chevron.forward.circle\",tapped:this.buttonTapped((()=>{this.clipboardNextPage()}))}]),this.bottomBar.setTitle(this.listPageNow[this.listSection]+1).setLargeTitleDisplayMode(h.largeTitleDisplayModeNever);const e=this.bottomBar.getNavigationBarView();return e.layout=(e,t)=>{e.bottom.left.right.equalTo(t.super.safeArea),e.top.equalTo(t.prev.bottom)},e}updateList(){const e=this.listPageNow[this.listSection]*this.listPageSize,t=e+this.listPageSize;$(this.listId).data=this.allClips[this.listSection].slice(e,t).map((e=>this.lineData(e))),$(this.bottomBar.id+\"-small-title\").text=this.listPageNow[this.listSection]+1}clipboardPrevPage(){this.listPageNow[this.listSection]>0&&(this.listPageNow[this.listSection]--,this.updateList())}clipboardNextPage(){const e=Math.ceil(this.allClips[this.listSection].length/this.listPageSize);this.listPageNow[this.listSection]this.listReady(),rowHeight:(e,t)=>{const i=e.object(t).tag.text?this.tagContainerHeight:this.top_bottom;return this.singleLineHeight+this.top_bottom+i},didSelect:this.buttonTapped(((e,t)=>{const i=this.clips[t.row],r=this.kernel.storage.keyToPath(i.text);r&&this.kernel.fileStorage.exists(r.original)?$clipboard.image=this.kernel.fileStorage.readSync(r.original).image:(this.setClipboardText(i.text),this.setCopied(i.uuid,t.row)),$ui.toast($l10n(\"COPIED\"))}))},layout:(e,t)=>{e.top.width.equalTo(t.super),e.bottom.equalTo(t.super).offset(-this.navHeight)}},this.getBottomBarView()],layout:(e,t)=>{e.top.equalTo(this.navHeight),e.bottom.left.right.equalTo(t.super.safeArea)}}}getActionView(){let e=this.todayActions.getActions();0===e.length&&(e=this.todayActions.getAllActions());const t={type:\"matrix\",props:{id:this.matrixId,bgcolor:$color(\"clear\"),columns:2,itemHeight:this.matrixItemHeight,spacing:this.left_right,data:e.map((e=>this.kernel.actionManager.actionToData(e))),template:{props:{smoothCorners:!0,cornerRadius:10,bgcolor:$color($rgba(255,255,255,.3),$rgba(0,0,0,.3))},views:[{type:\"image\",props:{id:\"color\",cornerRadius:this.left_right,smoothCorners:!0},layout:e=>{const t=this.matrixItemHeight-20;e.top.left.inset((this.matrixItemHeight-t)/2),e.size.equalTo($size(t,t))}},{type:\"image\",props:{id:\"icon\",tintColor:$color(\"#ffffff\")},layout:(e,t)=>{e.edges.equalTo(t.prev).insets(5)}},{type:\"label\",props:{id:\"name\",font:$font(14)},layout:(e,t)=>{e.bottom.top.inset(10),e.left.equalTo(t.prev.prev.right).offset(10),e.right.inset(10)}},{type:\"view\",props:{id:\"info\",hidden:!0}}]}},layout:$layout.fill,events:{didSelect:(e,t,i)=>{const a=i.info.info,n=new r({env:s.today,text:\"clipboard\"===a.type||\"uncategorized\"===a.type?$clipboard.text:null});this.kernel.actionManager.getActionHandler(a.type,a.dir)(n)}}};return{type:\"view\",props:{id:this.actionsId,hidden:2!==this.tabIndex},views:[t],layout:(e,t)=>{e.top.equalTo(this.navHeight),e.bottom.left.right.equalTo(t.super.safeArea)}}}getView(){return n.create({props:{titleColor:o.textColor,barColor:o.primaryViewBackgroundColor},views:[{type:\"view\",views:[this.getNavBarView(),this.getListView(),this.getActionView()],layout:$layout.fill}],events:{appeared:async()=>{if($app.env!==$env.today)return;const e=$timer.schedule({interval:0,handler:()=>{$ui.animate({duration:.3,animation:()=>{$ui.vc.ocValue().$view().$setBackgroundColor($color(\"clear\"))},completion:()=>{e.invalidate()}})}})}}})}}})),$app.strings={en:{ALERT_INFO:\"Alert\",NONE:\"Nothing\",DONE:\"Done\",CLOSE:\"Close\",FAILED_TO_LOAD_VIEW:\"Faild to load view\",VIEW_NOT_PROVIDED:\"The view is not provided\",UNCATEGORIZED:\"Uncategorized\",SHARE:\"Share\",CLICK_TO_OPEN_JSBOX:\"Click the title to open the main app.\",CLIPS:\"Clips\",CLIPBOARD:\"Clipboard\",UNIVERSAL_CLIPBOARD:\"Universal Clipboard\",UNIVERSAL_CLIPBOARD_TIPS:\"Universal Clipboard allows you to copy something on your iPhone, and paste it on your Mac–or vice-versa–using iCloud.\",CLIPS_STRUCTURE_ERROR:\"Clips data structure is abnormal\",CLIPBOARD_NO_CHANGE:\"Clipboard no change\",ADD:\"Add\",TAG:\"Tag\",ADD_TAG:\"Add Tag\",EDIT:\"Edit\",SEARCH:\"Search\",SEARCH_HISTORY:\"Search History\",SEARCH_RESULT:\"Search Result\",NO_SEARCH_RESULT:\"No item found.\",PIN:\"Pin\",COPY:\"Copy\",COPIED:\"Copied\",SORT:\"Sort\",ACTIONS:\"Actions\",MORE_ACTIONS:\"More Actions\",PREVIEW:\"Preview\",MAX_ITEM_LENGTH:\"Line Limit\",TEXT_MAX_LENGTH:\"Display Character Length\",AUTO_SAVE:\"Auto Save\",AUTO_SYNC:\"Auto Sync\",SYNC_NOW:\"Sync Now\",UNZIP_FAILED:\"Unzip file failed\",SYNC_ALERT_INFO:\"If it has not been synced locally, the iCloud data will be pulled directly. \\\\nDo you want to continue?\",DELETE_ICLOUD_DATA:\"Delete iCloud Data\",REBUILD:\"Rebuild\",REBUILD_DATABASE:\"Rebuild Database\",REBUILD_DATABASE_ALERT:\"Rebuilding the database will lose the order information, do you want to confirm the rebuild?\",DELETE_ALL_DATA:\"Delete All Data\",DELETE_ALL_DATA_ALERT:\"Are you sure you want to delete all your data?\",DELETE_DATA:\"Delete Data\",DELETE_TABLE:\"Delete all data from ${table}?\",SELECT_ALL:\"Select All\",DESELECT_ALL:\"Deselect All\",EDITOR:\"Editor\",CREATE_NEW:\"Create New\",CREATE_NEW_ACTION:\"New Action\",CREATE_NEW_TYPE:\"New Category\",TYPE_ALREADY_EXISTS:\"This category already exists\",EDIT_DETAILS:\"Edit Details\",EDIT_SCRIPT:\"Edit Script\",INFORMATION:\"Information\",NAME:\"Name\",ICON:\"Icon\",TYPE:\"Category\",DESCRIPTION:\"Description\",CODE:\"Code\",TEXT_INSETS:\"Text bottom margin\",SHOW_LINE_NUMBER:\"Show line number\",LIGHT_MODE_THEME:\"Light Mode Theme\",DARK_MODE_THEME:\"Dark Mode Theme\",SAVE:\"Save\",SAVE_SUCCESS:\"Save success\",SAVE_ERROR:\"Save failed\",DELETE:\"Delete\",CONFIRM_DELETE_TITLE:\"Delete Confirmation\",CONFIRM_DELETE_MSG:\"Are you sure you want to delete?\",DELETE_SUCCESS:\"Delete success\",DELETE_ERROR:\"Delete failed\",IMPORT_EXAMPLE_ACTIONS:\"Import example actions\",REBUILD_ACTION_DATABASE:\"Rebuild Action Database\",REBUILD_ACTION_DATABASE_ALERT:\"Are you sure you want to rebuild?\",EXPORT:\"Export\",IMPORT:\"Import\",FILE_TYPE_ERROR:\"File type does not match\",OVERWRITE_ALERT:\"This operation will overwrite the current data. Do you want to continue?\",KEYBOARD:\"Keyboard\",KEYBOARD_HEIGHT:\"Keyboard Height\",BACKGROUND_COLOR:\"Background Color\",BACKGROUND_COLOR_DARK:\"Dark Background Color\",BACKGROUND_IMAGE:\"Background Image\",DELETE_DELAY:\"Delete Delay\",SWITCH_AFTER_INSERT:\"Switch After Insert\",JSBOX_TOOLBAR:\"JSBox Toolbar\",QUICK_START_SCRIPTS:\"Quick Start Scripts\",SEND:\"Send\",OPEN_IN_JSBOX:\"Open in JSBox\",SWITCH_KEYBOARD:\"Switch Keyboard\",TAPTIC_ENGINE:\"Taptic Engine\",TAPTIC_ENGINE_FOR_DELETE:\"Taptic Engine For Delete\",CHECK_UPDATE:\"Check Update\",UPDATE:\"Update\",WIDGET:\"Widget\",RECENT:\"Recent\",CLICK_ACTION:\"Click Action\",TODAY_WIDGET:\"Today Widget\",PREV_PAGE:\"Prev\",NEXT_PAGE:\"Next\",DISPLAY_MODE:\"Display Mode\",CLASSIC:\"Classic\",MODERN:\"Modern\",FILE_MANAGEMENT:\"File Management\",\"compatibility.rebuildUserAction.alert.title\":\"We need to rebuild some of the action!\",\"compatibility.rebuildUserAction.alert.message\":\"If you tap the OK button, the following actions will be rebuilt:\",\"compatibility.rebuildUserAction.alert.message2\":\"Only the action logic will be changed, and the name and icon will remain as it is.\"},\"zh-Hans\":{ALERT_INFO:\"提示\",NONE:\"什么都没有\",DONE:\"完成\",CLOSE:\"关闭\",FAILED_TO_LOAD_VIEW:\"加载视图失败\",VIEW_NOT_PROVIDED:\"未提供该视图\",UNCATEGORIZED:\"未分类\",SHARE:\"分享\",CLICK_TO_OPEN_JSBOX:\"点击标题打开主应用。\",CLIPS:\"剪切板\",CLIPBOARD:\"剪切板\",UNIVERSAL_CLIPBOARD:\"通用剪贴板\",UNIVERSAL_CLIPBOARD_TIPS:\"用剪贴板允许您在iPhone上复制某些内容,然后使用iCloud将其粘贴到Mac上(反之亦然)。\",CLIPS_STRUCTURE_ERROR:\"剪切板数据结构异常\",CLIPBOARD_NO_CHANGE:\"剪切板无变化\",ADD:\"添加\",TAG:\"标签\",ADD_TAG:\"添加标签\",EDIT:\"编辑\",SEARCH:\"搜索\",SEARCH_HISTORY:\"搜索历史\",SEARCH_RESULT:\"搜索结果\",NO_SEARCH_RESULT:\"搜索无结果\",PIN:\"置顶\",COPY:\"复制\",COPIED:\"已复制\",SORT:\"排序\",ACTIONS:\"动作\",MORE_ACTIONS:\"更多动作\",PREVIEW:\"预览\",MAX_ITEM_LENGTH:\"行数限制\",TEXT_MAX_LENGTH:\"显示字符长度\",AUTO_SAVE:\"自动保存\",AUTO_SYNC:\"自动同步\",SYNC_NOW:\"立即同步\",UNZIP_FAILED:\"解压文件失败\",SYNC_ALERT_INFO:\"若未在本机进行过同步则会直接拉取 iCloud 数据。\\\\n是否继续?\",DELETE_ICLOUD_DATA:\"删除 iCloud 数据\",REBUILD:\"重建\",REBUILD_DATABASE:\"重建数据库\",REBUILD_DATABASE_ALERT:\"重建数据库将会丢失顺序信息,是否确认重建?\",DELETE_ALL_DATA:\"删除所有数据\",DELETE_ALL_DATA_ALERT:\"确定要删除所有数据吗?\",DELETE_DATA:\"删除数据\",DELETE_TABLE:\"删除${table}的所有数据?\",SELECT_ALL:\"全选\",DESELECT_ALL:\"取消全选\",EDITOR:\"编辑器\",CREATE_NEW:\"新建\",CREATE_NEW_ACTION:\"新建动作\",CREATE_NEW_TYPE:\"新建分类\",TYPE_ALREADY_EXISTS:\"该类别已经存在\",EDIT_DETAILS:\"编辑信息\",EDIT_SCRIPT:\"编辑脚本\",INFORMATION:\"信息\",NAME:\"名称\",ICON:\"图标\",TYPE:\"分类\",DESCRIPTION:\"描述\",CODE:\"代码\",TEXT_INSETS:\"文本下边距\",SHOW_LINE_NUMBER:\"显示行号\",LIGHT_MODE_THEME:\"浅色模式主题\",DARK_MODE_THEME:\"深色模式主题\",SAVE:\"保存\",SAVE_SUCCESS:\"保存成功\",SAVE_ERROR:\"保存失败\",DELETE:\"删除\",CONFIRM_DELETE_TITLE:\"删除前确认\",CONFIRM_DELETE_MSG:\"确认要删除吗?\",DELETE_SUCCESS:\"删除成功\",DELETE_ERROR:\"删除失败\",IMPORT_EXAMPLE_ACTIONS:\"导入示例动作\",REBUILD_ACTION_DATABASE:\"重建动作库\",REBUILD_ACTION_DATABASE_ALERT:\"您确认要重建?\",EXPORT:\"导出\",IMPORT:\"导入\",FILE_TYPE_ERROR:\"文件类型不符\",OVERWRITE_ALERT:\"该操作将会覆盖当前数据,是否继续?\",KEYBOARD:\"键盘\",KEYBOARD_HEIGHT:\"键盘高度\",BACKGROUND_COLOR:\"背景色\",BACKGROUND_COLOR_DARK:\"深色模式背景色\",BACKGROUND_IMAGE:\"背景图片\",DELETE_DELAY:\"删除延时\",SWITCH_AFTER_INSERT:\"输入后切换\",JSBOX_TOOLBAR:\"JSBox 工具栏\",QUICK_START_SCRIPTS:\"快速启动脚本\",SEND:\"发送\",OPEN_IN_JSBOX:\"在 JSBox 中打开\",SWITCH_KEYBOARD:\"切换键盘\",TAPTIC_ENGINE:\"触感反馈\",TAPTIC_ENGINE_FOR_DELETE:\"删除按钮触感反馈\",CHECK_UPDATE:\"检查更新\",UPDATE:\"更新\",WIDGET:\"小组件\",RECENT:\"最近内容\",CLICK_ACTION:\"点击事件\",TODAY_WIDGET:\"通知中心小组件\",PREV_PAGE:\"上一页\",NEXT_PAGE:\"下一页\",DISPLAY_MODE:\"显示模式\",CLASSIC:\"经典\",MODERN:\"现代\",FILE_MANAGEMENT:\"文件管理\",\"compatibility.rebuildUserAction.alert.title\":\"我们需要重建部分动作!\",\"compatibility.rebuildUserAction.alert.message\":\"如果您点击 好,以下动作将会被重建:\",\"compatibility.rebuildUserAction.alert.message2\":\"只有动作逻辑会被更改,名称和图标将维持现状。\"}},$app.theme=\"auto\",$app.minSDKVer=\"2.19.0\",$app.minOSVer=\"14.0.0\",$app.idleTimerDisabled=!1,$app.keyboardToolbarEnabled=!0,$app.rotateDisabled=!1,__INFO__={name:\"CAIO\",version:\"1.8.0\",author:\"ipuppet\",module:!1},__README__={\"README.md\":\"# CAIO\\r\\n\\r\\n> Clipboard all in one.\\r\\n> \\r\\n> A Clipboard tool based on JSBox.\\r\\n\\r\\nSupport for home widget and notification center widgets.\\r\\n\\r\\n## Build Taio Action\\r\\n\\r\\nBuild script depend on [Parcel](https://parceljs.org/).\\r\\n\\r\\n```shell\\r\\nnpm i -g parcel\\r\\nnpm run build\\r\\n```\\r\\n\\r\\nYou can also use the packaged files directly [dist/CAIO-en.json](./dist/CAIO-en.json).\\r\\n\\r\\n## Actions\\r\\n\\r\\n> For details on how to write, see `scripts/action/README.md` or the book button in the upper right corner of the `Action` edit page in the app.\\r\\n\\r\\n### `Action` data difference in different environments\\r\\n\\r\\n- The data processed by the `Action` button at the top of the home page is the currently copied content.\\r\\n- The data processed by the `Action` menu that pops up by long-pressing the list is the selected content.\\r\\n- The data processed by the `Action` button in the editor is whatever is being edited.\\r\\n\\r\\n\\r\\n## Today Widget\\r\\n\\r\\n> Click to copy, long press to trigger the action.\\r\\n\\r\\nPlease try to avoid using the Today Widget when JSBox is running CAIO.\",\"README_CN.md\":\"# CAIO\\r\\n\\r\\n> Clipboard all in one.\\r\\n> \\r\\n> A Clipboard tool based on JSBox.\\r\\n\\r\\n支持桌面小组件和通知中心小组件\\r\\n\\r\\n## 构建 Taio 动作\\r\\n\\r\\n构建脚本依赖 [Parcel](https://parceljs.org/)\\r\\n\\r\\n```shell\\r\\nnpm i -g parcel\\r\\nnpm run build\\r\\n```\\r\\n\\r\\n您也可以直接使用已打包好的文件 [dist/CAIO-zh-Hans.json](./dist/CAIO-zh-Hans.json)\\r\\n\\r\\n## Actions\\r\\n\\r\\n> 编写方式详见 `scripts/action/README.md` 或应用内 `Action` 编辑页面右上角图书按钮。\\r\\n\\r\\n### 不同环境中 `Action` 数据区别\\r\\n\\r\\n- 首页顶部 `Action` 按钮处理的数据为当前复制的内容\\r\\n- 长按列表弹出的 `Action` 菜单处理的数据为被选中的内容\\r\\n- 编辑器中顶部 `Action` 按钮(闪电图形按钮)处理的数据为正在编辑的所有内容\\r\\n\\r\\n\\r\\n## Today Widget\\r\\n\\r\\n> 点击复制,长按触发动作。\\r\\n\\r\\n请尽量避免在 JSBox 运行 CAIO 时使用 Today Widget\"},__SETTING__=[{items:[{icon:[\"doc.on.clipboard\",\"#FFCC66\"],type:\"child\",title:\"CLIPS\",key:\"clipboard\",children:[{items:[{icon:[\"link\",\"#FF6633\"],title:\"UNIVERSAL_CLIPBOARD\",type:\"switch\",key:\"clipboard.universal\",value:!0},{icon:[\"cursorarrow.rays\",\"#FF6633\"],title:\"Tips\",type:\"script\",key:\"clipboard.tips.universal\",value:\"$ui.alert({title:$l10n('UNIVERSAL_CLIPBOARD'),message:$l10n('UNIVERSAL_CLIPBOARD_TIPS')})\"}]},{items:[{icon:[\"text.alignleft\",\"#FFCC66\"],title:\"MAX_ITEM_LENGTH\",type:\"number\",key:\"clipboard.maxItemLength\",value:100},{icon:[\"square.and.arrow.down.on.square\",\"#FF6633\"],title:\"AUTO_SAVE\",type:\"switch\",key:\"clipboard.autoSave\",value:!0}]},{items:[{icon:[\"square.and.arrow.up\"],title:\"EXPORT\",type:\"script\",key:\"clipboard.export\",value:\"this.method.exportClipboard\"},{icon:[\"square.and.arrow.down\",\"#FFCC33\"],title:\"IMPORT\",type:\"script\",key:\"clipboard.import\",value:\"this.method.importClipboard\"}]},{items:[{icon:[\"arrow.2.circlepath\",\"red\"],title:\"REBUILD_DATABASE\",type:\"script\",key:\"clipboard.rebuildDatabase\",value:\"this.method.rebuildDatabase\"},{icon:[\"trash\",\"red\"],title:\"DELETE_ALL_DATA\",type:\"script\",key:\"clipboard.deleteAllData\",value:\"this.method.deleteAllData\"}]}]},{icon:[\"bolt.circle\",\"#FF6633\"],type:\"child\",title:\"ACTIONS\",key:\"action\",children:[{items:[{icon:[\"bolt.circle\",\"#FF6633\"],title:\"IMPORT_EXAMPLE_ACTIONS\",type:\"script\",key:\"action.importExampleAction\",value:\"this.method.importExampleAction\"}]},{items:[{icon:[\"square.and.arrow.up\"],title:\"EXPORT\",type:\"script\",key:\"action.export\",value:\"this.method.exportAction\"},{icon:[\"square.and.arrow.down\",\"#FFCC33\"],title:\"IMPORT\",type:\"script\",key:\"action.import\",value:\"this.method.importAction\"}]},{items:[{icon:[\"arrow.2.circlepath\",\"red\"],title:\"REBUILD_ACTION_DATABASE\",type:\"script\",key:\"action.rebuildAction\",value:\"this.method.rebuildAction\"}]}]},{icon:[\"pencil.circle\",\"#CC0099\"],type:\"child\",title:\"EDITOR\",key:\"editor\",children:[{title:\"CLIPS\",items:[{icon:[\"wand.and.stars\",\"#FF6633\"],title:\"TEXT_INSETS\",type:\"number\",key:\"editor.text.insets\",value:300}]},{title:\"CODE\",items:[{icon:[\"list.number\",\"#6699CC\"],title:\"SHOW_LINE_NUMBER\",type:\"switch\",key:\"editor.code.lineNumbers\",value:!1},{icon:[\"wand.and.stars\",\"#FF6633\"],title:\"LIGHT_MODE_THEME\",type:\"input\",key:\"editor.code.lightTheme\",value:\"atom-one-light\"},{icon:[\"wand.and.stars\",\"#FF6633\"],title:\"DARK_MODE_THEME\",type:\"input\",key:\"editor.code.darkTheme\",value:\"atom-one-dark\"}]}]},{icon:[\"keyboard\",\"#a2a5a6\"],type:\"child\",title:\"KEYBOARD\",key:\"keyboard\",children:[{items:[{icon:[\"rectangle.3.offgrid.fill\"],title:\"PREVIEW\",type:\"push\",key:\"keyboard.previewAndHeight\",view:\"this.method.previewKeyboard\",value:267}]},{items:[{icon:[\"sun.min\",\"#A569BD\"],title:\"BACKGROUND_COLOR\",type:\"color\",key:\"keyboard.background.color\",value:\"#D1D3D9\"},{icon:[\"sun.min\",\"#A569BD\"],title:\"BACKGROUND_COLOR_DARK\",type:\"color\",key:\"keyboard.background.color.dark\",value:\"#313131\"},{icon:[\"photo\",\"#FFCC66\"],title:\"BACKGROUND_IMAGE\",type:\"image\",key:\"keyboard.background.image\"}]},{items:[{icon:[\"globe\",\"#1899c4\"],title:\"SWITCH_AFTER_INSERT\",type:\"switch\",key:\"keyboard.switchAfterInsert\",value:!1},{icon:[\"cursor.rays\",\"#FF8C00\"],title:\"TAPTIC_ENGINE\",type:\"switch\",key:\"keyboard.tapticEngine\",value:!0},{icon:[\"option\",\"#157EFB\"],title:\"JSBOX_TOOLBAR\",type:\"switch\",key:\"keyboard.showJSBoxToolbar\",value:!1},{icon:[\"paperplane\"],title:\"QUICK_START_SCRIPTS\",type:\"script\",key:\"keyboard.setKeyboardQuickStart\",value:\"this.method.setKeyboardQuickStart\"}]},{items:[{icon:[\"cursor.rays\",\"#FF8C00\"],title:\"TAPTIC_ENGINE_FOR_DELETE\",type:\"switch\",key:\"keyboard.tapticEngineForDelete\",value:!0},{icon:[\"rays\",\"#FFCC33\"],title:\"DELETE_DELAY\",type:\"number\",key:\"keyboard.deleteDelay\",value:.05}]}]},{icon:[\"rectangle.3.offgrid.fill\",\"#1899c4\"],type:\"child\",title:\"WIDGET\",key:\"widget\",children:[{items:[{icon:[\"rectangle.3.offgrid.fill\"],title:\"PREVIEW\",type:\"script\",key:\"previewWidget\",value:\"this.method.previewWidget\"}]},{title:\"2x2\",items:[{icon:[\"link\"],title:\"CLICK_ACTION\",type:\"menu\",key:\"widget.2x2.widgetURL\",items:[\"ADD\",\"ACTIONS\",\"CLIPS\"],value:2}]}]},{icon:[\"filemenu.and.selection\",\"#ebcc34\"],type:\"child\",title:\"TODAY_WIDGET\",key:\"todayWidget\",children:[{items:[{icon:[\"rectangle.3.offgrid.fill\"],title:\"PREVIEW\",type:\"script\",key:\"todayWidget.preview\",value:\"this.method.previewTodayWidget\"}]},{items:[{icon:[\"bolt.circle\"],title:\"ACTIONS\",type:\"script\",key:\"todayWidget.setTodayWidgetActions\",value:\"this.method.setTodayWidgetActions\"}]}]}]},{items:[{icon:[\"rectangle.topthird.inset.filled\",\"#A569BD\"],title:\"DISPLAY_MODE\",type:\"tab\",key:\"mainUIDisplayMode\",items:[\"CLASSIC\",\"MODERN\"],value:0},{icon:[\"folder.fill\",\"#FF9900\"],title:\"FILE_MANAGEMENT\",type:\"script\",key:\"fileManager\",value:\"this.method.fileManager\"}]},{items:[{icon:[\"/assets/icon/github.com.jpeg\",\"white\"],title:\"Github\",type:\"info\",key:\"github\",value:[\"ipuppet/CAIO\",\"https://github.com/ipuppet/CAIO\"]},{icon:[\"/assets/icon/telegram.png\",\"white\"],title:\"Telegram\",type:\"info\",key:\"telegram\",value:[\"JSBoxTG\",\"https://t.me/JSBoxTG\"]},{icon:[\"person.fill\",\"#FF9900\"],title:\"AUTHOR\",type:\"info\",key:\"author\",value:[\"ipuppet\",\"https://blog.ultagic.com\"]},{icon:[\"arrow.2.circlepath\"],title:\"CHECK_UPDATE\",type:\"script\",key:\"checkUpdate\",value:\"this.method.checkUpdate\"},{icon:[\"book.fill\",\"#A569BD\"],title:\"README\",type:\"script\",key:\"readme\",value:\"this.method.readme\"}]}],__ACTIONS__={clipboard:{B23Clean:{\"config.json\":'{\\r\\n \"icon\": \"trash\",\\r\\n \"color\": \"#FF0000\",\\r\\n \"name\": \"b23 清除追踪\",\\r\\n \"description\": \"清除 b23.tv 分享链接中的追踪参数,转换为 BV 视频链接。\"\\r\\n}',\"main.js\":'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n */\\r\\nclass MyAction extends Action {\\r\\n l10n() {\\r\\n return {\\r\\n \"zh-Hans\": {\\r\\n \"b23clean.converting\": \"正在转换...\",\\r\\n \"b23clean.noUrl\": \"未检测到链接\",\\r\\n \"b23clean.noBiliUrl\": \"未检测到 bilibili 链接\",\\r\\n \"b23clean.success\": \"已转换为 BV 视频链接\",\\r\\n \"b23clean.noChange\": \"无变化\",\\r\\n \"b23clean.multipleLinks\": \"多条链接仅在编辑模式下可用。\"\\r\\n },\\r\\n en: {\\r\\n \"b23clean.converting\": \"Converting...\",\\r\\n \"b23clean.noUrl\": \"No link detected\",\\r\\n \"b23clean.noBiliUrl\": \"bilibili link not detected\",\\r\\n \"b23clean.success\": \"Converted to BV video link\",\\r\\n \"b23clean.noChange\": \"No change\",\\r\\n \"b23clean.multipleLinks\": \"Multiple links are only available in edit mode.\"\\r\\n }\\r\\n }\\r\\n }\\r\\n\\r\\n async cleanUrl(b23url) {\\r\\n if (b23url.indexOf(\"bilibili.com\") === -1 && b23url.indexOf(\"b23.tv\") === -1) {\\r\\n throw new Error($l10n(\"b23clean.noBiliUrl\"))\\r\\n }\\r\\n\\r\\n let url = b23url\\r\\n if (b23url.indexOf(\"b23.tv\") >= 0) {\\r\\n const resp = await $http.get(b23url)\\r\\n url = resp.response.url\\r\\n }\\r\\n\\r\\n const queryStart = url.indexOf(\"?\")\\r\\n if (queryStart > -1) {\\r\\n url = url.substring(0, queryStart - 1)\\r\\n }\\r\\n\\r\\n return url\\r\\n }\\r\\n\\r\\n /**\\r\\n * 系统会调用 do() 方法\\r\\n */\\r\\n async do() {\\r\\n $ui.toast($l10n(\"b23clean.converting\"), 1000)\\r\\n\\r\\n try {\\r\\n const b23url = this.getUrls()\\r\\n if (b23url.length === 0) {\\r\\n throw new Error($l10n(\"b23clean.noUrl\"))\\r\\n }\\r\\n\\r\\n if (b23url.length === 1) {\\r\\n let url = await this.cleanUrl(b23url[0])\\r\\n $ui.clearToast()\\r\\n $ui.alert({\\r\\n title: $l10n(\"b23clean.success\"),\\r\\n message: url,\\r\\n actions: [\\r\\n { title: $l10n(\"OK\") },\\r\\n {\\r\\n title: $l10n(\"COPY\"),\\r\\n handler: () => {\\r\\n $clipboard.text = url\\r\\n $ui.success($l10n(\"COPIED\"))\\r\\n }\\r\\n }\\r\\n ]\\r\\n })\\r\\n } else {\\r\\n if (this.env !== ActionEnv.editor) {\\r\\n $ui.toast($l10n(\"b23clean.multipleLinks\"))\\r\\n return\\r\\n }\\r\\n let flag = false\\r\\n for (let i = 0; i < b23url.length; i++) {\\r\\n try {\\r\\n const url = b23url[i].trim()\\r\\n const replacedUrl = await this.cleanUrl(url)\\r\\n flag = true\\r\\n\\r\\n if (url !== replacedUrl) {\\r\\n const newText = this.text.replace(url, replacedUrl)\\r\\n this.setContent(newText)\\r\\n }\\r\\n } catch {}\\r\\n }\\r\\n if (!flag) {\\r\\n throw new Error($l10n(\"b23clean.noBiliUrl\"))\\r\\n } else {\\r\\n $ui.toast($l10n(\"b23clean.noChange\"))\\r\\n }\\r\\n }\\r\\n } catch (error) {\\r\\n $ui.clearToast()\\r\\n $delay(0.5, () => $ui.error(error))\\r\\n }\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## B23Clean\\r\\n\\r\\n清除 b23.tv 分享链接中的追踪参数,转换为 BV 视频链接。\"},CleanClipboard:{\"config.json\":'{\\r\\n \"icon\": \"trash\",\\r\\n \"color\": \"#FF0000\",\\r\\n \"name\": \"清除剪切板\",\\r\\n \"description\": \"清除剪切板内容\"\\r\\n}',\"main.js\":'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n */\\r\\nclass MyAction extends Action {\\r\\n l10n() {\\r\\n return {\\r\\n \"zh-Hans\": {\\r\\n \"clipboard.clean.success\": \"剪切板已清空\"\\r\\n },\\r\\n en: {\\r\\n \"clipboard.clean.success\": \"Clipboard is cleaned\"\\r\\n }\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * 系统会调用 do() 方法\\r\\n */\\r\\n do() {\\r\\n $clipboard.clear()\\r\\n $ui.success($l10n(\"clipboard.clean.success\"))\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## CleanClipboard\"},DownloadFromUrl:{\"config.json\":'{\\r\\n \"icon\": \"square.and.arrow.down\",\\r\\n \"color\": \"#FF0099\",\\r\\n \"name\": \"从链接下载\",\\r\\n \"description\": \"从链接下载内容,如 js 文件内容等\"\\r\\n}',\"main.js\":'class MyAction extends Action {\\r\\n async downloadContent(url) {\\r\\n const response = await $http.get({\\r\\n url,\\r\\n showsProgress: true\\r\\n })\\r\\n if (response.error) {\\r\\n $ui.alert(response.error.localizedDescription)\\r\\n } else {\\r\\n return response\\r\\n }\\r\\n }\\r\\n\\r\\n async do() {\\r\\n const url = this.getUrls()\\r\\n let response = undefined\\r\\n if (url.length > 1) {\\r\\n $ui.menu({\\r\\n items: url,\\r\\n handler: async (title, index) => {\\r\\n response = await this.downloadContent(url[index])\\r\\n }\\r\\n })\\r\\n } else if (url.length === 1) {\\r\\n response = await this.downloadContent(url[0])\\r\\n } else {\\r\\n $ui.warning(\"未检测到链接\")\\r\\n return\\r\\n }\\r\\n $share.sheet([\\r\\n {\\r\\n name: response.response.suggestedFilename,\\r\\n data: response.data\\r\\n }\\r\\n ])\\r\\n return response\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## DownloadFromUrl\\r\\n\\r\\n从链接下载内容,如 js 文件内容等\"},GetFromWin:{\"config.json\":'{\\r\\n \"icon\": \"square.and.arrow.down\",\\r\\n \"color\": \"#33CC33\",\\r\\n \"name\": \"读取 clipsync\",\\r\\n \"description\": \"通 clipsync 读取 PC 剪切板。\"\\r\\n}',\"main.js\":'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n */\\r\\nclass MyAction extends Action {\\r\\n async getIp(refresh = false) {\\r\\n let address = $cache.get(\"caio.action.clipsync.address\")\\r\\n if (refresh || !address) {\\r\\n address = await $input.text({\\r\\n placeholder: \"Address\",\\r\\n text: $cache.get(\"caio.action.clipsync.address\")\\r\\n })\\r\\n }\\r\\n\\r\\n $cache.set(\"caio.action.clipsync.address\", address)\\r\\n\\r\\n if (!address.startsWith(\"http\")) {\\r\\n address = \"http://\" + address\\r\\n }\\r\\n\\r\\n return address\\r\\n }\\r\\n\\r\\n async do() {\\r\\n let address = await this.getIp()\\r\\n\\r\\n $ui.toast(\"Loading...\", 5)\\r\\n try {\\r\\n const resp = await this.request(address + \"/api/clip\", \"GET\")\\r\\n if (resp.data.status) {\\r\\n $ui.success(\"success\")\\r\\n $clipboard.text = resp.data.data\\r\\n }\\r\\n } catch (error) {\\r\\n $ui.clearToast()\\r\\n $ui.alert({\\r\\n title: \"Error\",\\r\\n message: String(error),\\r\\n actions: [\\r\\n { title: \"OK\" },\\r\\n {\\r\\n title: \"Reset Adress\",\\r\\n handler: () => this.getIp(true)\\r\\n }\\r\\n ]\\r\\n })\\r\\n }\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## GetFromWin\\r\\n\\r\\n通 clipsync 读取 PC 剪切板。\\r\\n\\r\\n服务端:[clipsync](https://github.com/ipuppet/clipsync)\\r\\n\"},OpenUrl:{\"config.json\":'{\\r\\n \"icon\": \"link\",\\r\\n \"color\": \"#FF0099\",\\r\\n \"name\": \"打开链接\",\\r\\n \"description\": \"提取文本中的链接并打开\"\\r\\n}',\"main.js\":'class MyAction extends Action {\\r\\n l10n() {\\r\\n return {\\r\\n \"zh-Hans\": {\\r\\n \"openLink.nourl\": \"未检测到链接\"\\r\\n },\\r\\n en: {\\r\\n \"openLink.nourl\": \"No link detected\"\\r\\n }\\r\\n }\\r\\n }\\r\\n\\r\\n openUrl(url) {\\r\\n $app.openURL(url.trim())\\r\\n }\\r\\n\\r\\n do() {\\r\\n const url = this.getUrls()\\r\\n if (url.length > 1) {\\r\\n $ui.menu({\\r\\n items: url,\\r\\n handler: (title, index) => {\\r\\n this.openUrl(url[index])\\r\\n }\\r\\n })\\r\\n } else if (url.length === 1) {\\r\\n this.openUrl(url[0])\\r\\n } else {\\r\\n $ui.warning($l10n(\"openLink.nourl\"))\\r\\n }\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## OpenUrl\\r\\n\\r\\n提取文本中的URL并打开\"},SendToWin:{\"config.json\":'{\\r\\n \"icon\": \"square.and.arrow.up\",\\r\\n \"color\": \"#33CC33\",\\r\\n \"name\": \"推送 clipsync\",\\r\\n \"description\": \"通 clipsync 推送剪切板至 PC。\"\\r\\n}',\"main.js\":'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n */\\r\\nclass MyAction extends Action {\\r\\n async getIp(refresh = false) {\\r\\n let address = $cache.get(\"caio.action.clipsync.address\")\\r\\n if (refresh || !address) {\\r\\n address = await $input.text({\\r\\n placeholder: \"Address\",\\r\\n text: $cache.get(\"caio.action.clipsync.address\")\\r\\n })\\r\\n }\\r\\n\\r\\n $cache.set(\"caio.action.clipsync.address\", address)\\r\\n\\r\\n if (!address.startsWith(\"http\")) {\\r\\n address = \"http://\" + address\\r\\n }\\r\\n\\r\\n return address\\r\\n }\\r\\n\\r\\n async do() {\\r\\n let address = await this.getIp()\\r\\n\\r\\n $ui.toast(\"Loading...\", 5)\\r\\n try {\\r\\n const resp = await this.request(address + \"/api/clip\", \"POST\", {\\r\\n data: $clipboard.text\\r\\n })\\r\\n if (resp.data.status) {\\r\\n $ui.success(\"success\")\\r\\n }\\r\\n } catch (error) {\\r\\n $ui.clearToast()\\r\\n $ui.alert({\\r\\n title: \"Error\",\\r\\n message: String(error),\\r\\n actions: [\\r\\n { title: \"OK\" },\\r\\n {\\r\\n title: \"Reset Adress\",\\r\\n handler: () => this.getIp(true)\\r\\n }\\r\\n ]\\r\\n })\\r\\n }\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## SendToWin\\r\\n\\r\\n通 clipsync 推送剪切板至 PC。\\r\\n\\r\\n服务端:[clipsync](https://github.com/ipuppet/clipsync)\\r\\n\"},Tokenize:{\"config.json\":'{\\r\\n \"icon\": \"pencil.and.ellipsis.rectangle\",\\r\\n \"color\": \"#0099FF\",\\r\\n \"name\": \"分词复制\",\\r\\n \"description\": \"将文本分词处理后复制\"\\r\\n}',\"main.js\":'class MyAction extends Action {\\r\\n getView() {\\r\\n const color = {\\r\\n background: {\\r\\n normal: $color(\"#E7F2FF\", \"#E7F2FF\"),\\r\\n highlight: $color(\"##074FF\", \"#BBDAFF\")\\r\\n },\\r\\n text: {\\r\\n normal: $color(\"##074FF\", \"##074FF\"),\\r\\n highlight: $color(\"#FFFFFF\", \"#ADADAD\")\\r\\n }\\r\\n }\\r\\n const fontSize = 16\\r\\n const edges = 10\\r\\n return {\\r\\n type: \"matrix\",\\r\\n layout: $layout.fill,\\r\\n props: {\\r\\n spacing: edges,\\r\\n data: this.results.map(item => ({ label: { text: item } })),\\r\\n template: {\\r\\n views: [{\\r\\n type: \"label\",\\r\\n props: {\\r\\n id: \"label\",\\r\\n align: $align.center,\\r\\n cornerRadius: edges,\\r\\n bgcolor: color.background.normal,\\r\\n font: $font(fontSize),\\r\\n textColor: color.text.normal\\r\\n },\\r\\n layout: $layout.fill\\r\\n }]\\r\\n }\\r\\n },\\r\\n events: {\\r\\n highlighted: () => { },\\r\\n itemSize: (sender, indexPath) => {\\r\\n const width = fontSize * this.results[indexPath.item].length + 1\\r\\n if (this.maxtrixItemHeight === undefined)\\r\\n this.maxtrixItemHeight = fontSize + edges * 2\\r\\n return $size(width + edges * 2, this.maxtrixItemHeight)\\r\\n },\\r\\n didSelect: (sender, indexPath) => {\\r\\n const index = this.selected.indexOf(indexPath.item)\\r\\n const label = sender.cell(indexPath).get(\"label\")\\r\\n if (index === -1) {\\r\\n this.selected.push(indexPath.item)\\r\\n label.bgcolor = color.background.highlight\\r\\n label.textColor = color.text.highlight\\r\\n } else {\\r\\n this.selected.splice(index, 1)\\r\\n label.bgcolor = color.background.normal\\r\\n label.textColor = color.text.normal\\r\\n }\\r\\n }\\r\\n }\\r\\n }\\r\\n }\\r\\n /**\\r\\n * 系统会调用 do() 方法\\r\\n */\\r\\n do() {\\r\\n this.selected = []\\r\\n this.results = []\\r\\n $text.tokenize({\\r\\n text: this.text,\\r\\n handler: results => {\\r\\n this.results = results\\r\\n this.pageSheet({\\r\\n view: this.getView(),\\r\\n done: () => {\\r\\n const result = []\\r\\n this.selected.sort().forEach(i => {\\r\\n result.push(this.results[i])\\r\\n })\\r\\n if (result.length > 0) {\\r\\n const text = result.join(\"\")\\r\\n $clipboard.text = text\\r\\n $ui.alert({\\r\\n title: \"完成\",\\r\\n message: `已复制内容:${text}`\\r\\n })\\r\\n }\\r\\n }\\r\\n })\\r\\n }\\r\\n })\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## Tokenize\\r\\n\\r\\n> 将文本分词处理后复制\"}},editor:{PreviewMarkdown:{\"config.json\":'{\\r\\n \"icon\": \"book\",\\r\\n \"color\": \"#9900CC\",\\r\\n \"name\": \"预览Markdown\",\\r\\n \"description\": \"预览Markdown\"\\r\\n}',\"main.js\":'class MyAction extends Action {\\r\\n do() {\\r\\n this.pageSheet({\\r\\n view: {\\r\\n type: \"markdown\",\\r\\n props: { content: this.text },\\r\\n layout: $layout.fill\\r\\n }\\r\\n })\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## PreviewMarkdown\\r\\n\\r\\n> 预览Markdown\"},SelectedText:{\"config.json\":'{\\r\\n \"icon\": \"crop\",\\r\\n \"color\": \"#6699CC\",\\r\\n \"name\": \"选中的文本\",\\r\\n \"description\": \"这是个测试 Action, 将在控制台输出当前选中的文本\"\\r\\n}',\"main.js\":\"class MyAction extends Action {\\r\\n do() {\\r\\n if (this.selectedRange.length > 0) {\\r\\n const selectedText = this.text\\r\\n $ui.alert(selectedText)\\r\\n }\\r\\n }\\r\\n}\\r\\n\",\"README.md\":\"## SelectedText\\r\\n\\r\\n> 显示选中的文本\"}},uncategorized:{DeleteClips:{\"config.json\":'{\\r\\n \"icon\": \"trash\",\\r\\n \"color\": \"#FF0000\",\\r\\n \"name\": \"删除所有剪切板\",\\r\\n \"description\": \"删除所有保存的剪切板(不包括置顶)\"\\r\\n}',\"main.js\":'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n */\\r\\n\\r\\nclass MyAction extends Action {\\r\\n async do() {\\r\\n try {\\r\\n const action = await this.clearAllClips()\\r\\n if (action) {\\r\\n $ui.success($l10n(\"DONE\"))\\r\\n }\\r\\n } catch (error) {\\r\\n $ui.error(error)\\r\\n }\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## DeleteClips\"},DisplayClipboard:{\"config.json\":'{\\r\\n \"icon\": \"option\",\\r\\n \"color\": \"#FF6633\",\\r\\n \"name\": \"显示剪切板\",\\r\\n \"description\": \"显示剪切板内容\"\\r\\n}',\"main.js\":'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n */\\r\\n\\r\\nclass MyAction extends Action {\\r\\n do() {\\r\\n this.pageSheet({\\r\\n view: {\\r\\n type: \"label\",\\r\\n props: {\\r\\n lines: 0,\\r\\n text: $clipboard.text,\\r\\n align: $align.center\\r\\n },\\r\\n layout: $layout.fill\\r\\n }\\r\\n })\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## DisplayClipboard\"},ExportAllContent:{\"config.json\":'{\\r\\n \"icon\": \"square.and.arrow.up\",\\r\\n \"color\": \"#FF3300\",\\r\\n \"name\": \"导出数据\",\\r\\n \"description\": \"导出所有保存的数据\"\\r\\n}',\"main.js\":'class MyAction extends Action {\\r\\n do() {\\r\\n const data = this.getAllClips()\\r\\n if (data.clips.length > 0 || data.pin.length > 0) {\\r\\n $share.sheet(JSON.stringify(data, null, 2))\\r\\n } else {\\r\\n $ui.alert(\"无数据\")\\r\\n }\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## ExportAllContent\\r\\n\\r\\n导出所有保存的数据\"},Replace:{\"config.json\":'{\\r\\n \"icon\": \"square.and.arrow.up\",\\r\\n \"color\": \"#FF3300\",\\r\\n \"name\": \"查找替换\",\\r\\n \"description\": \"查找替换\"\\r\\n}',\"main.js\":'function HtmlTemplate(html) {\\r\\n return `\\r\\n\\r\\n\\r\\n \\r\\n\\r\\n\\r\\n${html}\\r\\n\\r\\n\\r\\n`\\r\\n}\\r\\n\\r\\nclass MyAction extends Action {\\r\\n do() {\\r\\n $ui.menu({\\r\\n items: [\"忽略大小写\", \"大小写敏感\", \"正则表达式\"],\\r\\n handler: async (title, idx) => {\\r\\n const patternText = await $input.text({\\r\\n placeholder: \"查找内容\"\\r\\n })\\r\\n const replaceString = await $input.text({\\r\\n placeholder: \"替换内容\"\\r\\n })\\r\\n let pattern = undefined\\r\\n if (idx === 0) {\\r\\n pattern = new RegExp(`(${patternText})+`, \"gi\")\\r\\n } else if (idx === 1) {\\r\\n pattern = new RegExp(`(${patternText})+`, \"g\")\\r\\n } else if (idx === 2) {\\r\\n pattern = new RegExp(patternText, \"g\")\\r\\n }\\r\\n\\r\\n const matchResultPreview = this.text.replace(pattern, `${replaceString}`)\\r\\n const matchResult = this.text.replace(pattern, replaceString)\\r\\n this.pageSheet({\\r\\n title: \"替换预览\",\\r\\n doneText: \"替换\",\\r\\n view: {\\r\\n type: \"web\",\\r\\n props: {\\r\\n html: HtmlTemplate(matchResultPreview)\\r\\n },\\r\\n layout: $layout.fill\\r\\n },\\r\\n done: () => {\\r\\n this.setContent(matchResult)\\r\\n }\\r\\n })\\r\\n }\\r\\n })\\r\\n // this.setContent(\"Hello world!\")\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## Replace\\r\\n\\r\\n查找替换\"}}};var $8Makm=parcelRequire(\"8Makm\");$8Makm.run()})();" + "value": "(()=>{var $parcel$global=\"undefined\"!=typeof globalThis?globalThis:\"undefined\"!=typeof self?self:\"undefined\"!=typeof window?window:\"undefined\"!=typeof global?global:{},$parcel$modules={},$parcel$inits={},parcelRequire=$parcel$global.parcelRequire94c2;null==parcelRequire&&(parcelRequire=function(e){if(e in $parcel$modules)return $parcel$modules[e].exports;if(e in $parcel$inits){var t=$parcel$inits[e];delete $parcel$inits[e];var i={id:e,exports:{}};return $parcel$modules[e]=i,t.call(i.exports,i,i.exports),i.exports}var r=new Error(\"Cannot find module '\"+e+\"'\");throw r.code=\"MODULE_NOT_FOUND\",r},parcelRequire.register=function(e,t){$parcel$inits[e]=t},$parcel$global.parcelRequire94c2=parcelRequire),parcelRequire.register(\"8Makm\",(function(e,t){var i=parcelRequire(\"gxpqj\"),r=i.UIKit,s=i.ViewController,a=i.TabBarController,n=i.Kernel,o=i.FileStorage,l=i.Setting,c=i.FileManager,h=parcelRequire(\"jEwwi\"),d=parcelRequire(\"imdB1\"),p=parcelRequire(\"44eiF\"),u=parcelRequire(\"gYDdO\"),g=parcelRequire(\"9RsVy\");const $=new o;class f extends n{constructor(){let e;super(),this.query=$context.query,this.fileStorage=$;try{e=__SETTING__}catch{}this.setting=new l({fileStorage:this.fileStorage,structure:e}),this.setting.loadConfig(),this.storage=new h(this),this.initComponents(),g(this)}addOpenInJsboxButton(){this.useJsboxNav(),this.setNavButtons([{image:$image(\"assets/icon.png\"),handler:()=>this.openInJsbox()}])}initComponents(){this.clips=new d(this),this.actionManager=new p(this),this.fileManager=new c}deleteConfirm(e,t){$ui.alert({title:$l10n(\"CONFIRM_DELETE_TITLE\"),message:e,actions:[{title:$l10n(\"DELETE\"),style:$alertActionType.destructive,handler:()=>{t()}},{title:$l10n(\"CANCEL\")}]})}}class y{static kernel=$app.env!==$env.widget?new f:void 0;static renderMainUI(){const e={clips:{icon:\"doc.on.clipboard\",title:$l10n(\"CLIPS\")},actions:{icon:\"command\",title:$l10n(\"ACTIONS\")},setting:{icon:\"gear\",title:$l10n(\"SETTING\")}};if(this.kernel.setting.setEvent(\"onSet\",(e=>{\"mainUIDisplayMode\"===e&&$delay(.3,(()=>$addin.restart()))})),0===this.kernel.setting.get(\"mainUIDisplayMode\"))this.kernel.useJsboxNav(),this.kernel.setting.useJsboxNav(),this.kernel.setNavButtons([{symbol:e.setting.icon,title:e.setting.title,handler:()=>{r.push({title:e.setting.title,views:[this.kernel.setting.getListView()]})}},{symbol:e.actions.icon,title:e.actions.title,handler:()=>{this.kernel.actionManager.present()}}]),this.kernel.UIRender(this.kernel.clips.getNavigationView().getPage());else{this.kernel.fileManager.setViewController(new s),this.kernel.tabBarController=new a;const t=this.kernel.clips.getNavigationView();this.kernel.tabBarController.setPages({clips:t.getPage(),actions:this.kernel.actionManager.getPage(),setting:this.kernel.setting.getPage()}).setCells({clips:e.clips,actions:e.actions,setting:e.setting}),this.kernel.UIRender(this.kernel.tabBarController.generateView().definition)}}static renderKeyboardUI(){this.kernel.addOpenInJsboxButton();const e=new(parcelRequire(\"7eNYp\"))(this.kernel);this.kernel.UIRender(e.getView())}static renderTodayUI(){this.kernel.addOpenInJsboxButton();const e=new(parcelRequire(\"49je6\"))(this.kernel);this.kernel.UIRender(e.getView())}static renderUnsupported(){$intents.finish(\"不支持在此环境中运行\"),$ui.render({views:[{type:\"label\",props:{text:\"不支持在此环境中运行\",align:$align.center},layout:$layout.fill}]})}}class b{static widgetInstance(e,...t){if($file.exists(`/scripts/widget/${e}.js`)){const{Widget:i}=require(`./widget/${e}.js`);return new i(...t)}return!1}static renderError(){$widget.setTimeline({render:()=>({type:\"text\",props:{text:\"Invalid argument\"}})})}static renderClipboard(){const e=new l;e.loadConfig().setReadonly();b.widgetInstance(\"Clipboard\",e,new h({fileStorage:$})).render()}static render(e=$widget.inputValue){\"Clipboard\"===(e=e??\"Clipboard\")?b.renderClipboard():b.renderError()}}e.exports={Widget:b,run:()=>{u(y.kernel),$app.env===$env.app||$app.env===$env.action?y.renderMainUI():$app.env===$env.keyboard?y.renderKeyboardUI():$app.env===$env.widget?b.render():$app.env===$env.today?y.renderTodayUI():y.renderUnsupported()}}})),parcelRequire.register(\"gxpqj\",(function(module,exports){var $parcel$global=\"undefined\"!=typeof globalThis?globalThis:\"undefined\"!=typeof self?self:\"undefined\"!=typeof window?window:void 0!==$parcel$global?$parcel$global:{},$parcel$modules={},$parcel$inits={},parcelRequire=$parcel$global.parcelRequire94c2;null==parcelRequire&&(parcelRequire=function(e){if(e in $parcel$modules)return $parcel$modules[e].exports;if(e in $parcel$inits){var t=$parcel$inits[e];delete $parcel$inits[e];var i={id:e,exports:{}};return $parcel$modules[e]=i,t.call(i.exports,i,i.exports),i.exports}var r=new Error(\"Cannot find module '\"+e+\"'\");throw r.code=\"MODULE_NOT_FOUND\",r},parcelRequire.register=function(e,t){$parcel$inits[e]=t},$parcel$global.parcelRequire94c2=parcelRequire),parcelRequire.register(\"45Ip7\",(function(e,t){class i{static#e=$objc(\"UIApplication\").$sharedApplication();static#t=$objc(\"UINotificationFeedbackGenerator\").$new();static feedbackSuccess(){i.#t.$notificationOccurred(0)}static feedbackError(){i.#t.$notificationOccurred(2)}static align={left:0,right:1,top:2,bottom:3};static textColor=$color(\"primaryText\");static linkColor=$color(\"systemLink\");static primaryViewBackgroundColor=$color(\"primarySurface\");static scrollViewBackgroundColor=$color(\"insetGroupedBackground\");static scrollViewList=[\"list\",\"matrix\"];static isLargeScreen=$device.isIpad||$device.isIpadPro;static get windowSize(){return $objc(\"UIWindow\").$keyWindow().jsValue().size}static NavigationBarNormalHeight=$objc(\"UINavigationController\").invoke(\"alloc.init\").$navigationBar().jsValue().frame.height;static NavigationBarLargeTitleHeight=$objc(\"UITabBarController\").invoke(\"alloc.init\").$tabBar().jsValue().frame.height+i.NavigationBarNormalHeight;static get isSplitScreenMode(){return i.isLargeScreen&&$device.info.screen.width!==i.windowSize.width}static get topSafeAreaInsets(){return i.#e?.$keyWindow()?.$safeAreaInsets()?.top??0}static get bottomSafeAreaInsets(){return i.#e?.$keyWindow()?.$safeAreaInsets()?.bottom??0}static get statusBarOrientation(){return i.#e.$statusBarOrientation()}static get consoleBarHeight(){if($app.isDebugging){let e=i.#e.$statusBarFrame().height+26;return $device.isIphoneX&&(e+=30),e}return 0}static get isHorizontal(){return 3===i.statusBarOrientation||4===i.statusBarOrientation}static loading(){const e=$ui.create(i.blurBox({cornerRadius:15},[{type:\"spinner\",props:{loading:!0,style:0},layout:(e,t)=>{e.size.equalTo(t.prev),e.center.equalTo(t.super)}}]));return{start:()=>{$ui.controller.view.insertAtIndex(e,0),e.layout(((e,t)=>{e.center.equalTo(t.super);const r=Math.min(.6*Math.min(i.windowSize.width,i.windowSize.height),260);e.size.equalTo($size(r,r))})),e.moveToFront()},end:()=>{e.remove()}}}static defaultBackgroundColor(e){return i.scrollViewList.indexOf(e)>-1?i.scrollViewBackgroundColor:i.primaryViewBackgroundColor}static separatorLine(e={},t=i.align.bottom){return{type:\"canvas\",props:e,layout:(e,r)=>{void 0===r.prev?e.top.equalTo(r.super):t===i.align.bottom?e.top.equalTo(r.prev.bottom):e.top.equalTo(r.prev.top),e.height.equalTo(1/$device.info.screen.scale),e.left.right.inset(0)},events:{draw:(t,i)=>{i.strokeColor=e.bgcolor??$color(\"separatorColor\"),i.setLineWidth(1),i.moveToPoint(0,0),i.addLineToPoint(t.frame.width,0),i.strokePath()}}}}static blurBox(e={},t=[],i=$layout.fill){return{type:\"blur\",props:Object.assign({style:$blurStyle.thinMaterial},e),views:t,layout:i}}static getContentSize(e,t=\"A\",r=i.windowSize.width,s){const a={text:t,width:r,font:e};return void 0!==s&&(a.lineSpacing=s),$text.sizeThatFits(a)}static push({views:e,statusBarStyle:t=0,title:i=\"\",navButtons:r=[{title:\"\"}],bgcolor:s=e[0]?.props?.bgcolor??\"primarySurface\",disappeared:a}={}){$ui.push({props:{statusBarStyle:t,navButtons:r,title:i,bgcolor:\"string\"==typeof s?$color(s):s},events:{disappeared:()=>{void 0!==a&&a()}},views:[{type:\"view\",views:e,layout:(e,t)=>{e.top.equalTo(t.super.safeArea),e.bottom.equalTo(t.super),e.left.right.equalTo(t.super.safeArea)}}]})}}e.exports={UIKit:i}})),parcelRequire.register(\"7D8Kb\",(function(module,exports){var $fYz8N=parcelRequire(\"fYz8N\"),$58e2f5443faff7c0$require$Controller=$fYz8N.Controller,$8aDdQ=parcelRequire(\"8aDdQ\"),$58e2f5443faff7c0$require$FileStorageFileNotFoundError=$8aDdQ.FileStorageFileNotFoundError,$58e2f5443faff7c0$require$FileStorage=$8aDdQ.FileStorage,$cgaQ6=parcelRequire(\"cgaQ6\"),$58e2f5443faff7c0$require$Kernel=$cgaQ6.Kernel,$45Ip7=parcelRequire(\"45Ip7\"),$58e2f5443faff7c0$require$UIKit=$45Ip7.UIKit,$aXWmO=parcelRequire(\"aXWmO\"),$58e2f5443faff7c0$require$Sheet=$aXWmO.Sheet,$12xzj=parcelRequire(\"12xzj\"),$58e2f5443faff7c0$require$NavigationView=$12xzj.NavigationView,$dcStC=parcelRequire(\"dcStC\"),$58e2f5443faff7c0$require$NavigationBar=$dcStC.NavigationBar,$gMc1q=parcelRequire(\"gMc1q\"),$58e2f5443faff7c0$require$ViewController=$gMc1q.ViewController;class SettingLoadConfigError extends Error{constructor(){super(\"Call loadConfig() first.\"),this.name=\"SettingLoadConfigError\"}}class SettingReadonlyError extends Error{constructor(){super(\"Attempted to assign to readonly property.\"),this.name=\"SettingReadonlyError\"}}class Setting extends $58e2f5443faff7c0$require$Controller{name;setting={};userData;fileStorage;imagePath;viewController=new $58e2f5443faff7c0$require$ViewController;method={readme:()=>{const e=(()=>{const e=$device.info?.language?.startsWith(\"zh\")?\"README_CN.md\":\"README.md\";try{return __README__[e]??__README__[\"README.md\"]}catch{return $file.read(e)?.string??$file.read(\"README.md\")?.string}})();(new $58e2f5443faff7c0$require$Sheet).setView({type:\"markdown\",props:{content:e},layout:(e,t)=>{e.size.equalTo(t.super)}}).init().present()}};rowHeight=50;edgeOffset=10;iconSize=30;#i={};#r=!1;#s=!1;#a;constructor(e={}){super(),\"function\"==typeof e.set&&\"function\"==typeof e.get?(this.set=e.set,this.get=e.get,this.userData=e.userData):(this.fileStorage=e.fileStorage??new $58e2f5443faff7c0$require$FileStorage,this.dataFile=e.dataFile??\"setting.json\"),e.structure?this.setStructure(e.structure):this.setStructurePath(e.structurePath??\"setting.json\"),this.isUseJsboxNav=e.isUseJsboxNav??!1,this.imagePath=(e.name??\"default\")+\".image/\",this.setName(e.name??$text.uuid),this.loadL10n()}useJsboxNav(){return this.isUseJsboxNav=!0,this}#n(){if(!this.#s)throw new SettingLoadConfigError}loadConfig(){const e=[\"script\",\"info\"],t=this.userData??this.fileStorage.readAsJSON(this.dataFile,{});return this.setting=function i(r){const s={};for(let a of r)for(let r of a.items)if(\"child\"===r.type){const e=i(r.children);Object.assign(s,e)}else-1===e.indexOf(r.type)?s[r.key]=r.key in t?t[r.key]:r.value:s[r.key]=r.value;return s}(this.structure),this.#s=!0,this}hasSectionTitle(e){return this.#n(),!!e[0]?.title}loadL10n(){$58e2f5443faff7c0$require$Kernel.l10n(\"zh-Hans\",{OK:\"好\",DONE:\"完成\",CANCEL:\"取消\",CLEAR:\"清除\",BACK:\"返回\",ERROR:\"发生错误\",SUCCESS:\"成功\",LOADING:\"加载中\",INVALID_VALUE:\"非法参数\",CONFIRM_CHANGES:\"数据已变化,确认修改?\",SETTING:\"设置\",GENERAL:\"一般\",ADVANCED:\"高级\",TIPS:\"小贴士\",COLOR:\"颜色\",COPY:\"复制\",COPIED:\"复制成功\",JSBOX_ICON:\"JSBox 内置图标\",SF_SYMBOLS:\"SF Symbols\",IMAGE_BASE64:\"图片 / base64\",PREVIEW:\"预览\",SELECT_IMAGE:\"选择图片\",CLEAR_IMAGE:\"清除图片\",NO_IMAGE:\"无图片\",ABOUT:\"关于\",VERSION:\"Version\",AUTHOR:\"作者\",AT_BOTTOM:\"已经到底啦~\"},!1),$58e2f5443faff7c0$require$Kernel.l10n(\"en\",{OK:\"OK\",DONE:\"Done\",CANCEL:\"Cancel\",CLEAR:\"Clear\",BACK:\"Back\",ERROR:\"Error\",SUCCESS:\"Success\",LOADING:\"Loading\",INVALID_VALUE:\"Invalid value\",CONFIRM_CHANGES:\"The data has changed, confirm the modification?\",SETTING:\"Setting\",GENERAL:\"General\",ADVANCED:\"Advanced\",TIPS:\"Tips\",COLOR:\"Color\",COPY:\"Copy\",COPIED:\"Copide\",JSBOX_ICON:\"JSBox in app icon\",SF_SYMBOLS:\"SF Symbols\",IMAGE_BASE64:\"Image / base64\",PREVIEW:\"Preview\",SELECT_IMAGE:\"Select Image\",CLEAR_IMAGE:\"Clear Image\",NO_IMAGE:\"No Image\",ABOUT:\"About\",VERSION:\"Version\",AUTHOR:\"Author\",AT_BOTTOM:\"It's the end~\"},!1)}setUserData(e){this.userData=e}setStructure(e){return this.structure=e,this}setStructurePath(e){return this.structure||this.setStructure($58e2f5443faff7c0$require$FileStorage.readFromRootAsJSON(e)),this}setName(e){return this.name=e,this}setFooter(e){return this.#a=e,this}set footer(e){this.#a=e}get footer(){if(void 0===this.#a){let e=$58e2f5443faff7c0$require$FileStorage.readFromRootAsJSON(\"config.json\",{}).info??{};if(!e.version||!e.author)try{e=__INFO__}catch{}this.#a={},e.version&&e.author&&(this.#a={type:\"view\",props:{height:70},views:[{type:\"label\",props:{font:$font(14),text:`${$l10n(\"VERSION\")} ${e.version} ♥ ${e.author}`,textColor:$color({light:\"#C0C0C0\",dark:\"#545454\"}),align:$align.center},layout:e=>{e.left.right.inset(0),e.top.inset(10)}}]})}return this.#a}setReadonly(){return this.#r=!0,this}set(e,t){if(this.#r)throw new SettingReadonlyError;return this.#n(),this.setting[e]=t,this.fileStorage.write(this.dataFile,$data({string:JSON.stringify(this.setting)})),this.callEvent(\"onSet\",e,t),!0}get(e,t=null){return this.#n(),Object.prototype.hasOwnProperty.call(this.setting,e)?this.setting[e]:t}getColor(e){return\"string\"==typeof e?$color(e):$rgba(e.red,e.green,e.blue,e.alpha)}getImagePath(e,t=!1){let i=$text.MD5(e)+\".jpg\";return t&&(i=\"compress.\"+i),this.imagePath+i}getImage(e,t=!1){try{return this.fileStorage.readSync(this.getImagePath(e,t)).image}catch(e){if(e instanceof $58e2f5443faff7c0$require$FileStorageFileNotFoundError)return null;throw e}}getId(e){return`setting-${this.name}-${e}`}#o(e){$(e).bgcolor=$color(\"systemFill\")}#l(e,t=.3){0===t?$(e).bgcolor=$color(\"clear\"):$ui.animate({duration:t,animation:()=>{$(e).bgcolor=$color(\"clear\")}})}#c(e,t,i=!1,r=0){if(t=Object.assign(t,{touchesBegan:()=>{this.#o(e),this.#i[e]=$delay(1,(()=>this.#l(e,0)))},touchesMoved:()=>{this.#i[e]?.cancel(),this.#l(e,0)}}),i){const i=t.tapped;t.tapped=()=>{this.#o(e),setTimeout((()=>this.#l(e)),1e3*r),\"function\"==typeof i&&i()}}return t}createLineLabel(e,t){return t[1]||(t[1]=\"#00CC00\"),\"object\"!=typeof t[1]&&(t[1]=[t[1],t[1]]),\"object\"!=typeof t[0]&&(t[0]=[t[0],t[0]]),{type:\"view\",views:[{type:\"view\",props:{bgcolor:$color(t[1][0],t[1][1]),cornerRadius:5,smoothCorners:!0},views:[{type:\"image\",props:{tintColor:$color(\"white\"),image:$image(t[0][0],t[0][1])},layout:(e,t)=>{e.center.equalTo(t.super),e.size.equalTo(20)}}],layout:(e,t)=>{e.centerY.equalTo(t.super),e.size.equalTo(this.iconSize),e.left.inset(this.edgeOffset)}},{type:\"label\",props:{text:e,lines:1,textColor:this.textColor,align:$align.left},layout:(e,t)=>{e.centerY.equalTo(t.super),e.height.equalTo(t.super),e.left.equalTo(t.prev.right).offset(this.edgeOffset),e.width.greaterThanOrEqualTo(10)}}],layout:(e,t)=>{e.height.centerY.equalTo(t.super),e.left.inset(0)}}}createInfo(e,t,i){const r=Array.isArray(i),s=r?i[0]:i,a=r?i[1]:i;return{type:\"view\",props:{selectable:!0},views:[this.createLineLabel(t,e),{type:\"label\",props:{text:s,align:$align.right,textColor:$color(\"darkGray\")},layout:(e,t)=>{e.centerY.equalTo(t.prev),e.right.inset(this.edgeOffset),e.width.equalTo(180)}},{type:\"view\",events:{tapped:()=>{$ui.alert({title:t,message:a,actions:[{title:$l10n(\"COPY\"),handler:()=>{$clipboard.text=a,$ui.toast($l10n(\"COPIED\"))}},{title:$l10n(\"OK\")}]})}},layout:(e,t)=>{e.right.inset(0),e.size.equalTo(t.super)}}],layout:$layout.fill}}createSwitch(e,t,i){return{type:\"view\",props:{id:this.getId(e),selectable:!0},views:[this.createLineLabel(i,t),{type:\"switch\",props:{on:this.get(e),onColor:$color(\"#00CC00\")},events:{changed:t=>{try{this.set(e,t.on)}catch(e){throw t.on=!t.on,e}}},layout:(e,t)=>{e.centerY.equalTo(t.prev),e.right.inset(this.edgeOffset)}}],layout:$layout.fill}}createString(e,t,i){return{type:\"view\",props:{id:this.getId(e),selectable:!0},views:[this.createLineLabel(i,t),{type:\"button\",props:{symbol:\"square.and.pencil\",bgcolor:$color(\"clear\"),tintColor:$color(\"primaryText\")},events:{tapped:t=>{const i=$ui.popover({sourceView:t,sourceRect:t.bounds,directions:$popoverDirection.down,size:$size(320,150),views:[{type:\"text\",props:{id:`${this.name}-string-${e}`,align:$align.left,text:this.get(e)},layout:e=>{e.left.right.inset(10),e.top.inset(20),e.height.equalTo(90)}},{type:\"button\",props:{symbol:\"checkmark\",bgcolor:$color(\"clear\"),titleEdgeInsets:10,contentEdgeInsets:0},layout:e=>{e.right.inset(10),e.bottom.inset(25),e.size.equalTo(30)},events:{tapped:()=>{this.set(e,$(`${this.name}-string-${e}`).text),i.dismiss()}}}]})}},layout:(e,t)=>{e.centerY.equalTo(t.prev),e.right.inset(0),e.size.equalTo(50)}}],layout:$layout.fill}}createStepper(e,t,i,r,s){const a=this.getId(e),n=`${a}-label`;return{type:\"view\",props:{id:a,selectable:!0},views:[this.createLineLabel(i,t),{type:\"label\",props:{id:n,text:this.get(e),textColor:this.textColor,align:$align.left},layout:(e,t)=>{e.height.equalTo(t.super),e.right.inset(120)}},{type:\"stepper\",props:{min:r,max:s,value:this.get(e)},events:{changed:t=>{$(n).text=t.value;try{this.set(e,t.value)}catch(t){throw $(n).text=this.get(e),t}}},layout:(e,t)=>{e.centerY.equalTo(t.prev),e.right.inset(this.edgeOffset)}}],layout:$layout.fill}}createScript(key,icon,title,script){const id=this.getId(key),buttonId=`${id}-button`,actionStart=()=>{$(buttonId).alpha=0,$(`${buttonId}-spinner`).alpha=1,this.#o(id)},actionCancel=()=>{$(buttonId).alpha=1,$(`${buttonId}-spinner`).alpha=0,this.#l(id)},actionDone=(e=!0,t=$l10n(\"ERROR\"))=>{$(`${buttonId}-spinner`).alpha=0,this.#l(id);const i=$(buttonId);if(!e)return $ui.toast(t),void(i.alpha=1);i.symbol=\"checkmark\",$ui.animate({duration:.6,animation:()=>{i.alpha=1},completion:()=>{setTimeout((()=>{$ui.animate({duration:.4,animation:()=>{i.alpha=0},completion:()=>{i.symbol=\"chevron.right\",$ui.animate({duration:.4,animation:()=>{i.alpha=1},completion:()=>{i.alpha=1}})}})}),600)}})};return{type:\"view\",props:{id:id},views:[this.createLineLabel(title,icon),{type:\"view\",views:[{type:\"image\",props:{id:buttonId,symbol:\"chevron.right\",tintColor:$color(\"secondaryText\")},layout:(e,t)=>{e.centerY.equalTo(t.super),e.right.inset(0),e.size.equalTo(15)}},{type:\"spinner\",props:{id:`${buttonId}-spinner`,loading:!0,alpha:0},layout:(e,t)=>{e.size.equalTo(t.prev),e.left.top.equalTo(t.prev)}}],layout:(e,t)=>{e.right.inset(this.edgeOffset),e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],events:this.#c(id,{tapped:()=>{const animate={actionStart:actionStart,actionCancel:actionCancel,actionDone:actionDone,touchHighlightStart:()=>this.#o(id),touchHighlightEnd:()=>this.#l(id)};\"function\"==typeof script?script(animate):script.startsWith(\"this\")?eval(`(()=>{return ${script}(animate)})()`):eval(script)}}),layout:$layout.fill}}createTab(key,icon,title,items,values){\"string\"==typeof items?items=eval(`(()=>{return ${items}()})()`):\"function\"==typeof items&&(items=items()),\"string\"==typeof values?values=eval(`(()=>{return ${values}()})()`):\"function\"==typeof values&&(values=values());const id=this.getId(key),isCustomizeValues=items?.length>0&&values?.length===items?.length;return{type:\"view\",props:{id:id,selectable:!0},views:[this.createLineLabel(title,icon),{type:\"tab\",props:{items:items??[],index:isCustomizeValues?values.indexOf(this.get(key)):this.get(key),dynamicWidth:!0},layout:(e,t)=>{e.right.inset(this.edgeOffset),e.centerY.equalTo(t.prev)},events:{changed:e=>{isCustomizeValues?this.set(key,values[e.index]):this.set(key,e.index)}}}],layout:$layout.fill}}createMenu(key,icon,title,items,values){const id=this.getId(key),labelId=`${id}-label`,getItems=()=>{let res;return res=\"string\"==typeof items?eval(`(()=>{return ${items}()})()`):\"function\"==typeof items?items():items??[],res},getValues=()=>{let res;return res=\"string\"==typeof values?eval(`(()=>{return ${values}()})()`):\"function\"==typeof values?values():values,res},tmpItems=getItems(),tmpValues=getValues(),isCustomizeValues=tmpItems?.length>0&&tmpValues?.length===tmpItems?.length;return{type:\"view\",props:{id:id,selectable:!0},views:[this.createLineLabel(title,icon),{type:\"view\",views:[{type:\"label\",props:{text:isCustomizeValues?tmpItems[tmpValues.indexOf(this.get(key))]:tmpItems[this.get(key)],color:$color(\"secondaryText\"),id:labelId},layout:(e,t)=>{e.right.inset(0),e.height.equalTo(t.super)}}],layout:(e,t)=>{e.right.inset(this.edgeOffset),e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],events:{tapped:()=>{const e=getItems(),t=getValues();$ui.menu({items:e,handler:(e,i)=>{isCustomizeValues?this.set(key,t[i]):this.set(key,i),$(labelId).text=$l10n(e)}})}},layout:$layout.fill}}createColor(e,t,i){const r=this.getId(e),s=`${r}-color`;return{type:\"view\",props:{id:r,selectable:!0},views:[this.createLineLabel(i,t),{type:\"view\",views:[{type:\"view\",props:{id:s,bgcolor:this.getColor(this.get(e)),circular:!0,borderWidth:1,borderColor:$color(\"#e3e3e3\")},layout:(e,t)=>{e.centerY.equalTo(t.super),e.right.inset(this.edgeOffset),e.size.equalTo(20)}},{type:\"view\",events:{tapped:async()=>{const t=await $picker.color({color:this.getColor(this.get(e))});this.set(e,t.components),$(s).bgcolor=$rgba(t.components.red,t.components.green,t.components.blue,t.components.alpha)}},layout:(e,t)=>{e.right.inset(0),e.height.width.equalTo(t.super.height)}}],layout:(e,t)=>{e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],layout:$layout.fill}}createDate(e,t,i,r=2){const s=this.getId(e),a=e=>{let t=\"\";switch(\"number\"==typeof e&&(e=new Date(e)),r){case 0:t=e.toLocaleTimeString();break;case 1:t=e.toLocaleDateString();break;case 2:t=e.toLocaleString()}return t};return{type:\"view\",props:{id:s,selectable:!0},views:[this.createLineLabel(i,t),{type:\"view\",views:[{type:\"label\",props:{id:`${s}-label`,color:$color(\"secondaryText\"),text:this.get(e)?a(this.get(e)):\"None\"},layout:(e,t)=>{e.right.inset(0),e.height.equalTo(t.super)}}],events:{tapped:async()=>{const t=this.get(e),i=await $picker.date({props:{mode:r,date:t||Date.now()}});this.set(e,i.getTime()),$(`${s}-label`).text=a(i)}},layout:(e,t)=>{e.right.inset(this.edgeOffset),e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],layout:$layout.fill}}createNumber(e,t,i){return this.createInput(e,t,i,!1,$kbType.decimal,(t=>\"\"!==t&&/^[0-9]+.?[0-9]*$/.test(t)?this.set(e,Number(t)):($ui.toast($l10n(\"INVALID_VALUE\")),!1)))}createInput(e,t,i,r=!1,s=$kbType.default,a){void 0===a&&(a=t=>this.set(e,t));const n=this.getId(e),o=n+\"-input\";return{type:\"view\",props:{id:n,selectable:!0},views:[this.createLineLabel(i,t),{type:\"input\",props:{id:o,type:s,align:$align.right,bgcolor:$color(\"clear\"),textColor:$color(\"secondaryText\"),text:this.get(e),font:$font(16),secure:r,accessoryView:$58e2f5443faff7c0$require$UIKit.blurBox({height:44},[$58e2f5443faff7c0$require$UIKit.separatorLine({},$58e2f5443faff7c0$require$UIKit.align.top),{type:\"button\",props:{title:$l10n(\"DONE\"),bgcolor:$color(\"clear\"),titleColor:$color(\"primaryText\")},layout:(e,t)=>{e.right.inset(this.edgeOffset),e.centerY.equalTo(t.super)},events:{tapped:()=>{$(o).blur()}}},{type:\"button\",props:{title:$l10n(\"CANCEL\"),bgcolor:$color(\"clear\"),titleColor:$color(\"primaryText\")},layout:(e,t)=>{e.left.inset(this.edgeOffset),e.centerY.equalTo(t.super)},events:{tapped:()=>{const t=$(o),i=this.get(e,\"\");t.text!==i&&(t.text=i),t.blur()}}}])},layout:(t,i)=>{t.left.equalTo(i.prev.get(\"label\").right).offset(this.edgeOffset),t.right.inset(this.edgeOffset);const r=$58e2f5443faff7c0$require$UIKit.getContentSize($font(16),this.get(e)).width;t.width.greaterThanOrEqualTo(r+30),t.height.equalTo(i.super)},events:{didBeginEditing:e=>{e.secure=!1,$app.autoKeyboardEnabled||($app.autoKeyboardEnabled=!0)},returned:e=>{e.blur()},didEndEditing:async t=>{const i=this.get(e,\"\");a(t.text)||(t.text=i),r&&(t.secure=r)}}}],layout:$layout.fill}}createIcon(e,t,i,r=\"#000000\"){const s=this.getId(e),a=`${s}-image`;return{type:\"view\",props:{id:s,selectable:!0},views:[this.createLineLabel(i,t),{type:\"view\",views:[{type:\"image\",props:{cornerRadius:8,bgcolor:\"string\"==typeof r?$color(r):r,smoothCorners:!0},layout:(e,t)=>{e.right.inset(this.edgeOffset),e.centerY.equalTo(t.super),e.size.equalTo($size(30,30))}},{type:\"image\",props:{id:a,image:$image(this.get(e)),icon:$icon(this.get(e).slice(5,this.get(e).indexOf(\".\")),$color(\"#ffffff\")),tintColor:$color(\"#ffffff\")},layout:(e,t)=>{e.right.equalTo(t.prev).offset(-5),e.centerY.equalTo(t.super),e.size.equalTo($size(20,20))}}],events:{tapped:()=>{$ui.menu({items:[$l10n(\"JSBOX_ICON\"),$l10n(\"SF_SYMBOLS\"),$l10n(\"IMAGE_BASE64\")],handler:async(t,i)=>{if(0===i){const t=await $ui.selectIcon();this.set(e,t),$(a).icon=$icon(t.slice(5,t.indexOf(\".\")),$color(\"#ffffff\"))}else 1!==i&&2!==i||$input.text({text:\"\",placeholder:t,handler:t=>{\"\"!==t?(this.set(e,t),1===i?$(a).symbol=t:$(a).image=$image(t)):$ui.toast($l10n(\"INVALID_VALUE\"))}})}})}},layout:(e,t)=>{e.right.inset(0),e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],layout:$layout.fill}}createPush(key,icon,title,view,tapped){const id=this.getId(key);return{type:\"view\",layout:$layout.fill,props:{id:id,selectable:!0},views:[this.createLineLabel(title,icon),{type:\"image\",props:{symbol:\"chevron.right\",tintColor:$color(\"secondaryText\")},layout:(e,t)=>{e.centerY.equalTo(t.super),e.right.inset(this.edgeOffset),e.size.equalTo(15)}}],events:{tapped:()=>{const push=view=>{if(\"string\"==typeof view&&view.startsWith(\"this.method\")?view=eval(`(()=>{return ${view}()})()`):\"function\"==typeof view&&(view=view()),this.isUseJsboxNav)$58e2f5443faff7c0$require$UIKit.push({title:title,props:view.props??{},views:[view]});else{const e=new $58e2f5443faff7c0$require$NavigationView;e.setView(view).navigationBarTitle(title),e.navigationBarItems.addPopButton(),e.navigationBar.setLargeTitleDisplayMode($58e2f5443faff7c0$require$NavigationBar.largeTitleDisplayModeNever),this.hasSectionTitle(view)&&e.navigationBar.setContentViewHeightOffset(-10),this.viewController.push(e)}};\"function\"==typeof tapped?tapped(push):push(view)}}}}createChild(e,t,i,r){return this.createPush(e,t,i,void 0,(e=>{this.events?.onChildPush?this.callEvent(\"onChildPush\",this.getListView(r,{}),i):e(this.getListView(r,{}))}))}createImage(e,t,i){const r=this.getId(e),s=`${r}-image`,a=$image(\"questionmark.square.dashed\");return{type:\"view\",props:{id:r,selectable:!0},views:[this.createLineLabel(i,t),{type:\"view\",views:[{type:\"image\",props:{id:s,image:this.getImage(e,!0)??a},layout:(e,t)=>{e.right.inset(this.edgeOffset),e.centerY.equalTo(t.super),e.size.equalTo($size(30,30))}}],events:{tapped:()=>{this.#o(r),$ui.menu({items:[$l10n(\"PREVIEW\"),$l10n(\"SELECT_IMAGE\"),$l10n(\"CLEAR_IMAGE\")],handler:(t,i)=>{if(0===i){const t=this.getImage(e);t?$quicklook.open({image:t}):$ui.toast($l10n(\"NO_IMAGE\"))}else 1===i?$photo.pick({format:\"data\"}).then((t=>{if($ui.toast($l10n(\"LOADING\")),!t.status||!t.data)return void(\"canceled\"!==t?.error?.description&&$ui.toast($l10n(\"ERROR\")));const i=$58e2f5443faff7c0$require$Kernel.compressImage(t.data.image);this.fileStorage.write(this.getImagePath(e,!0),i.jpg(.8)),this.fileStorage.write(this.getImagePath(e),t.data),$(s).image=i,$ui.success($l10n(\"SUCCESS\"))})):2===i&&(this.fileStorage.delete(this.getImagePath(e,!0)),this.fileStorage.delete(this.getImagePath(e)),$(s).image=a,$ui.success($l10n(\"SUCCESS\")))},finished:()=>{this.#l(r)}})}},layout:(e,t)=>{e.right.inset(0),e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],layout:$layout.fill}}#h(e){const t=[];for(let i of e){const e=[];for(let t of i.items){const i=this.get(t.key);let r=null;switch(t.icon||(t.icon=[\"square.grid.2x2.fill\",\"#00CC00\"]),\"object\"==typeof t.items&&(t.items=t.items.map((e=>$l10n(e)))),t.title=$l10n(t.title),t.type){case\"switch\":r=this.createSwitch(t.key,t.icon,t.title);break;case\"stepper\":r=this.createStepper(t.key,t.icon,t.title,t.min??1,t.max??12);break;case\"string\":r=this.createString(t.key,t.icon,t.title);break;case\"info\":r=this.createInfo(t.icon,t.title,i);break;case\"script\":r=this.createScript(t.key,t.icon,t.title,i);break;case\"tab\":r=this.createTab(t.key,t.icon,t.title,t.items,t.values);break;case\"menu\":r=this.createMenu(t.key,t.icon,t.title,t.items,t.values);break;case\"color\":r=this.createColor(t.key,t.icon,t.title);break;case\"date\":r=this.createDate(t.key,t.icon,t.title,t.mode);break;case\"number\":r=this.createNumber(t.key,t.icon,t.title);break;case\"input\":r=this.createInput(t.key,t.icon,t.title,t.secure);break;case\"icon\":r=this.createIcon(t.key,t.icon,t.title,t.bgcolor);break;case\"push\":r=this.createPush(t.key,t.icon,t.title,t.view);break;case\"child\":r=this.createChild(t.key,t.icon,t.title,t.children);break;case\"image\":r=this.createImage(t.key,t.icon,t.title);break;default:continue}e.push(r)}t.push({title:$l10n(i.title??\"\"),rows:e})}return t}getListView(e,t=this.footer){return{type:\"list\",props:{id:this.name,style:2,separatorInset:$insets(0,this.iconSize+2*this.edgeOffset,0,this.edgeOffset),bgcolor:$58e2f5443faff7c0$require$UIKit.scrollViewBackgroundColor,footer:t,data:this.#h(e??this.structure)},layout:$layout.fill,events:{rowHeight:(e,t)=>(e.object(t)?.props?.info??{}).rowHeight??this.rowHeight}}}getNavigationView(){const e=new $58e2f5443faff7c0$require$NavigationView;return e.setView(this.getListView(this.structure)).navigationBarTitle($l10n(\"SETTING\")),this.hasSectionTitle(this.structure)&&e.navigationBar.setContentViewHeightOffset(-10),e}getPage(){return this.getNavigationView().getPage()}}module.exports={Setting:Setting}})),parcelRequire.register(\"fYz8N\",(function(e,t){e.exports={Controller:class{events={};setEvents(e){return Object.keys(e).forEach((t=>this.setEvent(t,e[t]))),this}setEvent(e,t){return this.events[e]=t,this}callEvent(e,...t){\"function\"==typeof this.events[e]&&this.events[e](...t)}}}})),parcelRequire.register(\"8aDdQ\",(function(e,t){class i extends Error{constructor(e){super(`Parameter [${e}] is required.`),this.name=\"FileStorageParameterError\"}}class r extends Error{constructor(e){super(`File not found: ${e}`),this.name=\"FileStorageFileNotFoundError\"}}class s{basePath;constructor({basePath:e=\"storage\"}={}){this.basePath=e,this.#d(this.basePath)}#d(e){$file.isDirectory(e)||$file.mkdir(e)}filePath(e=\"\",t=!0){e.startsWith(\"/\")&&(e=e.substring(1));let i=\"\";if(!(e=`${this.basePath}/${e}`).endsWith(\"/\")){const t=e.lastIndexOf(\"/\");e.lastIndexOf(\".\")>t&&(i=e.substring(t+1),e=e.substring(0,t+1))}return t&&this.#d(e),e+i}exists(e=\"\"){return e=this.filePath(e,!1),!!$file.exists(e)}write(e=\"\",t){return new Promise(((i,r)=>{try{const s=this.writeSync(e,t);s?i(s):r(s)}catch(e){r(e)}}))}writeSync(e=\"\",t){if(!t)throw new i(\"data\");return $file.write({data:t,path:this.filePath(e)})}read(e=\"\"){return new Promise(((t,i)=>{try{const r=this.readSync(e);r?t(r):i()}catch(e){i(e)}}))}readSync(e=\"\"){if(e=this.filePath(e),!$file.exists(e))throw new r(e);return $file.isDirectory(e)?$file.list(e):$file.read(e)}readAsJSON(e=\"\",t=null){try{const t=this.readSync(e)?.string;return JSON.parse(t)}catch(e){return t}}static readFromRoot(e=\"\"){return new Promise(((t,i)=>{try{const r=s.readFromRootSync(e);r?t(r):i()}catch(e){i(e)}}))}static readFromRootSync(e=\"\"){if(!e)throw new i(\"path\");if(!$file.exists(e))throw new r(e);return $file.isDirectory(e)?$file.list(e):$file.read(e)}static readFromRootAsJSON(e=\"\",t=null){try{const t=s.readFromRootSync(e)?.string;return JSON.parse(t)}catch(e){return t}}delete(e=\"\"){return $file.delete(this.filePath(e,!1))}copy(e,t){e=this.filePath(e),t=this.filePath(t),$file.copy({src:e,dst:t})}move(e,t){e=this.filePath(e),t=this.filePath(t),$file.move({src:e,dst:t})}}e.exports={FileStorageParameterError:i,FileStorageFileNotFoundError:r,FileStorage:s}})),parcelRequire.register(\"cgaQ6\",(function(e,t){var i=parcelRequire(\"czAIJ\").VERSION;class r{startTime=Date.now();isUseJsboxNav=!1;title=$addin?.current?.name;constructor(){$app.isDebugging&&this.debug()}static isTaio=$app.info.bundleID.includes(\"taio\");static l10n(e,t,i=!0){if(\"string\"==typeof t){const e={};t.split(\";\").forEach((t=>{if(\"\"!==(t=t.trim())){const i=t.split(\"=\");e[i[0].trim().slice(1,-1)]=i[1].trim().slice(1,-1)}})),t=e}const r=$app.strings;r[e]=i?Object.assign($app.strings[e],t):Object.assign(t,$app.strings[e]),$app.strings=r}static compressImage(e,t=921600){const i=$imagekit.info(e);if(i.height*i.width>t){const r=t/(i.height*i.width);e=$imagekit.scaleBy(e,r)}return e}static objectEqual(e,t){let i=Object.getOwnPropertyNames(e),s=Object.getOwnPropertyNames(t);if(i.length!==s.length)return!1;for(let s=0;se?i[e]:0,s=isNaN(Number(t))?t.charCodeAt():Number(t),n=r.length>e?r[e]:0,o=isNaN(Number(n))?n.charCodeAt():Number(n);if(so){a=1;break}}return a}static deleteConfirm(e,t){$ui.alert({title:$l10n(\"DELETE_CONFIRM_TITLE\"),message:e,actions:[{title:$l10n(\"DELETE\"),style:$alertActionType.destructive,handler:()=>{t()}},{title:$l10n(\"CANCEL\")}]})}static bytesToSize(e){if(0===e)return\"0 B\";const t=Math.floor(Math.log(e)/Math.log(1024));return(e/Math.pow(1024,t)).toPrecision(3)+\" \"+[\"B\",\"KB\",\"MB\",\"GB\",\"TB\",\"PB\",\"EB\",\"ZB\",\"YB\"][t]}debug(e,t){this.debugMode=!0,$app.idleTimerDisabled=!0,\"function\"==typeof e&&(this.debugPrint=e),\"function\"==typeof t&&(this.debugError=t),this.print(\"You are running EasyJsBox in debug mode.\")}print(e){this.debugMode&&(\"function\"==typeof this.debugPrint?this.debugPrint(e):console.log(e))}error(e){this.debugMode&&(\"function\"==typeof this.debugError?this.debugError(e):console.error(e))}useJsboxNav(){return this.isUseJsboxNav=!0,this}setTitle(e){this.isUseJsboxNav&&($ui.title=e),this.title=e}setNavButtons(e){this.navButtons=e}openInJsbox(){$app.openURL(`jsbox://run?name=${this.title}`)}UIRender(e){try{e.props=Object.assign({title:this.title,navBarHidden:!this.isUseJsboxNav,navButtons:this.navButtons??[],statusBarStyle:0},e.props),e.events||(e.events={});const t=e.events.layoutSubviews,{UIKit:i}=parcelRequire(\"45Ip7\");e.events.layoutSubviews=()=>{$app.notify({name:\"interfaceOrientationEvent\",object:{statusBarOrientation:i.statusBarOrientation,isHorizontal:i.isHorizontal}}),\"function\"==typeof t&&t()},$ui.render(e)}catch(e){this.print(e)}}async checkUpdate(){const e=await $http.get(\"https://raw.githubusercontent.com/ipuppet/EasyJsBox/dev/src/version.js\");if(e.error)throw e.error;const t=srcRes.data.match(/.*VERSION.?\\\"([0-9\\.]+)\\\"/)[1];if(this.print(`easy-jsbox latest version: ${t}`),r.versionCompare(t,i)>0){const e=await $http.get(\"https://raw.githubusercontent.com/ipuppet/EasyJsBox/dev/dist/easy-jsbox.js\");if(e.error)throw e.error;return e.data}return!1}}r.l10n(\"zh-Hans\",{DELETE_CONFIRM_TITLE:\"删除前确认\"},!1),r.l10n(\"en\",{DELETE_CONFIRM_TITLE:\"Delete Confirmation\"},!1),e.exports={Kernel:r}})),parcelRequire.register(\"czAIJ\",(function(e,t){e.exports={VERSION:\"1.3.3\"}})),parcelRequire.register(\"aXWmO\",(function(e,t){var i=parcelRequire(\"6Xrbz\").ValidationError,r=parcelRequire(\"liCrE\").View,s=parcelRequire(\"45Ip7\").UIKit,a=parcelRequire(\"12xzj\").NavigationView,n=parcelRequire(\"dcStC\").NavigationBar,o=parcelRequire(\"gAYmG\").BarButtonItem;class l extends Error{constructor(){super(\"Please call setView(view) first.\"),this.name=\"SheetAddNavBarError\"}}class c extends i{constructor(e,t){super(e,t),this.name=\"SheetViewTypeError\"}}class h extends r{#p=()=>{};#u=()=>{};style=h.UIModalPresentationStyle.PageSheet;#g=!1;static UIModalPresentationStyle={Automatic:-2,FullScreen:0,PageSheet:1,FormSheet:2,CurrentContext:3,Custom:4,OverFullScreen:5,OverCurrentContext:6,Popover:7,BlurOverFullScreen:8};navigationView;init(){const{width:e,height:t}=$device.info.screen,i=$objc(\"UIView\").invoke(\"initWithFrame\",$rect(0,0,e,t)),r=$objc(\"UIViewController\").invoke(\"alloc.init\"),a=r.$view();return a.$setBackgroundColor(s.primaryViewBackgroundColor),a.$addSubview(i),r.$setModalPresentationStyle(this.style),r.$setModalInPresentation(this.#g),this.#p=()=>{a.jsValue().add(this.navigationView?.getPage().definition??this.view),$ui.vc.ocValue().invoke(\"presentViewController:animated:completion:\",r,!0,void 0)},this.#u=()=>r.invoke(\"dismissViewControllerAnimated:completion:\",!0,void 0),this}preventDismiss(){return this.#g=!0,this}setStyle(e){return this.style=e,this}setView(e={}){if(\"object\"!=typeof e)throw new c(\"view\",\"object\");return this.view=e,this}addNavBar({title:e=\"\",popButton:t={title:$l10n(\"DONE\")},rightButtons:i=[]}={}){if(void 0===this.view)throw new l;this.navigationView=new a;const r=new o;r.setEvents(Object.assign({tapped:()=>{this.dismiss(),\"function\"==typeof t.tapped&&t.tapped()}},t.events)).setAlign(s.align.left).setSymbol(t.symbol).setTitle(t.title).setColor(t.color).setMenu(t.menu);const c=r.definition.views[0];return c.layout=(e,t)=>{e.left.equalTo(t.super.safeArea).offset(15),e.centerY.equalTo(t.super.safeArea)},this.navigationView.navigationBar.setLargeTitleDisplayMode(n.largeTitleDisplayModeNever).pageSheetMode(),this.navigationView.navigationBarItems.addPopButton(\"\",c).setRightButtons(i),this.navigationView.setView(this.view).navigationBarTitle(e),this.view.props?.bgcolor&&this.navigationView?.getPage().setProp(\"bgcolor\",this.view.props?.bgcolor),this}present(){this.#p()}dismiss(){this.#u()}}e.exports={Sheet:h}})),parcelRequire.register(\"6Xrbz\",(function(e,t){class i extends Error{constructor(e,t){super(`The type of the parameter '${e}' must be '${t}'`),this.name=\"ValidationError\"}}e.exports={ValidationError:i}})),parcelRequire.register(\"liCrE\",(function(e,t){var i=parcelRequire(\"45Ip7\").UIKit;class r{id=$text.uuid;type;props;views;events;layout;#$=void 0;#f=null;constructor({type:e=\"view\",props:t={},views:i=[],events:r={},layout:s=$layout.fill}={}){this.type=e,this.props=t,this.views=i,this.events=r,this.layout=s,this.props.id?this.id=this.props.id:this.props.id=this.id}static create(e){return new this(e)}static createFromViews(e){return new this({views:e})}get scrollableView(){return this.scrollable?this.#f:null}set scrollableView(e){this.#f=e}get scrollable(){if(void 0===this.#$)if(this.#$=!1,i.scrollViewList.indexOf(this.type)>-1)this.scrollableView=this,this.#$=!0;else if(this.views.length>0){const e=t=>{if(!this.#$&&t?.length>0)for(let s=0;s-1)return typeof t[s]!==r&&(t[s]=r.create(t[s])),this.scrollableView=t[s],void(this.#$=!0);e(t[s].views)}};e(this.views)}return this.#$}set scrollable(e){throw new Error(\"[scrollable] is readonly prop.\")}setProps(e){return Object.keys(e).forEach((t=>this.setProp(t,e[t]))),this}setProp(e,t){return\"id\"===e&&(this.id=t),this.props[e]=t,this}setViews(e){return this.views=e,this.#$=void 0,this}setEvents(e){return Object.keys(e).forEach((t=>this.setEvent(t,e[t]))),this}setEvent(e,t){return this.events[e]=t,this}eventMiddleware(e,t){const i=this.events[e];return this.events[e]=(...e)=>{\"function\"==typeof i&&t(i,...e)},this}assignEvent(e,t){const i=this.events[e];return this.events[e]=(...e)=>{\"function\"==typeof i&&i(...e),t(...e)},this}setLayout(e){return this.layout=e,this}getView(){return this}get definition(){return this.getView()}}e.exports={View:r,PageView:class extends r{constructor(e={}){super(e),this.activeStatus=!0}show(){$(this.props.id).hidden=!1,this.activeStatus=!0}hide(){$(this.props.id).hidden=!0,this.activeStatus=!1}setHorizontalSafeArea(e){return this.horizontalSafeArea=e,this}#y(e,t){e.top.bottom.equalTo(t.super),this.horizontalSafeArea?e.left.right.equalTo(t.super.safeArea):e.left.right.equalTo(t.super)}getView(){return this.layout=this.#y,this.props.clipsToBounds=!0,this.props.hidden=!this.activeStatus,super.getView()}}}})),parcelRequire.register(\"12xzj\",(function(e,t){var i=parcelRequire(\"fYz8N\").Controller,r=parcelRequire(\"liCrE\"),s=r.View,a=r.PageView,n=parcelRequire(\"6Xrbz\").ValidationError,o=parcelRequire(\"cgaQ6\").Kernel,l=parcelRequire(\"45Ip7\").UIKit,c=parcelRequire(\"dcStC\"),h=c.NavigationBar,d=c.NavigationBarController,p=parcelRequire(\"gAYmG\").NavigationBarItems;class u extends n{constructor(e,t){super(e,t),this.name=\"NavigationViewTypeError\"}}e.exports={NavigationView:class extends i{page;navigationController=new d;navigationBar=new h;navigationBarItems=new p;constructor(){super(),this.navigationBar.navigationBarItems=this.navigationBarItems,this.navigationController.navigationBar=this.navigationBar}navigationBarTitle(e){return this.navigationBar.setTitle(e),this}setView(e){if(\"object\"!=typeof e)throw new u(\"view\",\"object\");return this.view=s.create(e),this}#b(){if(!(this.view instanceof s))throw new u(\"view\",\"View\");const e=this.view.scrollableView,t=$app.isDebugging||o.isTaio?0:l.topSafeAreaInsets,i=this.navigationBar.largeTitleDisplayMode===h.largeTitleDisplayModeNever?this.navigationBar.navigationBarNormalHeight:this.navigationBar.navigationBarLargeTitleHeight;let r=this.navigationBar.contentViewHeightOffset+i;if(this.navigationBarItems.titleView&&(r+=this.navigationBarItems.titleView.topOffset,r+=this.navigationBarItems.titleView.height,r+=this.navigationBarItems.titleView.bottomOffset),!this.view.scrollable||!1===e.props.associateWithNavigationBar)return void(this.view.layout=(e,i)=>{e.left.right.equalTo(i.super.safeArea),e.bottom.equalTo(i.super);let s=r-this.navigationBar.contentViewHeightOffset;l.isHorizontal&&!l.isLargeScreen||!this.navigationBar.topSafeArea||(s+=t),e.top.equalTo(s)});e.props.stickyHeader&&(r-=i,r+=this.navigationBar.largeTitleFontHeight),e.props.header?e.props.header={type:\"view\",props:{height:r+(e.props.header?.props?.height??0)},views:[{type:\"view\",props:{clipsToBounds:!0},views:[e.props.header],layout:(e,t)=>{e.top.equalTo(r),e.bottom.width.equalTo(t.super)}}]}:e.props.header={props:{height:r}},e.props.footer=Object.assign({props:{}},e.props.footer??{}),e.props.footer.props.height=(this.navigationBarItems.fixedFooterView?.height??0)+(e.props.footer.props?.height??0);const a=this.navigationBarItems.isPinTitleView?this.navigationBarItems.titleView.height+this.navigationBarItems.titleView.bottomOffset+this.navigationBar.contentViewHeightOffset:0;if(e.props.indicatorInsets){const t=e.props.indicatorInsets;e.props.indicatorInsets=$insets(t.top+this.navigationBar.navigationBarNormalHeight+a,t.left,t.bottom+(this.navigationBarItems.fixedFooterView?.height??0),t.right)}else e.props.indicatorInsets=$insets(this.navigationBar.navigationBarNormalHeight+a,0,this.navigationBarItems.fixedFooterView?.height??0,0);e.layout=(t,i)=>{e.props.stickyHeader?t.top.equalTo(i.super.safeArea).offset(this.navigationBar.navigationBarNormalHeight):t.top.equalTo(i.super),t.left.right.equalTo(i.super.safeArea),t.bottom.equalTo(i.super)},e.assignEvent(\"didScroll\",(i=>{let r=i.contentOffset.y;l.isHorizontal&&!l.isLargeScreen||!this.navigationBar.topSafeArea||e.props.stickyHeader||(r+=t),this.navigationController.didScroll(r)})).assignEvent(\"didEndDragging\",((i,r)=>{let s=i.contentOffset.y,a=0;l.isHorizontal&&!l.isLargeScreen||!this.navigationBar.topSafeArea||e.props.stickyHeader||(s+=t,a=t),this.navigationController.didEndDragging(s,r,((...e)=>i.scrollToOffset(...e)),a)})).assignEvent(\"didEndDecelerating\",((...t)=>{t[0].tracking||e.events?.didEndDragging(...t)}))}#m(){if(this.navigationBar.prefersLargeTitles){this.#b();let e={};if(this.navigationBarItems.titleView){const t=this.navigationBar.largeTitleDisplayMode===h.largeTitleDisplayModeNever?1:0;e=s.create({views:[this.navigationBar.backgroundColor?{type:\"view\",props:{alpha:t,bgcolor:this.navigationBar.backgroundColor,id:this.navigationBar.id+\"-title-view-background\"},layout:$layout.fill}:l.blurBox({alpha:t,id:this.navigationBar.id+\"-title-view-background\"}),l.separatorLine({id:this.navigationBar.id+\"-title-view-underline\",alpha:t}),this.navigationBarItems.titleView.definition],layout:(e,t)=>{e.top.equalTo(t.prev.bottom),e.width.equalTo(t.super),e.height.equalTo(this.navigationBarItems.titleView.topOffset+this.navigationBarItems.titleView.height+this.navigationBarItems.titleView.bottomOffset)}})}this.page=a.createFromViews([this.view,this.navigationBar.getLargeTitleView(),e,this.navigationBar.getNavigationBarView(),this.navigationBarItems.fixedFooterView?.definition??{}])}else this.page=a.createFromViews([this.view]);this.view.props?.bgcolor?this.page.setProp(\"bgcolor\",this.view.props.bgcolor):this.page.setProp(\"bgcolor\",l.defaultBackgroundColor(this.view.type))}getPage(){return this.page||this.#m(),this.page}}}})),parcelRequire.register(\"dcStC\",(function(e,t){var i=parcelRequire(\"liCrE\").View,r=parcelRequire(\"fYz8N\").Controller,s=parcelRequire(\"45Ip7\").UIKit;parcelRequire(\"gAYmG\").BarButtonItem;class a extends i{static largeTitleDisplayModeAutomatic=0;static largeTitleDisplayModeAlways=1;static largeTitleDisplayModeNever=2;static pageSheetNavigationBarHeight=56;navigationBarItems;title=\"\";prefersLargeTitles=!0;largeTitleDisplayMode=a.largeTitleDisplayModeAutomatic;largeTitleFontSize=34;largeTitleFontFamily=\"bold\";largeTitleFontHeight=$text.sizeThatFits({text:\"A\",width:100,font:$font(this.largeTitleFontFamily,this.largeTitleFontSize)}).height;navigationBarTitleFontSize=17;topSafeArea=!0;contentViewHeightOffset=10;navigationBarNormalHeight=s.NavigationBarNormalHeight;navigationBarLargeTitleHeight=s.NavigationBarLargeTitleHeight;pageSheetMode(){return this.navigationBarLargeTitleHeight-=this.navigationBarNormalHeight,this.navigationBarNormalHeight=a.pageSheetNavigationBarHeight,this.navigationBarLargeTitleHeight+=this.navigationBarNormalHeight,this.topSafeArea=!1,this}setTopSafeArea(){return this.topSafeArea=!0,this}removeTopSafeArea(){return this.topSafeArea=!1,this}setLargeTitleDisplayMode(e){return this.largeTitleDisplayMode=e,this}setBackgroundColor(e){return this.backgroundColor=e,this}setTitle(e){return this.title=e,this}setPrefersLargeTitles(e){return this.prefersLargeTitles=e,this}setContentViewHeightOffset(e){return this.contentViewHeightOffset=e,this}getLargeTitleView(){return this.prefersLargeTitles&&this.largeTitleDisplayMode!==a.largeTitleDisplayModeNever?{type:\"label\",props:{id:this.id+\"-large-title\",text:this.title,textColor:s.textColor,align:$align.left,font:$font(this.largeTitleFontFamily,this.largeTitleFontSize),line:1},layout:(e,t)=>{e.left.equalTo(t.super.safeArea).offset(15),e.height.equalTo(this.largeTitleFontHeight),e.top.equalTo(t.super.safeAreaTop).offset(this.navigationBarNormalHeight)}}:{props:{id:this.id+\"-large-title\"},layout:(e,t)=>{e.left.top.right.inset(0),e.bottom.equalTo(t.super.safeAreaTop).offset(this.navigationBarNormalHeight)}}}getNavigationBarView(){const e=(e,t)=>{let i=0;const r=[];return e.forEach((e=>{i+=e.width,r.push(e.definition)})),i+=e[0]?.edges??0,e.length>0?{type:\"view\",views:r,layout:(e,r)=>{e.top.equalTo(r.super.safeAreaTop),e.bottom.equalTo(r.super.safeAreaTop).offset(this.navigationBarNormalHeight),t===s.align.left?e.left.equalTo(r.super.safeArea):e.right.equalTo(r.super.safeArea),e.width.equalTo(i)}}:{}},t=e(this.navigationBarItems.rightButtons,s.align.right),i=this.navigationBarItems.popButtonView??e(this.navigationBarItems.leftButtons,s.align.left),r=this.prefersLargeTitles,n=!this.prefersLargeTitles||this.largeTitleDisplayMode===a.largeTitleDisplayModeNever;return{type:\"view\",props:{id:this.id+\"-navigation\",bgcolor:$color(\"clear\")},layout:(e,t)=>{e.left.top.right.inset(0),e.bottom.equalTo(t.super.safeAreaTop).offset(this.navigationBarNormalHeight)},views:[this.backgroundColor?{type:\"view\",props:{hidden:r,bgcolor:this.backgroundColor,id:this.id+\"-background\"},layout:$layout.fill}:s.blurBox({hidden:r,id:this.id+\"-background\"}),s.separatorLine({id:this.id+\"-underline\",alpha:r?0:1}),{type:\"view\",props:{alpha:0,bgcolor:$color(\"clear\"),id:this.id+\"-large-title-mask\"},events:{ready:e=>{e.bgcolor=$(this.id+\"-large-title\")?.prev.bgcolor}},layout:$layout.fill},{type:\"label\",props:{id:this.id+\"-small-title\",alpha:n?1:0,text:this.title,font:$font(this.largeTitleFontFamily,this.navigationBarTitleFontSize),align:$align.center,bgcolor:$color(\"clear\"),textColor:s.textColor},layout:(e,t)=>{e.left.right.inset(0),e.height.equalTo(20),e.centerY.equalTo(t.super.safeArea)}}].concat(t,i)}}}class n extends r{static largeTitleViewSmallMode=0;static largeTitleViewLargeMode=1;navigationBar;updateSelector(){this.selector={navigation:$(this.navigationBar.id+\"-navigation\"),largeTitleView:$(this.navigationBar.id+\"-large-title\"),smallTitleView:$(this.navigationBar.id+\"-small-title\"),underlineView:this.navigationBar.navigationBarItems.isPinTitleView?$(this.navigationBar.id+\"-title-view-underline\"):$(this.navigationBar.id+\"-underline\"),largeTitleMaskView:$(this.navigationBar.id+\"-large-title-mask\"),backgroundView:$(this.navigationBar.id+\"-background\"),titleViewBackgroundView:$(this.navigationBar.id+\"-title-view-background\")}}toNormal(e=!0){this.updateSelector(),this.selector.backgroundView.hidden=!1,$ui.animate({duration:.2,animation:()=>{this.selector.underlineView.alpha=1,this.selector.smallTitleView.alpha=1,this.selector.largeTitleView.alpha=0}}),e&&this.navigationBar.navigationBarItems&&(this.navigationBar.largeTitleDisplayMode=a.largeTitleDisplayModeNever)}toLargeTitle(e=!0){this.updateSelector(),this.selector.backgroundView.hidden=!0,$ui.animate({duration:.2,animation:()=>{this.selector.underlineView.alpha=0,this.selector.smallTitleView.alpha=0,this.selector.largeTitleView.alpha=1}}),e&&this.navigationBar.navigationBarItems&&(this.navigationBar.largeTitleDisplayMode=a.largeTitleDisplayModeAlways)}#v(e){const t=e===n.largeTitleViewSmallMode;this.selector.largeTitleView.alpha=t?0:1,$ui.animate({duration:.2,animation:()=>{this.selector.smallTitleView.alpha=t?1:0}})}#w(e){if(this.selector.largeTitleView.updateLayout(((t,i)=>{this.navigationBar.navigationBarNormalHeight-e>0?t.top.equalTo(i.super.safeAreaTop).offset(this.navigationBar.navigationBarNormalHeight-e):t.top.equalTo(i.super.safeAreaTop).offset(0)})),e>0)e>=this.navigationBar.navigationBarNormalHeight?this.#v(n.largeTitleViewSmallMode):this.#v(n.largeTitleViewLargeMode);else{this.#v(n.largeTitleViewLargeMode);let t=this.navigationBar.largeTitleFontSize-.04*e;t>40&&(t=40),this.selector.largeTitleView.font=$font(this.navigationBar.largeTitleFontFamily,t)}}#T(e){const t=this.navigationBar.largeTitleDisplayMode===a.largeTitleDisplayModeNever?5:this.navigationBar.navigationBarNormalHeight,i=void 0!==this.selector.titleViewBackgroundView;if(e>t){this.selector.backgroundView.hidden=!1;const r=()=>{i&&this.navigationBar.navigationBarItems.isPinTitleView&&(this.selector.titleViewBackgroundView.alpha=1),this.selector.largeTitleMaskView.alpha=0,this.selector.underlineView.alpha=1};(e-t)/3>=1?r():$ui.animate({duration:.2,animation:()=>{r()}})}else this.selector.largeTitleMaskView.alpha=e>0?1:0,this.selector.underlineView.alpha=0,i&&(this.selector.titleViewBackgroundView.alpha=0),this.selector.backgroundView.hidden=!0}didScroll(e){if(!this.navigationBar.prefersLargeTitles)return;const t=this.navigationBar.largeTitleDisplayMode;t!==a.largeTitleDisplayModeAlways&&(this.updateSelector(),t===a.largeTitleDisplayModeAutomatic?(!this.navigationBar.navigationBarItems?.isPinTitleView&&(this.navigationBar.navigationBarItems?.titleView?.controller.didScroll(e),e>0)&&(e-=this.navigationBar.navigationBarItems?.titleView?.height??0)<0&&(e=0),this.#w(e),this.#T(e)):t===a.largeTitleDisplayModeNever&&this.#T(e))}didEndDragging(e,t,i,r){if(!this.navigationBar.prefersLargeTitles)return;const s=this.navigationBar.largeTitleDisplayMode;if(s!==a.largeTitleDisplayModeAlways&&(this.updateSelector(),s===a.largeTitleDisplayModeAutomatic)){let s=0;this.navigationBar.navigationBarItems?.isPinTitleView||(this.navigationBar.navigationBarItems?.titleView?.controller.didEndDragging(e,t,i,r),s=this.navigationBar.navigationBarItems?.titleView?.height??0,e-=s),e>=0&&e<=this.navigationBar.largeTitleFontHeight&&i($point(0,e>=this.navigationBar.largeTitleFontHeight/2?this.navigationBar.navigationBarNormalHeight+s-r:s-r))}}}e.exports={NavigationBar:a,NavigationBarController:n}})),parcelRequire.register(\"gAYmG\",(function(e,t){var i=parcelRequire(\"liCrE\").View,r=parcelRequire(\"45Ip7\").UIKit;class s extends i{static#E;edges=15;iconSize=$size(23,23);fontSize=16;color=r.textColor;title;symbol;align=r.align.right;get width(){if(this.title){const e=$text.sizeThatFits({text:this.title,width:r.windowSize.width,font:$font(this.fontSize)});return Math.ceil(e.width)+this.edges}return this.iconSize.width+this.edges}static get style(){return void 0===this.#E&&(this.#E=new s),this.#E}setEdges(e){return this.edges=e,this}setFontSize(e){return this.fontSize=e,this}setColor(e=r.textColor){return this.color=e,this}setTitle(e){return this.title=e,this}setSymbol(e){return this.symbol=e,this}setMenu(e){return this.menu=e,this}setAlign(e){return this.align=e,this}setLoading(e){e?($(this.id).hidden=!0,$(\"spinner-\"+this.id).hidden=!1):($(this.id).hidden=!1,$(\"spinner-\"+this.id).hidden=!0)}#A(){const e=$(`icon-button-${this.id}`),t=$(`icon-checkmark-${this.id}`);e.alpha=0,$(this.id).hidden=!1,$(\"spinner-\"+this.id).hidden=!0,$ui.animate({duration:.6,animation:()=>{t.alpha=1},completion:()=>{$delay(.3,(()=>$ui.animate({duration:.6,animation:()=>{t.alpha=0},completion:()=>{$ui.animate({duration:.4,animation:()=>{e.alpha=1},completion:()=>{e.alpha=1}})}})))}})}getView(){const e=this.events.tapped;return this.events.tapped=t=>{e&&e({start:()=>this.setLoading(!0),done:()=>this.#A(),cancel:()=>this.setLoading(!1)},t)},{type:\"view\",props:{info:{align:this.align}},views:[{type:\"button\",props:Object.assign({id:this.id,bgcolor:$color(\"clear\"),font:$font(this.fontSize),titleColor:this.color,contentEdgeInsets:$insets(0,0,0,0),titleEdgeInsets:$insets(0,0,0,0),imageEdgeInsets:$insets(0,0,0,0)},this.menu?{menu:this.menu}:{},this.title?{title:this.title}:{},this.props),views:[{type:\"image\",props:Object.assign({id:`icon-button-${this.id}`,hidden:void 0===this.symbol,tintColor:this.color},void 0===this.symbol?{}:\"string\"==typeof this.symbol?{symbol:this.symbol}:{data:this.symbol.png}),layout:(e,t)=>{e.center.equalTo(t.super),e.size.equalTo(this.iconSize)}},{type:\"image\",props:{id:`icon-checkmark-${this.id}`,alpha:0,tintColor:this.color,symbol:\"checkmark\"},layout:(e,t)=>{e.center.equalTo(t.super),e.size.equalTo(this.iconSize)}}],events:this.events,layout:$layout.fill},{type:\"spinner\",props:{id:\"spinner-\"+this.id,loading:!0,hidden:!0},layout:$layout.fill}],layout:(e,t)=>{if(e.size.equalTo($size(this.width,r.NavigationBarNormalHeight)),e.centerY.equalTo(t.super),t.prev&&t.prev?.info?.align===this.align)this.align===r.align.right?e.right.equalTo(t.prev.left):e.left.equalTo(t.prev.right);else{const t=this.edges/2;this.align===r.align.right?e.right.inset(t):e.left.inset(t)}}}}static creat({id:e,symbol:t,title:i,tapped:a,menu:n,events:o,color:l,align:c=r.align.right}={}){const h=new s;return h.setEvents(Object.assign({tapped:a},o)).setAlign(c).setSymbol(t).setTitle(i).setColor(l).setMenu(n),e&&h.setProp(\"id\",e),h}}e.exports={BarTitleView:class extends i{controller={};setController(e){return this.controller=e,this}},BarButtonItem:s,NavigationBarItems:class{rightButtons=[];leftButtons=[];#S={};hasbutton=!1;isPinTitleView=!1;setTitleView(e){return this.titleView=e,this}pinTitleView(){return this.isPinTitleView=!0,this}setFixedFooterView(e){return this.fixedFooterView=e,this}setRightButtons(e){return e.forEach((e=>this.addRightButton(e))),this.hasbutton||(this.hasbutton=!0),this}setLeftButtons(e){return e.forEach((e=>this.addLeftButton(e))),this.hasbutton||(this.hasbutton=!0),this}addRightButton({id:e,symbol:t,title:i,tapped:a,menu:n,events:o,color:l}={}){const c=s.creat({id:e,symbol:t,title:i,tapped:a,menu:n,events:o,color:l,align:r.align.right});return this.rightButtons.push(c),this.#S[e??c.id]=c,this.hasbutton||(this.hasbutton=!0),this}addLeftButton({id:e,symbol:t,title:i,tapped:a,menu:n,events:o,color:l}={}){const c=s.creat({id:e,symbol:t,title:i,tapped:a,menu:n,events:o,color:l,align:r.align.left});return this.leftButtons.push(c),this.#S[e??c.id]=c,this.hasbutton||(this.hasbutton=!0),this}getButton(e){return this.#S[e]}addPopButton(e,t,i){return e||(e=$l10n(\"BACK\")),this.popButtonView=t??{type:\"button\",props:{bgcolor:$color(\"clear\"),symbol:\"chevron.left\",tintColor:r.linkColor,title:` ${e}`,titleColor:r.linkColor,font:$font(\"bold\",16)},layout:(e,t)=>{e.left.equalTo(t.super.safeArea).offset(s.style.edges),e.centerY.equalTo(t.super.safeArea)},events:{tapped:()=>{$ui.pop(),\"function\"==typeof i&&i()}}},this}removePopButton(){return this.popButtonView=void 0,this}}}})),parcelRequire.register(\"gMc1q\",(function(e,t){var i=parcelRequire(\"fYz8N\").Controller;e.exports={ViewController:class extends i{#C=[];#I(e){e.callEvent(\"onPop\"),this.callEvent(\"onPop\",e),this.#C.pop()}push(e){const t=this.#C[this.#C.length-1];e.navigationBarItems.addPopButton(t?.navigationBar.title),this.#C.push(e),$ui.push({props:{statusBarStyle:0,navBarHidden:!0},events:{dealloc:()=>{this.#I(e)}},views:[e.getPage().definition],layout:$layout.fill})}}}})),String.prototype.trim=function(e,t){return e?\"l\"===t?this.replace(new RegExp(\"^\\\\\"+e+\"+\",\"g\"),\"\"):\"r\"===t?this.replace(new RegExp(\"\\\\\"+e+\"+$\",\"g\"),\"\"):this.replace(new RegExp(\"^\\\\\"+e+\"+|\\\\\"+e+\"+$\",\"g\"),\"\"):this.replace(/^\\s+|\\s+$/g,\"\")};var $czAIJ=parcelRequire(\"czAIJ\"),$bb0fea222fc5aea5$require$VERSION=$czAIJ.VERSION,$fYz8N=parcelRequire(\"fYz8N\"),$bb0fea222fc5aea5$require$Controller=$fYz8N.Controller,$272f042430a952c6$exports={},$45Ip7=parcelRequire(\"45Ip7\"),$272f042430a952c6$require$UIKit=$45Ip7.UIKit,$aXWmO=parcelRequire(\"aXWmO\"),$272f042430a952c6$require$Sheet=$aXWmO.Sheet,$cgaQ6=parcelRequire(\"cgaQ6\"),$272f042430a952c6$require$Kernel=$cgaQ6.Kernel,$12xzj=parcelRequire(\"12xzj\"),$272f042430a952c6$require$NavigationView=$12xzj.NavigationView,$dcStC=parcelRequire(\"dcStC\"),$272f042430a952c6$require$NavigationBar=$dcStC.NavigationBar;class $272f042430a952c6$var$FileManager{viewController;constructor(){this.listId=\"file-manager-list\",this.edges=10,this.iconSize=25,this.loadL10n()}loadL10n(){$272f042430a952c6$require$Kernel.l10n(\"zh-Hans\",{FILE_MANAGER_DELETE_CONFIRM_MSG:\"确认要删除吗\",DELETE:\"删除\",CANCEL:\"取消\",CLOSE:\"关闭\",SHARE:\"分享\",SAVE:\"保存\",SAVE_SUCCESS:\"保存成功\"},!1),$272f042430a952c6$require$Kernel.l10n(\"en\",{FILE_MANAGER_DELETE_CONFIRM_MSG:\"Are you sure you want to delete\",DELETE:\"Delete\",CANCEL:\"Cancel\",CLOSE:\"Close\",SHARE:\"Share\",SAVE:\"Save\",SAVE_SUCCESS:\"Save Success\"},!1)}setViewController(e){this.viewController=e}get menu(){return{items:[{title:$l10n(\"SHARE\"),symbol:\"square.and.arrow.up\",handler:async(e,t)=>{const i=e.object(t).info.info;$share.sheet([$file.absolutePath(i.path)])}}]}}delete(e){$file.delete(e.path)}edit(e){const t=$file.read(e.path);if(t.image)$quicklook.open({image:t.image});else{const i=new $272f042430a952c6$require$Sheet,r=$text.uuid;i.setView({type:\"code\",layout:$layout.fill,props:{id:r,lineNumbers:!0,theme:$device.isDarkMode?\"atom-one-dark\":\"atom-one-light\",text:t.string,insets:$insets(15,15,15,15)}}).addNavBar({title:e.file,popButton:{title:$l10n(\"CLOSE\")},rightButtons:[{title:$l10n(\"SAVE\"),tapped:()=>{$file.write({data:$data({string:$(r).text}),path:e.path}),$ui.success($l10n(\"SAVE_SUCCESS\"))}}]}),i.init().present()}}getFiles(e=\"\"){return $file.list(e).map((t=>{const i=e+\"/\"+t,r=$file.isDirectory(i);return{info:{info:{path:i,file:t,isDirectory:r}},icon:{symbol:r?\"folder.fill\":\"doc\"},name:{text:t},size:{text:r?\"\":\"--\"}}})).sort(((e,t)=>e.info.info.isDirectory!==t.info.info.isDirectory?e.info.info.isDirectory?-1:1:e.info.info.isDirectory===t.info.info.isDirectory?e.info.info.file.localeCompare(t.info.info.file):void 0))}async loadFileSize(e){return e.map(((t,i)=>{const r=t.info.info;if(!r.isDirectory)try{e[i].size.text=$272f042430a952c6$require$Kernel.bytesToSize($file.read(r.path).info.size)}catch(t){e[i].size.text=t}})),e}get listTemplate(){return{props:{bgcolor:$color(\"clear\")},views:[{props:{id:\"info\"}},{type:\"image\",props:{id:\"icon\"},layout:(e,t)=>{e.centerY.equalTo(t.super),e.left.inset(this.edges),e.size.equalTo(this.iconSize)}},{type:\"label\",props:{id:\"name\",lines:1},layout:(e,t)=>{e.centerY.equalTo(t.super),e.left.equalTo(t.prev.right).offset(this.edges)}},{type:\"label\",props:{id:\"size\",color:$color(\"secondaryText\"),lines:1},layout:(e,t)=>{e.centerY.equalTo(t.super),e.right.inset(this.edges)}}]}}#x(e,t){if(this.viewController){const i=new $272f042430a952c6$require$NavigationView;i.setView(t).navigationBarTitle(e),i.navigationBar.setLargeTitleDisplayMode($272f042430a952c6$require$NavigationBar.largeTitleDisplayModeNever),this.viewController.push(i)}else $272f042430a952c6$require$UIKit.push({title:e,views:[t]})}getListView(e=\"\"){return{type:\"list\",props:{id:this.listId,menu:this.menu,info:{basePath:e},bgcolor:$272f042430a952c6$require$UIKit.primaryViewBackgroundColor,separatorInset:$insets(0,this.edges,0,0),data:[],template:this.listTemplate,actions:[{title:\" \"+$l10n(\"DELETE\")+\" \",color:$color(\"red\"),handler:(e,t)=>{const i=e.object(t).info.info;$272f042430a952c6$require$Kernel.deleteConfirm($l10n(\"FILE_MANAGER_DELETE_CONFIRM_MSG\")+' \"'+i.file+'\" ?',(()=>{this.delete(i),e.delete(t)}))}}]},layout:$layout.fill,events:{ready:()=>{const t=this.getFiles(e);$(this.listId).data=t,this.loadFileSize(t).then((e=>{$(this.listId).data=e}))},pulled:async e=>{const t=this.getFiles($(this.listId).info.basePath);$(this.listId).data=t,$(this.listId).data=await this.loadFileSize(t),$delay(.5,(()=>{e.endRefreshing()}))},didSelect:(e,t,i)=>{const r=i.info.info;r.isDirectory?this.#x(r.file,this.getListView(r.path)):this.edit(r)}}}}push(e=\"\"){const t=e.substring(e.lastIndexOf(\"/\"));this.#x(t,this.getListView(e))}}$272f042430a952c6$exports={FileManager:$272f042430a952c6$var$FileManager};var $bb0fea222fc5aea5$require$FileManager=$272f042430a952c6$exports.FileManager,$8aDdQ=parcelRequire(\"8aDdQ\"),$bb0fea222fc5aea5$require$FileStorageParameterError=$8aDdQ.FileStorageParameterError,$bb0fea222fc5aea5$require$FileStorageFileNotFoundError=$8aDdQ.FileStorageFileNotFoundError,$bb0fea222fc5aea5$require$FileStorage=$8aDdQ.FileStorage,$4c192cc93140b629$exports={},$liCrE=parcelRequire(\"liCrE\"),$4c192cc93140b629$require$View=$liCrE.View,$45Ip7=parcelRequire(\"45Ip7\"),$4c192cc93140b629$require$UIKit=$45Ip7.UIKit;class $4c192cc93140b629$var$FixedFooterView extends $4c192cc93140b629$require$View{height=60;getView(){return this.type=\"view\",this.setProp(\"bgcolor\",$4c192cc93140b629$require$UIKit.primaryViewBackgroundColor),this.layout=(e,t)=>{e.left.right.bottom.equalTo(t.super),e.top.equalTo(t.super.safeAreaBottom).offset(-this.height)},this.views=[$4c192cc93140b629$require$View.create({props:this.props,views:this.views,layout:(e,t)=>{e.left.right.top.equalTo(t.super),e.height.equalTo(this.height)}})],this}}$4c192cc93140b629$exports={FixedFooterView:$4c192cc93140b629$var$FixedFooterView};var $bb0fea222fc5aea5$require$FixedFooterView=$4c192cc93140b629$exports.FixedFooterView,$cgaQ6=parcelRequire(\"cgaQ6\"),$bb0fea222fc5aea5$require$Kernel=$cgaQ6.Kernel,$50aa538fe0dbd3b0$exports={},$liCrE=parcelRequire(\"liCrE\"),$50aa538fe0dbd3b0$require$View=$liCrE.View;class $50aa538fe0dbd3b0$var$Matrix extends $50aa538fe0dbd3b0$require$View{titleStyle={font:$font(\"bold\",21),height:30};#k;#B;templateIdByIndex(e){return void 0===this.props.template.views[e]?.props?.id&&(void 0===this.props.template.views[e].props&&(this.props.template.views[e].props={}),this.props.template.views[e].props.id=$text.uuid),this.props.template.views[e].props.id}get templateHiddenStatus(){if(!this.#B){this.#B={};for(let e=0;e(e.items=e.items.map((e=>(Object.keys(e).forEach((t=>{e[t].hidden=this.templateHiddenStatus[t]??!1})),Object.keys(this.templateHiddenStatus).forEach((t=>{e[t]||(e[t]={}),e[t].hidden=this.templateHiddenStatus[t]})),e.__templateProps={hidden:!1},e.__title={hidden:!0},e))),e.title&&e.items.unshift(this.#q(e.title)),e)))}rebuildTemplate(){let e={};void 0!==this.props.template.props&&(e=Object.assign(this.props.template.props,{id:\"__templateProps\",hidden:!1})),this.props.template.props={};const t=[{type:\"view\",props:e,layout:$layout.fill},{type:\"label\",props:{id:\"__title\",hidden:!0,font:this.titleStyle.font},layout:(e,t)=>{e.top.inset(-this.titleStyle.height/4*3),e.height.equalTo(this.titleStyle.height),e.width.equalTo(t.super.safeArea)}}].concat(this.props.template.views);this.props.template.views=t}insert(e,t=!0){return e.indexPath=this.indexPath(e.indexPath,t),$(this.id).insert(e)}delete(e,t=!0){return e=this.indexPath(e,t),$(this.id).delete(e)}object(e,t=!0){return e=this.indexPath(e,t),$(this.id).object(e)}cell(e,t=!0){return e=this.indexPath(e,t),$(this.id).cell(e)}indexPath(e,t){let i=t?0:1;return\"number\"==typeof e&&(e=$indexPath(0,e)),$indexPath(e.section,e.row+i)}update(e){this.props.data=this.rebuildData(e),$(this.id).data=this.props.data}getView(){return this.props.data=this.rebuildData(this.props.data),this.rebuildTemplate(),this.setEvent(\"itemSize\",((e,t)=>{const i=e.object(t)?.__title?.info;if(i?.title)return $size(Math.max($device.info.screen.width,$device.info.screen.height),0);const r=this.props.columns??2,s=this.props.spacing??15,a=this.props.itemWidth??this.props.itemSize?.width??(e.super.frame.width-s*(r+1))/r,n=this.props.itemHeight??this.props.itemSize?.height??100;return $size(a,n)})),this}}$50aa538fe0dbd3b0$exports={Matrix:$50aa538fe0dbd3b0$var$Matrix};var $bb0fea222fc5aea5$require$Matrix=$50aa538fe0dbd3b0$exports.Matrix,$619319e3f3656d3f$exports={};class $619319e3f3656d3f$var$Request{static method={get:\"GET\",post:\"POST\",delete:\"DELETE\",patch:\"PATCH\",head:\"HEAD\"};cacheContainerKey=$addin?.current?.name+\".request.cache\";#R=!1;#L=!1;cacheLife=2592e6;isLogRequest=!1;timeout=5;logger;constructor(e){\"function\"==typeof e&&(this.logger=e)}get cache(){return $cache.get(this.cacheContainerKey)??{}}#O(e){this.isLogRequest&&\"function\"==typeof logger&&this.logger(e)}logRequest(e){return this.isLogRequest=!0,\"function\"==typeof e&&(this.logger=e),this}getCacheKey(e){return $text.MD5(e)}getCache(e,t=null){return this.cache[e]??t}setCache(e,t){if(!t)return;const i=this.cache;i[e]=t,$cache.set(this.cacheContainerKey,i)}removeCache(e){let t=this.cache;delete t[e],$cache.set(this.cacheContainerKey,t)}clearCache(){$cache.remove(this.cacheContainerKey)}useCache(){return this.#R=!0,this}ignoreCacheExp(){this.#L=!0}async request(e,t,i={},r={},s=this.cacheLife){let a;const n=this.#R&&t===$619319e3f3656d3f$var$Request.method.get;if(n){a=this.getCacheKey(e);const t=this.getCache(a);if(t&&(this.#L||t.exp>Date.now()))return this.#O(\"get data from cache: \"+e),t.data}try{this.#O(`sending request [${t}]: ${e}`);const o=await $http.request({header:r,url:e,method:t,body:i,timeout:this.timeout});if(o.error)throw o.error;if(o?.response?.statusCode>=400){let e=o.data;throw\"object\"==typeof e&&(e=JSON.stringify(e)),new Error(\"http error: [\"+o.response.statusCode+\"] \"+e)}return n&&this.setCache(a,{exp:Date.now()+s,data:o}),o}catch(e){throw e.code&&(e=new Error(\"network error: [\"+e.code+\"] \"+e.localizedDescription)),e}}}$619319e3f3656d3f$exports={Request:$619319e3f3656d3f$var$Request};var $bb0fea222fc5aea5$require$Request=$619319e3f3656d3f$exports.Request,$7D8Kb=parcelRequire(\"7D8Kb\"),$bb0fea222fc5aea5$require$Setting=$7D8Kb.Setting,$aXWmO=parcelRequire(\"aXWmO\"),$bb0fea222fc5aea5$require$Sheet=$aXWmO.Sheet,$7dfcabb1e936a92c$exports={},$liCrE=parcelRequire(\"liCrE\"),$7dfcabb1e936a92c$require$View=$liCrE.View,$7dfcabb1e936a92c$require$PageView=$liCrE.PageView,$fYz8N=parcelRequire(\"fYz8N\"),$7dfcabb1e936a92c$require$Controller=$fYz8N.Controller,$45Ip7=parcelRequire(\"45Ip7\"),$7dfcabb1e936a92c$require$UIKit=$45Ip7.UIKit;class $7dfcabb1e936a92c$var$TabBarCellView extends $7dfcabb1e936a92c$require$View{constructor(e={}){super(e),this.setIcon(e.icon),this.setTitle(e.title),void 0!==e.activeStatus&&(this.activeStatus=e.activeStatus)}setIcon(e){return this.icon=e instanceof Array?e:[e,e],this}setTitle(e){return this.title=e,this}active(){$(`${this.props.id}-icon`).image=$image(this.icon[1]),$(`${this.props.id}-icon`).tintColor=$color(\"systemLink\"),$(`${this.props.id}-title`).textColor=$color(\"systemLink\"),this.activeStatus=!0}inactive(){$(`${this.props.id}-icon`).image=$image(this.icon[0]),$(`${this.props.id}-icon`).tintColor=$color(\"lightGray\"),$(`${this.props.id}-title`).textColor=$color(\"lightGray\"),this.activeStatus=!1}getView(){return this.views=[{type:\"image\",props:{id:`${this.props.id}-icon`,image:$image(this.activeStatus?this.icon[1]:this.icon[0]),bgcolor:$color(\"clear\"),tintColor:$color(this.activeStatus?\"systemLink\":\"lightGray\")},layout:(e,t)=>{e.centerX.equalTo(t.super);const i=$7dfcabb1e936a92c$var$TabBarController.tabBarHeight/2;e.size.equalTo(i),e.top.inset(($7dfcabb1e936a92c$var$TabBarController.tabBarHeight-i-13)/2)}},{type:\"label\",props:{id:`${this.props.id}-title`,text:this.title,font:$font(10),textColor:$color(this.activeStatus?\"systemLink\":\"lightGray\")},layout:(e,t)=>{e.centerX.equalTo(t.prev),e.top.equalTo(t.prev.bottom).offset(3)}}],this}}class $7dfcabb1e936a92c$var$TabBarHeaderView extends $7dfcabb1e936a92c$require$View{height=60;getView(){return this.type=\"view\",this.setProp(\"bgcolor\",this.props.bgcolor??$7dfcabb1e936a92c$require$UIKit.primaryViewBackgroundColor),this.layout=(e,t)=>{e.left.right.bottom.equalTo(t.super),e.top.equalTo(t.super.safeAreaBottom).offset(-this.height-$7dfcabb1e936a92c$var$TabBarController.tabBarHeight)},this.views=[$7dfcabb1e936a92c$require$View.create({props:this.props,views:this.views,layout:(e,t)=>{e.left.right.top.equalTo(t.super),e.height.equalTo(this.height)}})],this}}class $7dfcabb1e936a92c$var$TabBarController extends $7dfcabb1e936a92c$require$Controller{static tabBarHeight=50;#D={};#N={};#V;#_;#P=$text.uuid;#M=$text.uuid;bottomSafeAreaInsets=$app.isDebugging?0:$7dfcabb1e936a92c$require$UIKit.bottomSafeAreaInsets;get selected(){return this.#_}set selected(e){this.switchPageTo(e)}get contentOffset(){return $7dfcabb1e936a92c$var$TabBarController.tabBarHeight+(this.#V?.height??0)}setPages(e={}){return Object.keys(e).forEach((t=>this.setPage(t,e[t]))),this}setPage(e,t){return void 0===this.#_&&(this.#_=e),this.#D[e]=t instanceof $7dfcabb1e936a92c$require$PageView?t:$7dfcabb1e936a92c$require$PageView.create(t),this.#_!==e&&(this.#D[e].activeStatus=!1),this}switchPageTo(e){if(this.#D[e]){if(this.#_===e)return;$ui.animate({duration:.4,animation:()=>{this.#N[e].active()}}),this.#N[this.#_].inactive(),this.#D[this.#_].hide(),this.#D[e].show(),this.callEvent(\"onChange\",this.#_,e),this.#_=e,this.initBackground()}}hideBackground(e=!0){$(this.#M).hidden=!0,$ui.animate({duration:e?.2:1e-4,animation:()=>{$(this.#P).alpha=0}})}showBackground(e=!0){$(this.#M).hidden=!1,$ui.animate({duration:e?.2:1e-4,animation:()=>{$(this.#P).alpha=1}})}initBackground(){const e=this.#D[this.selected];e.scrollable&&$delay(0,(()=>{const t=$(e.id).get(e.scrollableView.id),i=t.contentOffset.y;t.contentSize.height+this.bottomSafeAreaInsets-t.frame.height-i<=0?this.hideBackground(!1):this.showBackground(!1)}))}setCells(e={}){return Object.keys(e).forEach((t=>this.setCell(t,e[t]))),this}setCell(e,t){return void 0===this.#_&&(this.#_=e),t instanceof $7dfcabb1e936a92c$var$TabBarCellView||(t=new $7dfcabb1e936a92c$var$TabBarCellView({props:{info:{key:e}},icon:t.icon,title:t.title,activeStatus:this.#_===e})),this.#N[e]=t,this}setHeader(e){return this.#V=e,this}#F(){const e=[];return Object.values(this.#N).forEach((t=>{t.setEvent(\"tapped\",(e=>{const t=e.info.key;this.switchPageTo(t)})),e.push(t.getView())})),e}#H(){return Object.values(this.#D).map((e=>{if(e.scrollable){const t=e.scrollableView;if(t.props.indicatorInsets){const e=t.props.indicatorInsets;t.props.indicatorInsets=$insets(e.top,e.left,e.bottom+this.contentOffset,e.right)}else t.props.indicatorInsets=$insets(0,0,this.contentOffset,0);t.props.footer=Object.assign({props:{}},t.props.footer??{}),t.props.footer.props.height?t.props.footer.props.height+=this.contentOffset:t.props.footer.props.height=this.contentOffset,\"function\"==typeof t.assignEvent&&t.assignEvent(\"didScroll\",(e=>{const t=e.contentOffset.y;e.contentSize.height+this.bottomSafeAreaInsets-e.frame.height-t<=1?this.hideBackground():this.showBackground()}))}return e.definition}))}generateView(){const e={type:\"view\",layout:(e,t)=>{e.centerX.equalTo(t.super),e.width.equalTo(t.super),e.top.equalTo(t.super.safeAreaBottom).offset(-$7dfcabb1e936a92c$var$TabBarController.tabBarHeight),e.bottom.equalTo(t.super)},views:[$7dfcabb1e936a92c$require$UIKit.blurBox({id:this.#P}),{type:\"stack\",layout:$layout.fillSafeArea,props:{axis:$stackViewAxis.horizontal,distribution:$stackViewDistribution.fillEqually,spacing:0,stack:{views:this.#F()}}},$7dfcabb1e936a92c$require$UIKit.separatorLine({id:this.#M},$7dfcabb1e936a92c$require$UIKit.align.top)],events:{ready:()=>this.initBackground()}};return $7dfcabb1e936a92c$require$View.createFromViews(this.#H().concat(this.#V?.definition??[],e))}}$7dfcabb1e936a92c$exports={TabBarCellView:$7dfcabb1e936a92c$var$TabBarCellView,TabBarHeaderView:$7dfcabb1e936a92c$var$TabBarHeaderView,TabBarController:$7dfcabb1e936a92c$var$TabBarController};var $bb0fea222fc5aea5$require$TabBarCellView=$7dfcabb1e936a92c$exports.TabBarCellView,$bb0fea222fc5aea5$require$TabBarHeaderView=$7dfcabb1e936a92c$exports.TabBarHeaderView,$bb0fea222fc5aea5$require$TabBarController=$7dfcabb1e936a92c$exports.TabBarController,$3839e9f9bae78bdd$exports={};class $3839e9f9bae78bdd$var$Tasks{#U={};addTask(e,t=0){const i=$text.uuid;return this.#U[i]=$delay(t,(async()=>{await e(),delete this.#U[i]})),i}cancelTask(e){this.#U[e].cancel()}clearTasks(){Object.values(this.#U).forEach((e=>e.cancel()))}}$3839e9f9bae78bdd$exports={Tasks:$3839e9f9bae78bdd$var$Tasks};var $bb0fea222fc5aea5$require$Tasks=$3839e9f9bae78bdd$exports.Tasks,$895b2d75ea56b5f0$exports={},$45Ip7=parcelRequire(\"45Ip7\"),$895b2d75ea56b5f0$require$UIKit=$45Ip7.UIKit;class $895b2d75ea56b5f0$var$Toast{static type={info:void 0,success:\"checkmark\",warning:\"exclamationmark.triangle\",error:\"xmark.circle\"};static edges=40;static iconSize=100;static labelTopMargin=10;width=Math.min(.6*$895b2d75ea56b5f0$require$UIKit.windowSize.width,260);labelWidth=this.width-2*$895b2d75ea56b5f0$var$Toast.edges;id=$text.uuid;#z=\"\";type=$895b2d75ea56b5f0$var$Toast.type.info;labelLines=2;font=$font(\"default\",26);constructor(e,t=$895b2d75ea56b5f0$var$Toast.type.info,i=2,r=$font(\"default\",26)){this.type=t,this.message=e,this.labelLines=i,this.font=r}get message(){return this.#z}set message(e){this.#z=e,this.fontHeight=$895b2d75ea56b5f0$require$UIKit.getContentSize(this.font,this.message,this.labelWidth,this.labelLines).height,this.height=(this.hasIcon?$895b2d75ea56b5f0$var$Toast.labelTopMargin+$895b2d75ea56b5f0$var$Toast.iconSize:0)+this.fontHeight+2*$895b2d75ea56b5f0$var$Toast.edges}get hasIcon(){return void 0!==this.type}get blurBox(){const e=$895b2d75ea56b5f0$require$UIKit.blurBox({id:this.id,cornerRadius:15,alpha:0},[{type:\"image\",props:{symbol:this.type,hidden:!this.hasIcon,tintColor:$color(\"lightGray\")},layout:(e,t)=>{e.top.inset($895b2d75ea56b5f0$var$Toast.edges),e.size.equalTo($895b2d75ea56b5f0$var$Toast.iconSize),e.centerX.equalTo(t.super)}},{type:\"label\",props:{font:this.font,text:this.message,align:$align.center,lines:this.labelLines,color:$color(\"lightGray\")},layout:(e,t)=>{e.bottom.equalTo(t.supper).offset(-$895b2d75ea56b5f0$var$Toast.edges),e.width.equalTo(this.labelWidth),e.height.equalTo(this.fontHeight),e.centerX.equalTo(t.super)}}]);return e.events={tapped:()=>{this.remove()}},e}show(){$ui.controller.view.insertAtIndex($ui.create(this.blurBox),0);const e=$(this.id);e.layout(((e,t)=>{e.center.equalTo(t.super),e.size.equalTo($size(this.width,this.height))})),e.moveToFront(),$ui.animate({duration:.2,animation:()=>{e.alpha=1}})}remove(){const e=$(this.id);e&&$ui.animate({duration:.2,animation:()=>{e.alpha=0},completion:()=>{e.remove()}})}static toast({message:e,type:t=$895b2d75ea56b5f0$var$Toast.type.info,displayTime:i=2,labelLines:r=2,font:s=$font(\"default\",26)}){const a=new $895b2d75ea56b5f0$var$Toast(e,t,r,s);a.show(),$delay(i,(()=>{a.remove()}))}static info(e,t={}){$895b2d75ea56b5f0$var$Toast.toast(Object.assign({message:e,type:$895b2d75ea56b5f0$var$Toast.type.info},t))}static success(e,t={}){$895b2d75ea56b5f0$var$Toast.toast(Object.assign({message:e,type:$895b2d75ea56b5f0$var$Toast.type.success},t))}static warning(e,t={}){$895b2d75ea56b5f0$var$Toast.toast(Object.assign({message:e,type:$895b2d75ea56b5f0$var$Toast.type.warning},t))}static error(e,t={}){$895b2d75ea56b5f0$var$Toast.toast(Object.assign({message:e,type:$895b2d75ea56b5f0$var$Toast.type.error},t))}}$895b2d75ea56b5f0$exports={Toast:$895b2d75ea56b5f0$var$Toast};var $bb0fea222fc5aea5$require$Toast=$895b2d75ea56b5f0$exports.Toast,$45Ip7=parcelRequire(\"45Ip7\"),$bb0fea222fc5aea5$require$UIKit=$45Ip7.UIKit,$86d2ffde19fb8791$exports={};class $86d2ffde19fb8791$var$UILoading{#j;text=\"\";interval;fullScreen=!1;#K=()=>{};constructor(){this.#j=$text.uuid}updateText(e){$(this.#j).text=e}setLoop(e){if(\"function\"!=typeof e)throw\"loop must be a function\";this.#K=e}done(){clearInterval(this.interval)}load(){$ui.render({props:{navBarHidden:this.fullScreen},views:[{type:\"spinner\",props:{loading:!0},layout:(e,t)=>{e.centerY.equalTo(t.super).offset(-15),e.width.equalTo(t.super)}},{type:\"label\",props:{id:this.#j,align:$align.center,text:\"\"},layout:(e,t)=>{e.top.equalTo(t.prev.bottom).offset(10),e.left.right.equalTo(t.super)}}],layout:$layout.fill,events:{appeared:()=>{this.interval=setInterval((()=>{this.#K()}),100)}}})}}$86d2ffde19fb8791$exports={UILoading:$86d2ffde19fb8791$var$UILoading};var $bb0fea222fc5aea5$require$UILoading=$86d2ffde19fb8791$exports.UILoading,$6Xrbz=parcelRequire(\"6Xrbz\"),$bb0fea222fc5aea5$require$ValidationError=$6Xrbz.ValidationError,$liCrE=parcelRequire(\"liCrE\"),$bb0fea222fc5aea5$require$View=$liCrE.View,$bb0fea222fc5aea5$require$PageView=$liCrE.PageView,$gMc1q=parcelRequire(\"gMc1q\"),$bb0fea222fc5aea5$require$ViewController=$gMc1q.ViewController,$12xzj=parcelRequire(\"12xzj\"),$bb0fea222fc5aea5$require$NavigationView=$12xzj.NavigationView,$dcStC=parcelRequire(\"dcStC\"),$bb0fea222fc5aea5$require$NavigationBar=$dcStC.NavigationBar,$bb0fea222fc5aea5$require$NavigationBarController=$dcStC.NavigationBarController,$gAYmG=parcelRequire(\"gAYmG\"),$bb0fea222fc5aea5$require$NavigationBarItems=$gAYmG.NavigationBarItems,$bb0fea222fc5aea5$require$BarButtonItem=$gAYmG.BarButtonItem,$ee5e1f8d12d987dc$exports={},$fYz8N=parcelRequire(\"fYz8N\"),$ee5e1f8d12d987dc$require$Controller=$fYz8N.Controller,$gAYmG=parcelRequire(\"gAYmG\"),$ee5e1f8d12d987dc$require$BarTitleView=$gAYmG.BarTitleView;class $ee5e1f8d12d987dc$var$SearchBar extends $ee5e1f8d12d987dc$require$BarTitleView{height=35;topOffset=15;bottomOffset=10;kbType=$kbType.search;placeholder=$l10n(\"SEARCH\");inputEvents={};keyboardView;accessoryView;constructor(e){super(e),this.setController(new $ee5e1f8d12d987dc$var$SearchBarController),this.controller.setSearchBar(this)}setEvent(e,t){return this.inputEvents[e]=t,this}setPlaceholder(e){return this.placeholder=e,this}setKbType(e){return this.kbType=e,this}setKeyboardView(e){return this.keyboardView=e,this}setAccessoryView(e){return this.accessoryView=e,this}getView(){return this.props={id:this.id,smoothCorners:!0,cornerRadius:6,bgcolor:$color(\"#EEF1F1\",\"#212121\")},this.views=[{type:\"input\",props:{id:this.id+\"-input\",type:this.kbType,bgcolor:$color(\"clear\"),placeholder:this.placeholder,keyboardView:this.keyboardView,accessoryView:this.accessoryView},layout:$layout.fill,events:Object.assign({changed:e=>this.controller.callEvent(\"onChange\",e.text),returned:e=>this.controller.callEvent(\"onReturn\",e.text)},this.inputEvents)}],this.layout=(e,t)=>{e.height.equalTo(this.height),e.top.equalTo(t.super.safeArea).offset(this.topOffset),e.left.equalTo(t.super.safeArea).offset(15),e.right.equalTo(t.super.safeArea).offset(-15)},this}}class $ee5e1f8d12d987dc$var$SearchBarController extends $ee5e1f8d12d987dc$require$Controller{setSearchBar(e){return this.searchBar=e,this}updateSelector(){this.selector={inputBox:$(this.searchBar.id),input:$(this.searchBar.id+\"-input\")}}hide(){this.updateSelector(),this.selector.inputBox.updateLayout((e=>{e.height.equalTo(0)}))}show(){this.updateSelector(),this.selector.inputBox.updateLayout((e=>{e.height.equalTo(this.searchBar.height)}))}didScroll(e){this.updateSelector();let t=this.searchBar.height-e;if(t=t>0?t>this.searchBar.height?this.searchBar.height:t:0,this.selector.inputBox.updateLayout((e=>{e.height.equalTo(t)})),e>0){const t=(this.searchBar.height/2-5-e)/10;this.selector.input.alpha=t}else this.selector.input.alpha=1}didEndDragging(e,t,i){this.updateSelector(),e>=0&&e<=this.searchBar.height&&i($point(0,e>=this.searchBar.height/2?this.searchBar.height:0))}}$ee5e1f8d12d987dc$exports={SearchBar:$ee5e1f8d12d987dc$var$SearchBar,SearchBarController:$ee5e1f8d12d987dc$var$SearchBarController};var $bb0fea222fc5aea5$require$SearchBar=$ee5e1f8d12d987dc$exports.SearchBar,$bb0fea222fc5aea5$require$SearchBarController=$ee5e1f8d12d987dc$exports.SearchBarController;module.exports={VERSION:$bb0fea222fc5aea5$require$VERSION,Controller:$bb0fea222fc5aea5$require$Controller,FileManager:$bb0fea222fc5aea5$require$FileManager,FileStorageParameterError:$bb0fea222fc5aea5$require$FileStorageParameterError,FileStorageFileNotFoundError:$bb0fea222fc5aea5$require$FileStorageFileNotFoundError,FileStorage:$bb0fea222fc5aea5$require$FileStorage,FixedFooterView:$bb0fea222fc5aea5$require$FixedFooterView,Kernel:$bb0fea222fc5aea5$require$Kernel,Matrix:$bb0fea222fc5aea5$require$Matrix,Request:$bb0fea222fc5aea5$require$Request,Setting:$bb0fea222fc5aea5$require$Setting,Sheet:$bb0fea222fc5aea5$require$Sheet,TabBarCellView:$bb0fea222fc5aea5$require$TabBarCellView,TabBarHeaderView:$bb0fea222fc5aea5$require$TabBarHeaderView,TabBarController:$bb0fea222fc5aea5$require$TabBarController,Tasks:$bb0fea222fc5aea5$require$Tasks,Toast:$bb0fea222fc5aea5$require$Toast,UIKit:$bb0fea222fc5aea5$require$UIKit,UILoading:$bb0fea222fc5aea5$require$UILoading,ValidationError:$bb0fea222fc5aea5$require$ValidationError,View:$bb0fea222fc5aea5$require$View,PageView:$bb0fea222fc5aea5$require$PageView,ViewController:$bb0fea222fc5aea5$require$ViewController,NavigationView:$bb0fea222fc5aea5$require$NavigationView,NavigationBar:$bb0fea222fc5aea5$require$NavigationBar,NavigationBarController:$bb0fea222fc5aea5$require$NavigationBarController,NavigationBarItems:$bb0fea222fc5aea5$require$NavigationBarItems,BarButtonItem:$bb0fea222fc5aea5$require$BarButtonItem,SearchBar:$bb0fea222fc5aea5$require$SearchBar,SearchBarController:$bb0fea222fc5aea5$require$SearchBarController}})),parcelRequire.register(\"jEwwi\",(function(e,t){var i=parcelRequire(\"gxpqj\").Kernel;class r{sqlite;constructor(e){this.kernel=e,this.dbName=\"CAIO.db\",this.localDb=`/${this.dbName}`,this.imagePath=\"/image\",this.imageOriginalPath=`${this.imagePath}/original`,this.imagePreviewPath=`${this.imagePath}/preview`,this.tempPath=\"/temp\",this.tempDbFile=`${this.tempPath}/${this.dbName}`,this.tempImagePath=`${this.tempPath}/image`,this.exportFileName=\"CAIO.zip\",this.init()}init(){this.sqlite=$sqlite.open(this.kernel.fileStorage.filePath(this.localDb)),this.sqlite.update(\"CREATE TABLE IF NOT EXISTS clips(uuid TEXT PRIMARY KEY NOT NULL, text TEXT, md5 TEXT, prev TEXT, next TEXT)\"),this.sqlite.update(\"CREATE TABLE IF NOT EXISTS favorite(uuid TEXT PRIMARY KEY NOT NULL, text TEXT, md5 TEXT, prev TEXT, next TEXT)\"),this.sqlite.update(\"CREATE TABLE IF NOT EXISTS tag(uuid TEXT PRIMARY KEY NOT NULL, tag TEXT)\")}rebuild(){const e=this.tempPath+\"/rebuild.db\";this.kernel.fileStorage.delete(e);const t=new r(this.kernel);t.localDb=e,t.init();const i=(e,i)=>{const r=[];e.forEach((e=>{const s={uuid:e.uuid,text:e.text,md5:e.md5,tag:e.tag,image:e.image,prev:null,next:r[0]?.uuid??null};t.beginTransaction();try{t.insert(i,s),s.next&&(r[0].prev=s.uuid,t.update(i,r[0])),t.commit(),r.unshift(s)}catch(e){throw t.rollback(),this.kernel.error(e),e}}))};[\"clips\",\"favorite\"].map((e=>{let t=this.all(e);try{const e=this.sort(JSON.parse(JSON.stringify(t)));if(e.length>t.length)throw new Error;t=e.reverse()}catch{}i(t,e)}));const s=this.sqlite.query(\"SELECT * FROM tag\");this.parseTag(s).forEach((e=>{t.beginTransaction();try{t.setTag(e.uuid,e.tag),t.commit()}catch(e){throw t.rollback(),this.kernel.error(e),e}})),this.kernel.fileStorage.copy(e,this.localDb)}deleteAllData(){this.kernel.fileStorage.delete(this.imagePath),this.kernel.fileStorage.delete(this.localDb)}clearTemp(){this.kernel.fileStorage.delete(this.tempPath)}async export(e){this.clearTemp(),this.kernel.fileStorage.copy(this.localDb,this.tempDbFile),this.kernel.fileStorage.copy(this.imagePath,this.tempImagePath);const t=this.tempPath+\"/\"+this.exportFileName;await $archiver.zip({directory:this.kernel.fileStorage.filePath(this.tempPath),dest:this.kernel.fileStorage.filePath(t)}),$share.sheet({items:[{name:this.exportFileName,data:$data({path:this.kernel.fileStorage.filePath(t)})}],handler:i=>{this.kernel.fileStorage.delete(t),e(i)}})}async import(e){if(\"db\"===e.fileName.slice(-2)){if(!this.kernel.fileStorage.writeSync(this.localDb,e))throw new Error(\"WRITE_DB_FILE_FAILED\")}else if(\"zip\"===e.fileName.slice(-3)){if(!await $archiver.unzip({file:e,dest:this.kernel.fileStorage.filePath(this.tempPath)}))throw new Error(\"UNZIP_FAILED\");this.kernel.fileStorage.move(this.tempDbFile,this.localDb),this.kernel.fileStorage.move(this.tempImagePath,this.imagePath)}}sort(e,t=9e3){const i={};let r=0,s=null;e.forEach((e=>{i[e.uuid]=e,null===e.prev&&(s=e.uuid),r++}));const a=[];if(r>0)try{let e=i[s];for(;null!==e.next&&t>0;)t--,a.push(e),e=i[e.next];a.push(e)}catch(e){throw\"Unable to sort: \"+e}return a}parse(e){const t=e.result,i=e.error;if(null!==i)throw new Error(`Code [${i.code}] ${i.domain} ${i.localizedDescription}`);const r=[];for(;t.next();)r.push({uuid:t.get(\"uuid\"),section:t.get(\"section\"),text:t.get(\"text\"),md5:t.get(\"md5\"),tag:t.get(\"tag\")??\"\",prev:t.get(\"prev\")??null,next:t.get(\"next\")??null});return t.close(),r}parseTag(e){if(null!==e.error)throw e.error;const t=[];for(;e.result.next();)t.push({uuid:e.result.get(\"uuid\"),tag:e.result.get(\"tag\")});return e.result.close(),t}beginTransaction(){this.sqlite.beginTransaction()}commit(){this.sqlite.commit()}rollback(){this.sqlite.rollback()}getByUUID(e){e=e.replace(\"'\",\"\");const t=this.sqlite.query({sql:`\\n SELECT *, 'clips' AS section FROM clips WHERE uuid = '${e}'\\n UNION\\n SELECT *, 'favorite' AS section FROM favorite WHERE uuid = '${e}'\\n `});return this.parse(t)[0]}getByMD5(e){e=e.replace(\"'\",\"\");const t=this.sqlite.query({sql:`\\n SELECT *, 'clips' AS section FROM clips WHERE md5 = '${e}'\\n UNION\\n SELECT *, 'favorite' AS section FROM favorite WHERE md5 = '${e}'\\n `});return this.parse(t)[0]}search(e){const t=this.sqlite.query({sql:\"SELECT * from\\n (SELECT clips.*, 'clips' AS section FROM clips WHERE text like ?\\n UNION\\n SELECT favorite.*, 'favorite' AS section FROM favorite WHERE text like ?) a\\n LEFT JOIN tag ON a.uuid = tag.uuid\\n \",args:[`%${e}%`,`%${e}%`]});return this.parse(t)}isImage(e){return e?.startsWith(\"@image=\")}pathToKey(e){return`@image=${e=JSON.stringify(e)}`}keyToPath(e){return!!this.isImage(e)&&JSON.parse(e.slice(7))}deleteTable(e){const t=this.sqlite.update(`DELETE FROM ${e}`);if(!t.result)throw t.error}all(e){const t=this.sqlite.query(`SELECT ${e}.*, tag, '${e}' AS section FROM ${e} LEFT JOIN tag ON ${e}.uuid = tag.uuid`);return this.parse(t)}insert(e,t){if(t.image){const e=t.image,r=$text.uuid,s={original:`${this.imageOriginalPath}/${r}.png`,preview:`${this.imagePreviewPath}/${r}.jpg`};this.kernel.fileStorage.write(s.original,e.png),this.kernel.fileStorage.write(s.preview,i.compressImage(e).jpg(.8)),t.text=this.pathToKey(s)}const r=this.sqlite.update({sql:`INSERT INTO ${e} (uuid, text, md5, prev, next) values (?, ?, ?, ?, ?)`,args:[t.uuid,t.text,$text.MD5(t.text),t.prev,t.next]});if(!r.result)throw r.error}update(e,t){if(Object.keys(t).length<4||\"string\"!=typeof t.uuid)return;const i=this.sqlite.update({sql:`UPDATE ${e} SET text = ?, md5 = ?, prev = ?, next = ? WHERE uuid = ?`,args:[t.text,$text.MD5(t.text),t.prev,t.next,t.uuid]});if(!i.result)throw i.error}updateText(e,t,i){if(\"string\"!=typeof t)return;const r=this.sqlite.update({sql:`UPDATE ${e} SET text = ?, md5 = ? WHERE uuid = ?`,args:[i,$text.MD5(i),t]});if(!r.result)throw r.error}delete(e,t){const i=this.getByUUID(t);this.beginTransaction();try{const i=this.sqlite.update({sql:`DELETE FROM ${e} WHERE uuid = ?`,args:[t]});if(!i.result)throw i.error;this.deleteTag(t),this.commit()}catch(e){throw this.rollback(),e}const r=this.keyToPath(i?.text);r&&(this.kernel.fileStorage.delete(r.original),this.kernel.fileStorage.delete(r.preview))}setTag(e,t){const i=this.sqlite.update({sql:\"INSERT OR REPLACE INTO tag (uuid, tag) values (?, ?)\",args:[e,t]});if(!i.result)throw i.error}deleteTag(e){const t=this.sqlite.update({sql:\"DELETE FROM tag WHERE uuid = ?\",args:[e]});if(!t.result)throw t.error}}e.exports=r})),parcelRequire.register(\"imdB1\",(function(e,t){var i=parcelRequire(\"gxpqj\"),r=i.View,s=i.Kernel,a=i.UIKit,n=i.Sheet,o=i.ViewController,l=i.NavigationView,c=i.NavigationBar,h=i.Toast,d=parcelRequire(\"f0nX9\"),p=parcelRequire(\"ZnuTV\"),u=parcelRequire(\"ay4Kj\"),g=parcelRequire(\"9LqeL\"),f=parcelRequire(\"eSp9Z\"),y=f.ActionData,b=f.ActionEnv;e.exports=class extends p{listId=\"clips-list\";#Y=!1;#G=-1;tabLeftMargin=20;horizontalMargin=20;verticalMargin=20;containerMargin=0;fontSize=16;copiedIndicatorSize=6;imageContentHeight=50;tagFontSize=14;tagContainerHeight=25;menuItemActionMaxCount=5;tabHeight=44;copied=$cache.get(\"clips.copied\")??{};#W={};constructor(e){super(e),this.viewController=new o,this.search=new u(this.kernel),this.search.setCallback((e=>{(new n).setView(this.getListView(this.listId+\"-search-result\",e.map((e=>this.lineData(e))))).addNavBar({title:$l10n(\"SEARCH_RESULT\"),popButton:{title:$l10n(\"DONE\"),tapped:()=>this.search.dismiss()}}).init().present()}))}get singleLineHeight(){return this.#G<0&&(this.#G=$text.sizeThatFits({text:\"A\",width:this.fontSize,font:$font(this.fontSize)}).height),this.#G}setSingleLine(){this.#Y=!0,this.imageContentHeight=this.singleLineHeight}getTextHeight(e){return this.#W[e]||(this.#W[e]=this.#Y?this.singleLineHeight:Math.min($text.sizeThatFits({text:e,width:a.windowSize.width-2*(this.horizontalMargin+this.containerMargin),font:$font(this.fontSize)}).height,2*this.singleLineHeight)),this.#W[e]}appListen(){s.isTaio||$app.listen({resume:()=>{this.updateList(!0),$delay(.5,(()=>{this.readClipboard()}))}})}listReady(){this.updateList(),s.isTaio||($delay(.5,(()=>{if($context.query.copy){const e=$context.query.copy,t=this.kernel.storage.getByUUID(e);this.setClipboardText(t.text),this.setCopied(e,this.getRowByUUID(e)),$ui.success($l10n(\"COPIED\"))}else $context.query.add?this.getAddTextView():$context.query.actions&&(this.kernel.isUseJsboxNav?this.kernel.actionManager.present():this.kernel.tabBarController.switchPageTo(\"actions\"))})),$delay(.5,(()=>{this.readClipboard()})),this.appListen())}updateList(e=!1){e&&this.loadAllClips(),$(this.listId).data=this.clips.map((e=>this.lineData(e,this.copied.uuid===e.uuid))),this.updateListBackground()}updateListBackground(){const e=$(this.listId+\"-empty-list-background\");e&&(e.hidden=this.clips.length>0)}updateCopied(e={}){Object.assign(this.copied,e),this.kernel.print(`this.copied: ${JSON.stringify(this.copied,null,2)}`),$cache.set(\"clips.copied\",this.copied)}setCopied(e,t,i=!0){if(!e||e===this.copied.uuid&&this.tabIndex===this.copied?.tabIndex&&t===this.copied?.row)return;let r={};this.copied.uuid!==e&&(r=this.kernel.storage.getByUUID(e)??{}),r.tabIndex=this.tabIndex,r.row=t;const s=this.copied.row;this.updateCopied(r),i&&$delay(.3,(()=>{const e=$(this.listId);e.cell($indexPath(0,s)).get(\"copied\").hidden=!0,e.cell($indexPath(0,t)).get(\"copied\").hidden=!1}))}readClipboard(e=!1){if(e||this.kernel.setting.get(\"clipboard.autoSave\")){if(this.kernel.print(\"read clipboard\"),!this.isChanged)return void(e&&$ui.toast($l10n(\"CLIPBOARD_NO_CHANGE\")));if(this.switchTab(1,!0),$clipboard.images?.length>0)return!!e&&($clipboard.images.forEach((e=>{this.add(e)})),!0);const t=$clipboard.text;if(!t||\"\"===t)return!1;if(this.copied.text===t)return!1;const i=$text.MD5(t);if(this.savedClipboardIndex[i]){const e=this.kernel.storage.getByMD5(i);this.setCopied(e.uuid,this.getRowByUUID(e.uuid))}else{const e=this.add(t);this.copy(t,e.uuid,0)}}return!1}add(e){try{const t=super.add(e);return this.updateListBackground(),$(this.listId).insert({indexPath:$indexPath(0,0),value:this.lineData(t)}),this.copied?.tabIndex===this.tabIndex&&this.setCopied(this.copied.uuid,this.copied?.row+1,!1),t}catch(e){$ui.alert(e)}}delete(e,t){try{super.delete(e,t),this.copied.uuid===e&&(this.copied={},$clipboard.clear()),this.updateListBackground()}catch(e){$ui.alert(e)}}update(e,t,i){return!!super.update(e,t,i)&&(this.updateList(),e===this.copied.uuid&&(this.setClipboardText(t),this.updateCopied({text:t})),!0)}move(e,t,i=!0){if(e!==t)try{if(super.move(e,t),!i)return;const r=$(this.listId);ee&&this.copied.rowt||this.copied.row===t)&&this.setCopied(this.copied.uuid,e{i.text?$share.sheet(i.text):$ui.warning($l10n(\"NONE\"))}}];if(this.kernel.isUseJsboxNav)i.uikitPush(e,(e=>t(e)),r);else{const s=i.getNavigationView(e,(e=>t(e)),r);this.viewController.push(s)}}getAddTextView(){this.edit(\"\",(e=>{\"\"!==e&&this.add(e)}))}menuItems(e=!1){const t=[{inline:!0,items:[{title:$l10n(\"TAG\"),symbol:\"tag\",handler:(e,t)=>{const i=this.clips[t.row].uuid;$input.text({placeholder:$l10n(\"ADD_TAG\"),text:e.text,handler:e=>{(e=e.trim()).length>0?this.kernel.storage.setTag(i,e):this.kernel.storage.deleteTag(i),this.updateList(!0)}})}}]},{inline:!0,items:[{title:$l10n(\"SHARE\"),symbol:\"square.and.arrow.up\",handler:(e,t)=>{const i=this.clips[t.row].text;let r=i;const s=this.kernel.storage.keyToPath(i);if(s&&this.kernel.fileStorage.exists(s.original)){const e=this.kernel.fileStorage.readSync(s.original)?.image?.png;r={name:e.fileName,data:e}}$share.sheet([r])}},{title:$l10n(\"COPY\"),symbol:\"square.on.square\",handler:(e,t)=>{const i=this.clips[t.row];this.copy(i.text,i.uuid,t.row)}},{title:$l10n(\"DELETE\"),symbol:\"trash\",destructive:!0,handler:(e,t)=>{this.kernel.deleteConfirm($l10n(\"CONFIRM_DELETE_MSG\"),(()=>{const i=this.clips[t.row];this.delete(i.uuid,t.row),e.delete(t)}))}}]}];if(e)return t;const i=e=>{const t=this.kernel.actionManager.getActionHandler(e.type,e.dir);return e.handler=(e,i)=>{const r=this.clips[i.row],s=new y({env:b.clipboard,text:r.text,uuid:r.uuid});t(s)},e.title=e.name,e.symbol=e.icon,e},r=this.kernel.actionManager.getActions(\"clipboard\"),s={inline:!0,items:r.slice(0,this.menuItemActionMaxCount).map(i)};return r.length>this.menuItemActionMaxCount&&s.items.push({title:$l10n(\"MORE_ACTIONS\"),symbol:\"square.grid.2x2\",items:r.slice(this.menuItemActionMaxCount).map(i)}),[s,...t]}switchTab(e,t=!1){this.tabIndex=e,this.updateList(),t&&($(this.listId+\"-tab\").index=this.tabIndex)}tabView(){return{type:\"tab\",props:{id:this.listId+\"-tab\",items:this.tabItems,index:this.tabIndex,dynamicWidth:!0},events:{changed:e=>this.switchTab(e.index)},layout:(e,t)=>{e.centerY.equalTo(t.super),t.prev?e.left.equalTo(t.prev.right).offset(this.tabLeftMargin):e.left.inset(this.tabLeftMargin)}}}lineData(e,t=!1){const i={hidden:!0},r={text:\"\"},s=this.kernel.storage.keyToPath(e.text);return s?(i.src=s.preview,i.hidden=!1):r.text=e.text,{copied:{hidden:!t},image:i,tag:{text:e.tag},content:r}}listTemplate(){return{props:{bgcolor:$color(\"clear\")},views:[{type:\"view\",views:[{type:\"view\",props:{id:\"copied\",circular:this.copiedIndicatorSize,hidden:!0,bgcolor:$color(\"green\")},layout:(e,t)=>{e.centerY.equalTo(t.super),e.size.equalTo(this.copiedIndicatorSize),e.left.equalTo(t.super).inset(this.horizontalMargin/2-this.copiedIndicatorSize/2)}},{type:\"label\",props:{id:\"content\",lines:this.#Y?1:2,font:$font(this.fontSize)},layout:(e,t)=>{e.left.right.equalTo(t.super).inset(this.horizontalMargin),this.#Y?e.top.inset(this.imageContentHeight/2):e.top.inset(this.verticalMargin)}},{type:\"image\",props:{id:\"image\",hidden:!0},layout:$layout.fill}],layout:$layout.fill},{type:\"label\",props:{id:\"tag\",color:$color(\"systemGray2\"),font:$font(this.tagFontSize)},layout:(e,t)=>{e.bottom.width.equalTo(t.super),e.left.inset(this.horizontalMargin),e.height.equalTo(this.tagContainerHeight)}}]}}getListView(e=this.listId,t=[]){const i={type:\"list\",props:{id:e,associateWithNavigationBar:!1,bgcolor:$color(\"clear\"),separatorInset:$insets(0,this.horizontalMargin,0,0),menu:{items:this.menuItems()},data:t,template:this.listTemplate(),actions:[{title:$l10n(\"COPY\"),color:$color(\"systemLink\"),handler:(e,t)=>{const i=this.clips[t.row];this.copy(i.text,i.uuid,t.row)}},{title:$l10n(\"FAVORITE\"),color:$color(\"orange\"),handler:(e,t)=>{const i=this.clips[t.row];this.favorite(i,t.row)}}]},layout:$layout.fill,events:{ready:()=>this.listReady(),rowHeight:(e,t)=>{const i=e.object(t),r=i.tag.text?this.tagContainerHeight:this.verticalMargin;return(this.kernel.storage.isImage(i.content.text)?this.imageContentHeight:this.getTextHeight(i.content.text))+this.verticalMargin+r},didSelect:(e,t,i)=>{const r=this.clips[t.row],s=r.text,a=this.kernel.storage.keyToPath(s);a&&this.kernel.fileStorage.exists(a.original)?$quicklook.open({image:this.kernel.fileStorage.readSync(a.original)?.image}):this.edit(r.text,(e=>{r.md5!==$text.MD5(e)&&this.update(r.uuid,e,t.row)}))},pulled:e=>{this.updateList(!0),$delay(.5,(()=>e.endRefreshing()))}}},s={type:\"label\",props:{id:e+\"-empty-list-background\",color:$color(\"secondaryText\"),hidden:this.clips.length>0,text:$l10n(\"NONE\"),align:$align.center},layout:$layout.center};return r.createFromViews([i,s])}getNavigationView(){const e=this.tabView();e.type=\"menu\",e.layout=(e,t)=>{e.top.left.right.equalTo(t.super),e.height.equalTo(this.tabHeight)};const t=this.getListView();t.views.unshift(e),t.views[1].layout=(e,t)=>{e.bottom.left.right.equalTo(t.super),e.top.equalTo(t.prev.bottom)},t.views.push(this.search.getSearchHistoryView());const i=(new l).navigationBarTitle($l10n(\"CLIPS\")).setView(t);return i.navigationBarItems.setTitleView(this.search.getSearchBarView()).pinTitleView().setRightButtons([{symbol:\"plus.circle\",tapped:()=>this.getAddTextView()}]).setLeftButtons([{title:$l10n(\"EDIT\"),tapped:()=>{new g(this).presentSheet()}},{symbol:\"square.and.arrow.down.on.square\",tapped:e=>{e.start(),this.readClipboard(!0),e.done()}}]),i.navigationBar.setBackgroundColor(a.primaryViewBackgroundColor).setLargeTitleDisplayMode(c.largeTitleDisplayModeNever),this.kernel.isUseJsboxNav&&i.navigationBar.removeTopSafeArea(),i}}})),parcelRequire.register(\"f0nX9\",(function(e,t){var i=parcelRequire(\"gxpqj\"),r=i.UIKit,s=i.NavigationBar,a=i.NavigationView,n=i.Sheet,o=parcelRequire(\"eSp9Z\"),l=o.ActionEnv,c=o.ActionData;e.exports=class{#J=\"\";constructor(e){this.kernel=e,this.id=\"editor\",this.originalContent=void 0}set text(e=\"\"){void 0===this.originalContent&&(this.originalContent=e),this.#J=e}get text(){return this.#J}getActionButton(){return{symbol:\"bolt.circle\",tapped:(e,t)=>{t&&(e=t);const i=$(this.id).selectedRange,r=new c({env:l.editor,editor:{setContent:e=>this.setContent(e)},text:i.length>0?this.text.slice(i.location,i.location+i.length):this.text,selectedRange:i}),s=$ui.popover({sourceView:e,directions:$popoverDirection.up,size:$size(200,300),views:[this.kernel.actionManager.getActionListView((e=>{s.dismiss(),$delay(.5,(()=>e(r)))}))]})}}}setContent(e){this.text=e,$(this.id).text=e}getView(e=\"text\"){return{type:e,layout:$layout.fill,props:{id:this.id,lineNumbers:this.kernel.setting.get(\"editor.code.lineNumbers\"),theme:this.kernel.setting.get($device.isDarkMode?\"editor.code.darkTheme\":\"editor.code.lightTheme\"),text:this.text,insets:$insets(15,15,\"text\"===e?this.kernel.setting.get(\"editor.text.insets\"):15,15)},events:{ready:e=>{\"\"===this.text&&setTimeout((()=>e.focus()),500)},didChange:e=>{this.text=e.text}}}}pageSheet(e=\"\",t,i,r=[],s=\"text\"){this.text=e,r.unshift(this.getActionButton());const a=new n;a.setView(this.getView(s)).addNavBar({title:i,popButton:{title:$l10n(\"DONE\"),tapped:()=>t(this.text)},rightButtons:r}),a.navigationView.navigationBar.contentViewHeightOffset=0,a.init().present()}uikitPush(e=\"\",t,i=[],s=\"text\"){this.text=e,i.unshift(this.getActionButton()),r.push({title:\"\",navButtons:i.map((e=>(e.handler=e.tapped,e.tapped=void 0,e))),views:[this.getView(s)],disappeared:()=>t(this.text)})}getNavigationView(e=\"\",t,i=[],r=\"text\"){this.text=e,i.unshift(this.getActionButton());const n=new a;return n.navigationBar.contentViewHeightOffset=0,n.navigationBar.setLargeTitleDisplayMode(s.largeTitleDisplayModeNever),n.navigationBarItems.setRightButtons(i),n.setView(this.getView(r)).navigationBarTitle(\"\"),n.setEvent(\"onPop\",(()=>t(this.text))),n}}})),parcelRequire.register(\"eSp9Z\",(function(e,t){var i=parcelRequire(\"gxpqj\"),r=i.Kernel,s=i.Sheet;class a{static keyboard=0;static today=0;static editor=1;static clipboard=2;static action=3}e.exports={ActionEnv:a,ActionData:class{env;args;text;originalContent;uuid;selectedRange;textBeforeInput;textAfterInput;editor;constructor({env:e,args:t,text:i,uuid:r=null,selectedRange:s=null,textBeforeInput:a=null,textAfterInput:n=null,editor:o=null}={}){this.env=e,this.args=t,this.text=i,this.originalContent=i,this.uuid=r,this.selectedRange=s,this.textBeforeInput=a,this.textAfterInput=n,this.editor=o}},Action:class{#X;constructor(e,t,i){this.#X=e,this.config=t,Object.assign(this,i),this.originalContent=this.text;const s=this.l10n();Object.keys(s).forEach((e=>{r.l10n(e,s[e])}))}l10n(){return{}}pageSheet({view:e,title:t=\"\",done:i,doneText:r=$l10n(\"DONE\"),rightButtons:a=[]}){(new s).setView(e).addNavBar({title:t,popButton:{title:r,tapped:()=>{i&&i()}},rightButtons:a}).init().present()}getAllClips(){return{favorite:this.#X.storage.all(\"favorite\").map((e=>e.text)),clips:this.#X.storage.all(\"clips\").map((e=>e.text))}}async clearAllClips(){if(0!==(await $ui.alert({title:$l10n(\"DELETE_DATA\"),message:$l10n(\"DELETE_TABLE\").replace(\"${table}\",$l10n(\"CLIPS\")),actions:[{title:$l10n(\"DELETE\"),style:$alertActionType.destructive},{title:$l10n(\"CANCEL\")}]})).index)return!1;try{return this.#X.storage.deleteTable(\"clips\"),!0}catch(e){throw this.#X.error(e),e}}setContent(e){this.text=e,this.env===a.editor&&this.editor.setContent(e)}getAction(e,t,i){return this.#X.actionManager.getAction(e,t,i)}async runAction(e,t){const i=this.getAction(e,t);return await i.do()}async request(e,t,i={},r={}){try{this.#X.print(`sending request [${t}]: ${e}`);const s=await $http.request({header:r,url:e,method:t,body:i,timeout:5});if(s.error)throw s.error;if(s?.response?.statusCode>=400){let e=s.data;throw\"object\"==typeof e&&(e=JSON.stringify(e)),new Error(\"http error: [\"+s.response.statusCode+\"] \"+e)}return s}catch(e){throw e.code&&(e=new Error(\"network error: [\"+e.code+\"] \"+e.localizedDescription)),e}}getUrls(){return(this.text??\"\").match(/(https?:\\/\\/)([\\da-z\\.-]+)\\.([a-z\\.]{2,6})([:0-9])*([\\/\\w\\#\\.\\-\\?\\=\\&])*\\s?/gi)??[]}}}})),parcelRequire.register(\"ZnuTV\",(function(e,t){var i=parcelRequire(\"gxpqj\").UIKit;e.exports=class{kernel;pasteboard=$objc(\"UIPasteboard\").$generalPasteboard();#Q=[];savedClipboardIndex={};tabItems=[$l10n(\"FAVORITE\"),$l10n(\"CLIPS\")];tabItemsIndex=[\"favorite\",\"clips\"];constructor(e){this.kernel=e}set tabIndex(e){$cache.set(\"caio.main.tab.index\",e)}get tabIndex(){return $cache.get(\"caio.main.tab.index\")??0}get table(){return this.tabItemsIndex[this.tabIndex]}get tableL10n(){return this.tabItems[this.tabIndex]}get allClips(){return 0===this.#Q.length&&this.loadAllClips(),this.#Q}set allClips(e){this.#Q=e.map((e=>new Proxy(e??[],{set:(e,t,i)=>Reflect.set(e,t,i),get:(e,t)=>Reflect.get(e,t)})))}get clips(){return this.allClips[this.tabIndex]}get isChanged(){const e=this.pasteboard.$changeCount(),t=$cache.get(\"clipboard.changeCount\");return $cache.set(\"clipboard.changeCount\",e),t!==e}getRowByUUID(e){let t=this.clips.length;for(let i=0;i{const i=JSON.parse(JSON.stringify(e));return Object.assign(i,t)},r=this.table;this.clips[t]||(this.clips[t]={uuid:null,text:\"\",next:null,prev:this.clips[t-1].uuid});try{this.kernel.storage.beginTransaction();const s=i(this.clips[e]),a=i(this.clips[t]);if(this.clips[e-1]){const t=i(this.clips[e-1],{next:this.clips[e].next});this.kernel.storage.update(r,t),this.clips[e-1]=t}if(this.clips[e+1]){const t=i(this.clips[e+1],{prev:this.clips[e].prev});this.kernel.storage.update(r,t),this.clips[e+1]=t}if(this.clips[t-1]){const s=i(this.clips[t-1],{next:this.clips[e].uuid});this.kernel.storage.update(r,s),this.clips[t-1]=s}const n=i(a,{prev:s.uuid,next:this.clips[t].next});this.kernel.storage.update(r,n);const o=i(s,{prev:this.clips[t].prev,next:a.uuid});this.kernel.storage.update(r,o),this.clips[t]=n,this.clips[e]=o,this.clips.splice(t,0,this.clips[e]),this.clips.splice(e>t?e+1:e,1),this.kernel.storage.commit()}catch(e){throw this.kernel.error(e),this.kernel.storage.rollback(),e}finally{null===this.clips[t].uuid&&this.clips.splice(t,1)}}favorite(e,t){e.next=this.allClips[0][0]?.uuid??null,e.prev=null;try{this.kernel.storage.beginTransaction(),this.kernel.storage.insert(\"favorite\",e),e.next&&(this.allClips[0][0].prev=e.uuid,this.kernel.storage.update(\"favorite\",this.allClips[0][0])),this.kernel.storage.commit(),\"favorite\"!==e?.section&&(e.section=\"favorite\",this.delete(e.uuid,t)),this.allClips[0].unshift(e),this.savedClipboardIndex[e.md5]=1}catch(e){throw this.kernel.error(e),this.kernel.storage.rollback(),e}}loadAllClips(){this.kernel.print(\"load all clips\");const e=e=>{try{return this.kernel.storage.sort(e,this.kernel.setting.get(\"clipboard.maxItemLength\")).map((e=>(this.savedClipboardIndex[e.md5]=1,e)))}catch(e){$ui.alert({title:$l10n(\"REBUILD_DATABASE\"),message:$l10n(\"CLIPS_STRUCTURE_ERROR\"),actions:[{title:$l10n(\"OK\"),handler:()=>{const e=i.loading();e.start(),this.kernel.storage.rebuild(),e.end(),$delay(.8,(()=>$addin.restart()))}},{title:$l10n(\"CANCEL\")}]}),this.kernel.error(e)}};this.allClips=[e(this.kernel.storage.all(this.tabItemsIndex[0])),e(this.kernel.storage.all(this.tabItemsIndex[1]))]}}})),parcelRequire.register(\"ay4Kj\",(function(e,t){var i=parcelRequire(\"gxpqj\"),r=i.UIKit,s=i.SearchBar;e.exports=class{listId=\"clips-list-search\";kernel;callback=()=>{};onBegin=()=>{};onDismiss=()=>{};constructor(e){this.kernel=e,this.searchBar=new s,this.searchBarId=this.searchBar.id+\"-input\"}get searchHistoryView(){return{hide:()=>$(this.listId+\"-history\").hidden=!0,show:()=>$(this.listId+\"-history\").hidden=!1}}get searchHistory(){return[{title:$l10n(\"SEARCH_HISTORY\"),rows:$cache.get(\"caio.search.history\")?.reverse()??[]}]}getAccessoryView(){return r.blurBox({height:50},[{type:\"button\",props:{bgcolor:$color(\"clear\"),tintColor:$color(\"primaryText\"),symbol:\"xmark.circle\"},layout:(e,t)=>{e.right.inset(0),e.height.equalTo(t.super),e.width.equalTo(t.super.height)},events:{tapped:()=>this.dismiss()}},{type:\"button\",props:{bgcolor:$color(\"clear\"),tintColor:$color(\"primaryText\"),symbol:\"keyboard.chevron.compact.down\"},layout:(e,t)=>{e.right.equalTo(t.prev.left),e.height.equalTo(t.super),e.width.equalTo(t.super.height)},events:{tapped:()=>$(this.searchBarId).blur()}}])}getSearchHistoryView(){return{type:\"list\",props:{id:this.listId+\"-history\",hidden:!0,stickyHeader:!0,data:this.searchHistory,separatorInset:$insets(0,13,0,0),actions:[{title:$l10n(\"DELETE\"),handler:(e,t)=>{const i=e.data;this.updateSearchHistory(i[0].rows.reverse())}}]},events:{didSelect:(e,t,i)=>{this.searchAction(i),$(this.searchBarId).text=i}},layout:$layout.fill}}setCallback(e){this.callback=e}setOnBegin(e){this.onBegin=e}setOnDismiss(e){this.onDismiss=e}begin(){this.searchHistoryView.show(),this.onBegin()}dismiss(){$(this.searchBarId).blur(),$(this.searchBarId).text=\"\",this.searchHistoryView.hide(),this.onDismiss()}searchAction(e){try{if(\"\"!==e){const t=this.kernel.storage.search(e);t&&t.length>0?($(this.searchBarId).blur(),this.callback(t)):$ui.toast($l10n(\"NO_SEARCH_RESULT\")),this.pushSearchHistory(e)}}catch(e){throw e}}pushSearchHistory(e){let t=$cache.get(\"caio.search.history\")??[];-1===t.indexOf(e)&&(t.push(e),t.length>20&&(t=t.slice(-20)),$(this.listId+\"-history\").data=this.searchHistory,$cache.set(\"caio.search.history\",t))}updateSearchHistory(e=[]){$cache.set(\"caio.search.history\",e)}getSearchBarView(){return this.searchBar.controller.setEvent(\"onReturn\",(e=>{\"\"!==e?this.searchAction(e):this.searchHistoryView.show()})),this.searchBar.controller.setEvent(\"onChange\",(e=>{\"\"===e&&this.searchHistoryView.show()})),this.searchBar.setEvent(\"didBeginEditing\",(e=>{\"\"===e.text&&this.begin()})),this.searchBar.setAccessoryView(this.getAccessoryView()),this.searchBar}}})),parcelRequire.register(\"9LqeL\",(function(e,t){var i=parcelRequire(\"gxpqj\"),r=i.View,s=i.UIKit,a=i.Sheet;class n{static symbol={selected:\"checkmark.circle.fill\",unselected:\"circle\"};listId=\"clips-list-editor\";reorder={};toolBarHeight=44;#Z=void 0;#ee={};constructor(e){this.clipsInstance=e,this.kernel=e.kernel}get editorSelectedIsEmpty(){let e=!0;const t=this.editorSelected;for(const i of Object.keys(t))if(t[i]){e=!1;break}return e}get editorSelectedIsFull(){let e=0,t=0;const i=this.editorSelected;for(const r of Object.keys(i))++t,i[r]&&++e;return t===e}get editorSelected(){return void 0===this.#Z&&(Array(this.clipsInstance.clips.length).fill(0).map(((e,t)=>this.#ee[t]=!1)),this.#Z=new Proxy(this.#ee,{set:(e,t,i,r)=>{Reflect.set(e,t,i,r),t=Number(t);const s=this.editorSelectedIsEmpty,a=$(this.listId+\"-select-button\"),o=$(this.listId+\"-delete-button\");a.title=this.editorSelectedIsFull?$l10n(\"DESELECT_ALL\"):$l10n(\"SELECT_ALL\"),o.hidden=s;const l=$(this.listId);return l.data=this.clipsInstance.clips.map(((t,i)=>{const r=this.lineData(t);return r.checkmark={symbol:e[i]?n.symbol.selected:n.symbol.unselected},r})),l.reorder=s,!0}})),this.#Z}set editorSelected(e){this.#Z=e}selectAll(){const e=this.editorSelectedIsFull;this.clipsInstance.clips.forEach(((t,i)=>{this.editorSelected[i]=!e}))}deleteSelected(){this.kernel.deleteConfirm($l10n(\"CONFIRM_DELETE_MSG\"),(()=>{const e=$(this.listId),t=$(this.clipsInstance.listId);Object.keys(this.editorSelected).reverse().forEach((i=>{if(this.editorSelected[i]){i=Number(i);const r=this.clipsInstance.clips[i];this.kernel.print(`delete selected: [${i}]\\n${r.text}`),this.clipsInstance.delete(r.uuid,i),t.delete(i),e.delete(i)}}))}))}getToolBarView(){return s.blurBox({},[s.separatorLine(),{type:\"view\",views:[{type:\"button\",props:{id:this.listId+\"-select-button\",title:$l10n(\"SELECT_ALL\"),titleColor:$color(\"tint\"),bgcolor:$color(\"clear\")},layout:(e,t)=>{e.left.inset(this.clipsInstance.horizontalMargin),e.centerY.equalTo(t.super)},events:{tapped:()=>this.selectAll()}},{type:\"button\",props:{id:this.listId+\"-delete-button\",symbol:\"trash\",hidden:!0,tintColor:$color(\"red\"),bgcolor:$color(\"clear\")},layout:(e,t)=>{e.right.inset(this.clipsInstance.horizontalMargin),e.centerY.equalTo(t.super)},events:{tapped:()=>this.deleteSelected()}}],layout:(e,t)=>{e.left.right.top.equalTo(t.super),e.bottom.equalTo(t.super.safeAreaBottom)}}],((e,t)=>{e.left.right.bottom.equalTo(t.super),e.top.equalTo(t.super.safeAreaBottom).offset(-this.toolBarHeight)}))}lineData(e){const t=this.clipsInstance.lineData(e);return t.checkmark={symbol:n.symbol.unselected},t}listTemplate(){const e=this.clipsInstance.listTemplate();return e.views[0].layout=(e,t)=>{e.height.right.equalTo(t.super),e.left.inset(30)},e.views.push({type:\"image\",props:{id:\"checkmark\",symbol:n.symbol.unselected,contentMode:$contentMode.scaleAspectFit},layout:(e,t)=>{e.centerY.equalTo(t.super),e.left.inset(15),e.size.equalTo($size(25,25))}}),e}getListEditerView(){return{type:\"list\",props:{id:this.listId,bgcolor:s.primaryViewBackgroundColor,separatorInset:$insets(0,this.clipsInstance.horizontalMargin,0,0),indicatorInsets:$insets(0,0,this.toolBarHeight,0),data:this.clipsInstance.clips.map((e=>this.lineData(e))),template:this.listTemplate(),reorder:!0,footer:{height:this.toolBarHeight},crossSections:!1},events:{rowHeight:(e,t)=>{const i=this.clipsInstance.clips[t.row].text;return(this.kernel.storage.isImage(i)?this.imageContentHeight:this.clipsInstance.getTextHeight(i))+2*this.clipsInstance.verticalMargin},reorderBegan:e=>{this.reorder.began=!0,this.reorder.from=e.row,this.reorder.to=void 0},reorderMoved:(e,t)=>{this.reorder.to=t.row},reorderFinished:()=>{this.reorder.began=!1,void 0!==this.reorder.to&&this.clipsInstance.move(this.reorder.from,this.reorder.to)},didSelect:(e,t,i)=>{this.editorSelected[t.row]=!this.editorSelected[t.row]}},layout:$layout.fill}}presentSheet(){const e=new a;e.setView(r.createFromViews([this.getListEditerView(),this.getToolBarView()])).addNavBar({title:\"\",popButton:{title:$l10n(\"CLOSE\")},rightButtons:[{title:$l10n(\"CLEAR\"),color:$color(\"red\"),tapped:async()=>{if(0===(await $ui.alert({title:$l10n(\"DELETE_DATA\"),message:$l10n(\"DELETE_TABLE\").replace(\"${table}\",this.clipsInstance.tableL10n),actions:[{title:$l10n(\"DELETE\"),style:$alertActionType.destructive},{title:$l10n(\"CANCEL\")}]})).index)try{this.kernel.storage.deleteTable(this.clipsInstance.table),e.dismiss(),this.clipsInstance.updateList(!0)}catch(e){this.kernel.error(e),$ui.error(e)}}}]}).init().present()}}e.exports=n})),parcelRequire.register(\"44eiF\",(function(e,t){var i=parcelRequire(\"gxpqj\"),r=i.Matrix,s=i.Setting,a=i.NavigationView,n=i.BarButtonItem,o=i.Sheet,l=i.UIKit,c=parcelRequire(\"f0nX9\"),h=parcelRequire(\"47XCm\"),d=parcelRequire(\"eSp9Z\"),p=d.ActionEnv,u=d.ActionData;e.exports=class extends h{matrix;reorder={};addActionButtonId=\"action-manager-button-add\";syncLabelId=\"action-manager-sync-label\";get actionList(){return super.actions.map((e=>{const t=[];return e.items.forEach((e=>{t.push(this.actionToData(e))})),{title:e.title,items:t,rows:t}}))}actionSyncStatus(){$app.listen({actionSyncStatus:e=>{if(e.status===h.syncStatus.syncing)this.undateAddActionButton(!0),this.undateSyncLabel($l10n(\"SYNCING\"));else if(e.status===h.syncStatus.success)try{this.matrix.update(this.actionList)}catch(e){this.kernel.error(e),this.undateSyncLabel(e),$ui.error(e)}finally{this.undateSyncLabel(),this.undateAddActionButton(!1)}}})}editActionInfoPageSheet(e,t){const i=this.getActionTypes(),r={};i.forEach(((e,t)=>{r[e]=t}));const a=!Boolean(e);a?this.editingActionInfo={type:\"clipboard\",name:\"MyAction\",color:\"#CC00CC\",icon:\"icon_062.png\",readme:\"\"}:(this.editingActionInfo=e,this.editingActionInfo.readme=this.getActionReadme(e.type,e.dir));const n=new s({structure:{},set:(e,t)=>(this.editingActionInfo[e]=\"type\"===e?t[1]:t,!0),get:(e,t=null)=>\"type\"===e?r[this.editingActionInfo.type]:Object.prototype.hasOwnProperty.call(this.editingActionInfo,e)?this.editingActionInfo[e]:t}),l=n.createInput(\"name\",[\"pencil.circle\",\"#FF3366\"],$l10n(\"NAME\")),c=n.createColor(\"color\",[\"pencil.tip.crop.circle\",\"#0066CC\"],$l10n(\"COLOR\")),h=n.createIcon(\"icon\",[\"star.circle\",\"#FF9933\"],$l10n(\"ICON\"),this.kernel.setting.getColor(this.editingActionInfo.color)),d=n.createMenu(\"type\",[\"tag.circle\",\"#33CC33\"],$l10n(\"TYPE\"),i,!0),p={type:\"view\",views:[{type:\"text\",props:{id:\"action-text\",textColor:$color(\"#000000\",\"secondaryText\"),bgcolor:$color(\"systemBackground\"),text:this.editingActionInfo.readme,insets:$insets(10,10,10,10)},layout:$layout.fill,events:{tapped:e=>{$(\"actionInfoPageSheetList\").scrollToOffset($point(0,a?280:230)),$delay(.2,(()=>e.focus()))},didChange:e=>{this.editingActionInfo.readme=e.text}}}],layout:$layout.fill},u=[{title:$l10n(\"INFORMATION\"),rows:[l,c,h]},{title:$l10n(\"DESCRIPTION\"),rows:[p]}];a&&(u[0].rows=u[0].rows.concat(d));(new o).setView({type:\"list\",props:{id:\"actionInfoPageSheetList\",bgcolor:$color(\"insetGroupedBackground\"),style:2,separatorInset:$insets(0,50,0,10),data:u},layout:$layout.fill,events:{rowHeight:(e,t)=>1===t.section?120:50}}).addNavBar({title:\"\",popButton:{title:$l10n(\"DONE\"),tapped:()=>{this.editingActionInfo.dir||(this.editingActionInfo.dir=$text.MD5(this.editingActionInfo.name)),this.saveActionInfo(this.editingActionInfo),t&&t(this.editingActionInfo)}}}).init().present()}editActionMainJs(e=\"\",t){new c(this.kernel).pageSheet(e,(e=>{this.saveMainJs(t,e)}),t.name,[{symbol:\"book.circle\",tapped:()=>{const e=$file.read(\"scripts/action/README.md\").string;(new o).setView({type:\"markdown\",props:{content:e},layout:(e,t)=>{e.size.equalTo(t.super)}}).init().present()}}],\"code\")}move(e,t){if(e.section===t.section&&e.row===t.row)return;super.move(e,t);const i=this.matrix,r=this.actionToData(this.actions[t.section].items[t.row]);e.row{const i=e.cell(t),r=i.get(\"info\").info;this.editActionInfoPageSheet(r,(e=>{i.get(\"info\").info=e,i.get(\"color\").bgcolor=this.kernel.setting.getColor(e.color),i.get(\"name\").text=e.name,\"icon_\"===e.icon.slice(0,5)?i.get(\"icon\").icon=$icon(e.icon.slice(5,e.icon.indexOf(\".\")),$color(\"#ffffff\")):i.get(\"icon\").image=$image(e.icon)}))}},{title:$l10n(\"EDIT_SCRIPT\"),symbol:\"square.and.pencil\",handler:(e,t,i)=>{const r=i.info.info;if(!r)return;const s=`${this.userActionPath}/${r.type}/${r.dir}/main.js`,a=$file.read(s).string;this.editActionMainJs(a,r)}},{inline:!0,items:[{title:\"README\",symbol:\"book\",handler:(e,t)=>{const i=e.cell(t).get(\"info\").info;let r;try{r=__ACTIONS__[i.type][i.dir][\"README.md\"]}catch{r=this.getActionReadme(i.type,i.dir)}(new o).setView({type:\"markdown\",props:{content:r},layout:(e,t)=>{e.size.equalTo(t.super)}}).init().present()}}]},{inline:!0,items:[{title:$l10n(\"DELETE\"),symbol:\"trash\",destructive:!0,handler:(e,t,i)=>{this.kernel.deleteConfirm($l10n(\"CONFIRM_DELETE_MSG\"),(()=>{this.delete(i.info.info),e.delete(t)}))}}]}]}getNavButtons(){return[{symbol:\"plus.circle\",id:this.addActionButtonId,menu:{pullDown:!0,asPrimary:!0,items:[{title:$l10n(\"CREATE_NEW_ACTION\"),handler:()=>{this.editActionInfoPageSheet(null,(e=>{this.matrix.insert({indexPath:$indexPath(this.getActionTypes().indexOf(e.type),0),value:this.actionToData(e)});const t=$file.read(`${this.actionPath}/template.js`).string;this.saveMainJs(e,t),this.editActionMainJs(t,e)}))}},{title:$l10n(\"CREATE_NEW_TYPE\"),handler:()=>{$input.text({text:\"\",placeholder:$l10n(\"CREATE_NEW_TYPE\"),handler:e=>{if(\"\"===(e=e.trim()))return void $ui.toast($l10n(\"INVALID_VALUE\"));const t=`${this.userActionPath}/${e}`;$file.isDirectory(t)?$ui.warning($l10n(\"TYPE_ALREADY_EXISTS\")):($file.mkdir(t),$ui.success($l10n(\"SUCCESS\")))}})}}]}},{symbol:\"arrow.up.arrow.down.circle\",tapped:(e,t)=>{$ui.popover({sourceView:t,directions:$popoverDirection.up,size:$size(200,300),views:[this.getActionListView(void 0,{reorder:!0,actions:[{title:\"delete\",handler:(e,t)=>{const i=this.matrix,r=i.object(t,!1).info.info;this.delete(r),i.delete(t,!1)}}]},{reorderBegan:e=>{this.reorder.from=e,this.reorder.to=void 0},reorderMoved:(e,t)=>{this.reorder.to=t},reorderFinished:e=>{void 0!==this.reorder.to&&this.move(this.reorder.from,this.reorder.to,e)}})]})}}]}actionToData(e){return{name:{text:e.name},icon:\"icon_\"===e.icon.slice(0,5)?{icon:$icon(e.icon.slice(5,e.icon.indexOf(\".\")),$color(\"#ffffff\"))}:{image:$image(e.icon)},color:{bgcolor:this.kernel.setting.getColor(e.color)},info:{info:e}}}undateSyncLabel(e){e||(e=$l10n(\"LAST_SYNC_AT\")+this.getSyncDate().toLocaleString()),$(this.syncLabelId)&&($(this.syncLabelId).text=e)}undateAddActionButton(e){const t=this.navigationView?.navigationBarItems?.getButton(this.addActionButtonId)??{};t&&t.setLoading(e)}getActionListView(e,t={},i={}){return e&&(i.didSelect=(t,i,r)=>{const s=r.info.info,a=this.kernel.actionManager.getActionHandler(s.type,s.dir);e(a)}),{type:\"list\",layout:(e,t)=>{e.top.width.equalTo(t.super.safeArea),e.bottom.inset(0)},events:i,props:Object.assign({reorder:!1,bgcolor:$color(\"clear\"),rowHeight:60,sectionTitleHeight:30,stickyHeader:!0,data:this.actionList,template:{props:{bgcolor:$color(\"clear\")},views:[{type:\"image\",props:{id:\"color\",cornerRadius:8,smoothCorners:!0},layout:(e,t)=>{e.centerY.equalTo(t.super),e.left.inset(15),e.size.equalTo($size(30,30))}},{type:\"image\",props:{id:\"icon\",tintColor:$color(\"#ffffff\")},layout:(e,t)=>{e.centerY.equalTo(t.super),e.left.inset(20),e.size.equalTo($size(20,20))}},{type:\"label\",props:{id:\"name\",lines:1,font:$font(16)},layout:(e,t)=>{e.height.equalTo(30),e.centerY.equalTo(t.super),e.left.equalTo(t.prev.right).offset(15)}},{type:\"label\",props:{id:\"info\"}}]}},t)}}getMatrixView({columns:e=2,spacing:t=15,itemHeight:i=100}={}){return this.matrix=r.create({type:\"matrix\",props:{columns:e,itemHeight:i,spacing:t,bgcolor:l.scrollViewBackgroundColor,menu:{items:this.menuItems()},data:this.actionList,template:{props:{smoothCorners:!0,cornerRadius:10,bgcolor:$color(\"#ffffff\",\"#242424\")},views:[{type:\"image\",props:{id:\"color\",cornerRadius:8,smoothCorners:!0},layout:e=>{e.top.left.inset(10),e.size.equalTo($size(30,30))}},{type:\"image\",props:{id:\"icon\",tintColor:$color(\"#ffffff\")},layout:e=>{e.top.left.inset(15),e.size.equalTo($size(20,20))}},{type:\"button\",props:{bgcolor:$color(\"clear\"),tintColor:l.textColor,titleColor:l.textColor,contentEdgeInsets:$insets(0,0,0,0),titleEdgeInsets:$insets(0,0,0,0),imageEdgeInsets:$insets(0,0,0,0)},views:[{type:\"image\",props:{symbol:\"ellipsis.circle\"},layout:(e,t)=>{e.center.equalTo(t.super),e.size.equalTo(n.style.iconSize)}}],events:{tapped:e=>{const t=e.next.info;if(!t)return;const i=`${this.userActionPath}/${t.type}/${t.dir}/main.js`,r=$file.read(i).string;this.editActionMainJs(r,t)}},layout:e=>{e.top.right.inset(0),e.size.equalTo(n.style.width)}},{type:\"view\",props:{id:\"info\",hidden:!0}},{type:\"label\",props:{id:\"name\",font:$font(16)},layout:(e,t)=>{e.bottom.left.inset(10),e.width.equalTo(t.super)}}]},footer:{type:\"view\",props:{hidden:!this.kernel.setting.get(\"experimental.syncAction\"),height:this.kernel.setting.get(\"experimental.syncAction\")?50:0},views:[{type:\"label\",props:{id:this.syncLabelId,color:$color(\"secondaryText\"),font:$font(12),text:$l10n(\"LAST_SYNC_AT\")+this.getSyncDate().toLocaleString()},layout:(e,i)=>{e.size.equalTo(i.super),e.top.inset(-30),e.left.inset(t)}}]}},layout:$layout.fill,events:{didSelect:(e,t,i)=>{const r=i.info.info,s=new u({env:p.action,text:\"clipboard\"===r.type||\"uncategorized\"===r.type?$clipboard.text:null});this.getActionHandler(r.type,r.dir)(s)},pulled:e=>{$delay(.5,(async()=>{this.undateAddActionButton(!0),await this.sync(),this.actionsNeedReload(),this.matrix.update(this.actionList),this.undateSyncLabel(),this.undateAddActionButton(!1),e.endRefreshing()}))}}}),this.actionSyncStatus(),this.matrix.definition}getPage(){return this.navigationView=new a,this.navigationView.navigationBarItems.setRightButtons(this.getNavButtons()),this.navigationView.setView(this.getMatrixView()).navigationBarTitle($l10n(\"ACTIONS\")),this.navigationView.getPage()}present(){const e=new o,t=this.getNavButtons();this.kernel.setting.get(\"experimental.syncAction\")&&t.push({symbol:\"arrow.up.arrow.down.circle\",tapped:async(e,t)=>{e.actionStart(),this.undateAddActionButton(!0),await this.sync(),this.actionsNeedReload(),this.matrix.update(this.actionList),this.undateSyncLabel(),e.actionDone(),this.undateAddActionButton(!1)}}),e.setView(this.getMatrixView()).addNavBar({title:$l10n(\"ACTIONS\"),popButton:{symbol:\"xmark.circle\"},rightButtons:t}).init().present()}}})),parcelRequire.register(\"47XCm\",(function(e,t){var i=parcelRequire(\"eSp9Z\"),r=i.ActionEnv,s=i.ActionData,a=i.Action;class n{static syncStatus={syncing:0,success:1};#te=3;#ie=!1;#re;constructor(e){this.kernel=e,this.actionPath=\"scripts/action\",this.actionOrderFile=\"order.json\",this.tempPath=`${this.kernel.fileStorage.basePath}/temp`,this.userActionPath=`${this.kernel.fileStorage.basePath}/user_action`,this.localSyncFile=this.userActionPath+\"/data.json\",this.iCloudPath=\"drive://CAIO/user_action\",this.iCloudSyncFile=this.iCloudPath+\"/data.json\",this.iCloudSyncFileUndownloaded=this.iCloudPath+\"/.data.json.icloud\",this.typeNameMap={},this.checkUserAction(),$thread.background({delay:this.#te,handler:()=>this.sync(!0)})}get actions(){return this.#re||(this.#re=this.getActionTypes().map((e=>({title:this.getTypeName(e),items:this.getActions(e)})))),this.#re}actionsNeedReload(e=!1){this.#re=void 0,e&&$file.write({data:$data({string:JSON.stringify({date:Date.now()})}),path:this.localSyncFile})}importExampleAction(){try{Object.keys(__ACTIONS__).forEach((e=>{const t=`${this.userActionPath}/${e}`;Object.keys(__ACTIONS__[e]).forEach((i=>{$file.exists(`${t}/${i}/main.js`)||($file.mkdir(t),$file.mkdir(`${t}/${i}`),$file.write({data:$data({string:__ACTIONS__[e][i][\"main.js\"]}),path:`${t}/${i}/main.js`}),$file.write({data:$data({string:__ACTIONS__[e][i][\"config.json\"]}),path:`${t}/${i}/config.json`}),$file.write({data:$data({string:__ACTIONS__[e][i][\"README.md\"]}),path:`${t}/${i}/README.md`}))}))}))}catch{$file.list(this.actionPath).forEach((e=>{const t=`${this.actionPath}/${e}`;if($file.isDirectory(t)){const i=`${this.userActionPath}/${e}`;$file.list(t).forEach((e=>{$file.exists(`${i}/${e}/main.js`)||($file.mkdir(i),$file.copy({src:`${t}/${e}`,dst:`${i}/${e}`}))}))}}))}}#se(e=\"\"){if(e=e.trim(\"/\"),!$file.exists(e)){const t=e.lastIndexOf(\"/\");if(-1!==t){const i=e.substring(0,t);this.#se(i)}$file.mkdir(e)}}async downloadFiles(e){const t=$file.list(e);for(let i=0;ithis.sync(e)}));let t;this.#ie=!0,this.checkSyncData(),t=$file.exists(this.iCloudSyncFileUndownloaded)?await $file.download(this.iCloudSyncFileUndownloaded):$file.read(this.iCloudSyncFile),t=JSON.parse(t);const i=JSON.parse($file.read(this.localSyncFile).string);if(i.datet.date&&($file.write({data:$data({string:JSON.stringify({date:i.date})}),path:this.iCloudSyncFile}),await $wait(this.#te),$app.notify({name:\"actionSyncStatus\",object:{status:n.syncStatus.success}}));this.#ie=!1,e&&$thread.background({delay:this.#te,handler:()=>this.sync(e)})}checkUserAction(){$file.exists(this.userActionPath)&&0!==$file.list(this.userActionPath).length||($file.mkdir(this.userActionPath),this.importExampleAction()),$file.exists(this.iCloudPath)&&0!==$file.list(this.iCloudPath).length||($file.mkdir(this.iCloudPath),$file.copy({src:this.userActionPath,dst:this.iCloudPath}))}getActionTypes(){const e=[\"clipboard\",\"editor\"];return e.concat($file.list(this.userActionPath).filter((t=>{if($file.isDirectory(`${this.userActionPath}/${t}`)&&e.indexOf(t)<0)return t})))}getActionOrder(e){const t=`${this.userActionPath}/${e}/${this.actionOrderFile}`;return $file.exists(t)?JSON.parse($file.read(t).string):[]}getActionPath(e,t){return`${this.userActionPath}/${e}/${t}`}getActionConfig(e,t){return JSON.parse($file.read(`${this.getActionPath(e,t)}/config.json`).string)}getActionReadme(e,t){return $file.read(`${this.getActionPath(e,t)}/README.md`).string}getAction(e,t,i){const n=this.getActionPath(e,t),o=this.getActionConfig(e,t);try{const e=$file.read(`${n}/main.js`).string,t=new Function(\"Action\",\"ActionEnv\",\"ActionData\",`${e}\\n return MyAction`)(a,r,s);return new t(this.kernel,o,i)}catch(e){$ui.error(e),this.kernel.error(e)}}getActionHandler(e,t){return async i=>{try{const r=this.getAction(e,t,i);return await r.do()}catch(e){$ui.error(e),this.kernel.error(e)}}}getActions(e){const t=[],i=`${this.userActionPath}/${e}`;if(!$file.exists(i))return[];const r=r=>{const s=`${i}/${r}/`;if($file.isDirectory(s)){const i=this.getActionConfig(e,r);t.push(Object.assign(i,{dir:r,type:e,name:i.name??r,icon:i.icon,color:i.color}))}},s=this.getActionOrder(e);return s.forEach((e=>r(e))),$file.list(i).forEach((e=>{-1===s.indexOf(e)&&r(e)})),t}getTypeName(e){const t=e.toUpperCase(),i=$l10n(t),r=i===t?e:i;return this.typeNameMap[r]=e,r}getTypeDir(e){return this.typeNameMap[e]??e}#ae(e,t,i,r){\"string\"!=typeof r&&(r=JSON.stringify(r));const s=`${this.userActionPath}/${e}/${t}`;if($file.exists(s)||$file.mkdir(s),r===$file.read(`${s}/${i}`)?.string)return;$file.write({data:$data({string:r}),path:`${s}/${i}`});const a=`${this.iCloudPath}/${e}/${t}`;$file.exists(a)||$file.mkdir(a),$file.write({data:$data({string:r}),path:`${a}/${i}`})}saveActionInfo(e){this.#ae(e.type,e.dir,\"config.json\",{icon:e.icon,color:e.color,name:e.name}),this.#ae(e.type,e.dir,\"README.md\",e.readme),this.actionsNeedReload(!0)}saveMainJs(e,t){this.#ae(e.type,e.dir,\"main.js\",t)}saveOrder(e,t){$file.write({data:$data({string:JSON.stringify(t)}),path:`${this.userActionPath}/${e}/${this.actionOrderFile}`}),$file.write({data:$data({string:JSON.stringify(t)}),path:`${this.iCloudPath}/${e}/${this.actionOrderFile}`}),this.actionsNeedReload(!0)}move(e,t){if(e.section===t.section&&e.row===t.row)return;const i=this.actions[e.section],r=i.items,s=this.getTypeDir(i.title),a=e=>e.map((e=>e.dir));if(e.section===t.section)r.splice(e.rowt.row?e.row+1:e.row,1),this.saveOrder(s,a(r));else{const i=this.actions[t.section],n=i.items,o=this.getTypeDir(i.title);n.splice(t.row,0,r[e.row]),r.splice(e.row,1),this.saveOrder(o,a(n)),this.saveOrder(s,a(r)),$file.move({src:`${this.userActionPath}/${s}/${n[t.row].dir}`,dst:`${this.userActionPath}/${o}/${n[t.row].dir}`}),$file.move({src:`${this.iCloudPath}/${s}/${n[t.row].dir}`,dst:`${this.iCloudPath}/${o}/${n[t.row].dir}`})}this.actionsNeedReload(!0)}delete(e){$file.delete(`${this.userActionPath}/${e.type}/${e.dir}`),$file.delete(`${this.iCloudPath}/${e.type}/${e.dir}`),this.actionsNeedReload(!0)}}e.exports=n})),parcelRequire.register(\"gYDdO\",(function(e,t){function i(e,t=[]){t.forEach((t=>{$file.exists(t)&&(e.print(`delete file: ${t}`),$file.delete(t))}))}function r(e,t,i){const r=e.storage.sqlite.query(`SELECT count(*), name FROM sqlite_master WHERE type = \"table\" AND name = \"${t}\"`);if(null!==r.error)throw new Error(`Code [${r.error.code}] ${r.error.domain} ${r.error.localizedDescription}`);r.result.next();const s=r.result.get(0);r.result.close(),s>0&&(e.print(`copy data from old table: ${t}`),e.storage.sqlite.update(`INSERT INTO ${i} SELECT * FROM ${t}`),e.print(`drop table: ${t}`),e.storage.sqlite.update(`DROP TABLE ${t}`))}async function s(e,t={}){const i=\"scripts/action\",r=`${e.fileStorage.basePath}/user_action`,s=[];for(let e of Object.keys(t))t[e].forEach((t=>{const r=JSON.parse($file.read(`${i}/${e}/${t}/config.json`).string);s.push(r.name)}));if(1!==(await $ui.alert({title:$l10n(\"compatibility.rebuildUserAction.alert.title\"),message:$l10n(\"compatibility.rebuildUserAction.alert.message\")+\"\\n\"+JSON.stringify(s,null,2)+\"\\n\"+$l10n(\"compatibility.rebuildUserAction.alert.message2\"),actions:[{title:$l10n(\"OK\")},{title:$l10n(\"CANCEL\")}]})).index)for(let s of Object.keys(t))t[s].forEach((t=>{$file.exists(`${r}/${s}/${t}`)&&(e.print(`rebuild user action: ${s}/${t}`),$file.copy({src:`${i}/${s}/${t}/main.js`,dst:`${r}/${s}/${t}/main.js`}))}))}e.exports=async function(e){if(!e)return;const t=$cache.get(\"compatibility.version\")??0;try{t<1&&(e.print(`compatibility: userVersion [${t}] lower than [1], start action`),await async function(e){i(e,[\"scripts/action/clipboard/ClearClipboard\",\"scripts/ui/clipboard.js\",\"scripts/ui/clipboard-data.js\",\"scripts/ui/clipboard-search.js\"]),r(e,\"clipboard\",\"clips\"),await s(e,{uncategorized:[\"ExportAllContent\",\"DisplayClipboard\"],clipboard:[\"B23Clean\"]}),$cache.get(\"caio.keyboard.height\")&&(e.setting.set(\"keyboard.previewAndHeight\",$cache.get(\"caio.keyboard.height\")),$cache.remove(\"caio.keyboard.height\"))}(e)),t<2&&(e.print(`compatibility: userVersion [${t}] lower than [2], start action`),await async function(e){i(e,[\"scripts/storage.js\",\"scripts/ui/clips-data.js\",\"scripts/ui/components/action-manager-data.js\"]),r(e,\"pin\",\"favorite\"),await s(e,{uncategorized:[\"ExportAllContent\"]})}(e))}catch(t){throw e.error(t),t}$cache.set(\"compatibility.version\",2)}})),parcelRequire.register(\"9RsVy\",(function(e,t){var i=parcelRequire(\"gxpqj\"),r=i.Kernel,s=i.UIKit,a=parcelRequire(\"2aNLD\"),n=parcelRequire(\"ilpYs\");let o;function l(){o.setting.method.exportClipboard=e=>{e.actionStart(),o.storage.export((t=>{t?e.actionDone():e.actionCancel()}))},o.setting.method.importClipboard=e=>{e.actionStart(),$ui.alert({title:$l10n(\"ALERT_INFO\"),message:$l10n(\"OVERWRITE_ALERT\"),actions:[{title:$l10n(\"OK\"),handler:()=>{$drive.open({handler:t=>{void 0!==t?\"db\"===t.fileName.slice(-2)||\"zip\"===t.fileName.slice(-3)?o.storage.import(t).then((()=>{e.actionDone(),$delay(.3,(()=>{$addin.restart()}))})).catch((t=>{$ui.error(t),o.print(t),e.actionCancel()})):($ui.warning($l10n(\"FILE_TYPE_ERROR\")),e.actionCancel()):e.actionCancel()}})}},{title:$l10n(\"CANCEL\"),handler:()=>e.actionCancel()}]})},o.setting.method.rebuildDatabase=e=>{e.actionStart();$ui.alert({title:$l10n(\"REBUILD_DATABASE_ALERT\"),actions:[{title:$l10n(\"REBUILD\"),style:$alertActionType.destructive,handler:()=>{(()=>{try{o.storage.rebuild(),e.actionDone(),$delay(.8,(()=>$addin.restart()))}catch(t){e.actionCancel(),$ui.alert(t)}})()}},{title:$l10n(\"CANCEL\"),handler:()=>{e.actionCancel()}}]})},o.setting.method.deleteAllData=e=>{e.actionStart(),$ui.alert({title:$l10n(\"DELETE_ALL_DATA_ALERT\"),actions:[{title:$l10n(\"DELETE\"),style:$alertActionType.destructive,handler:()=>{o.storage.deleteAllData(),e.actionDone(),$delay(.5,(()=>$addin.restart()))}},{title:$l10n(\"CANCEL\"),handler:()=>{e.actionCancel()}}]})}}e.exports=function(e){o=e,o.setting.method.checkUpdate=async e=>{e.actionStart();const t=\"scripts/libs/easy-jsbox.js\";if($file.exists(t))try{const e=await o.checkUpdate();e&&($file.write({data:$data({string:e}),path:t}),$ui.toast(\"The framework has been updated.\"))}catch{}$http.get({url:\"https://raw.githubusercontent.com/ipuppet/CAIO/master/config.json\",handler:t=>{const i=t.data?.info.version;let s;try{s=__INFO__}catch{s=JSON.parse($file.read(\"config.json\").string).info}r.versionCompare(i,s.version)>0?$ui.alert({title:\"New Version\",message:`New version found: ${i}\\nUpdate via Github or click the button to open Erots.`,actions:[{title:$l10n(\"CANCEL\")},{title:\"Erots\",handler:()=>{$addin.run({name:\"Erots\",query:{q:\"show\",objectId:\"603e6eaaca0dd64fcef93e2d\"}})}}]}):$ui.toast(\"No need to update\"),e.actionDone()}})},o.setting.method.previewWidget=e=>{const{Widget:t}=parcelRequire(\"8Makm\"),i={};try{JSON.parse($file.read(\"widget-options.json\").string).forEach((e=>{i[e.name]=e.value}))}catch(e){return void $ui.error(e)}$ui.menu({items:Object.keys(i),handler:e=>{t.render(i[e])}})},o.setting.method.fileManager=()=>{o.fileManager.push(\"storage\")},l(),o.setting.method.exportAction=e=>{e.actionStart();const t=\"actions.zip\",i=\"/actions.zip\",r=o.fileStorage.filePath(i);$archiver.zip({directory:o.actionManager.userActionPath,dest:r,handler:()=>{$share.sheet({items:[{name:t,data:$data({path:r})}],handler:t=>{t?e.actionDone():e.actionCancel(),o.fileStorage.delete(i)}})}})},o.setting.method.importAction=e=>{e.actionStart(),$drive.open({handler:t=>{if(void 0!==t)if(\"zip\"===t.fileName.slice(-3)){const i=`${o.fileStorage.basePath}/action_import`;$archiver.unzip({file:t,dest:i,handler:()=>{$file.list(i).forEach((e=>{$file.isDirectory(`${i}/${e}`)&&$file.copy({src:`${i}/${e}`,dst:`${o.actionManager.userActionPath}/${e}`})})),$file.delete(i),e.actionDone()}})}else $ui.warning($l10n(\"FILE_TYPE_ERROR\")),e.actionCancel();else e.actionCancel()}})},o.setting.method.importExampleAction=e=>{e.actionStart(),o.actionManager.importExampleAction(),e.actionDone()},o.setting.method.rebuildAction=e=>{e.actionStart(),$ui.alert({title:$l10n(\"REBUILD_ACTION_DATABASE_ALERT_TITLE\"),message:$l10n(\"REBUILD_ACTION_DATABASE_ALERT_MESSAGE\"),actions:[{title:$l10n(\"REBUILD\"),style:$alertActionType.destructive,handler:()=>{$file.delete(o.actionManager.userActionPath),$file.delete(o.actionManager.iCloudPath),e.actionDone(),$delay(.8,(()=>$addin.restart()))}},{title:$l10n(\"CANCEL\"),handler:()=>e.actionCancel()}]})},function(){const e=parcelRequire(\"7eNYp\"),t=200;o.setting.method.previewKeyboard=()=>{const i=new e(o),r=$text.uuid,s=e=>{$(r).updateLayout((t=>{t.height.equalTo(e)})),i.keyboardHeight=e},a=e=>(e-t)/200;return{views:[{type:\"label\",layout:(e,t)=>{e.top.inset(20),e.centerX.equalTo(t.super)},events:{ready:e=>e.text=i.keyboardHeight,tapped:e=>{$input.text({type:$kbType.number,text:i.keyboardHeight,handler:i=>{if(/^[0-9]+$/.test(i)){let r=Number(i);r=Math.min(r,400),r=Math.max(r,t),e.text=r,e.next.value=a(r),s(r)}else $ui.toast(\"Only integers can be entered.\")}})}}},{type:\"slider\",props:{max:1,min:0},layout:(e,t)=>{e.top.equalTo(t.prev.bottom),e.right.inset(20),e.width.equalTo(t.super).offset(-40)},events:{ready:e=>e.value=a(i.keyboardHeight),changed:e=>{const i=Math.floor(200*e.value+t);e.prev.text=i,s(i)}}},{type:\"view\",props:{id:r},views:[i.getView()],layout:(e,t)=>{e.width.equalTo(t.super),e.height.equalTo(i.keyboardHeight),e.bottom.inset(0)}}],layout:$layout.fill}},o.setting.method.setKeyboardQuickStart=()=>a.sheet()}(),o.setting.method.previewTodayWidget=e=>{e.touchHighlightStart();const t=new(parcelRequire(\"49je6\"))(o).getView();s.push({views:[t],disappeared:()=>e.touchHighlightEnd()})},o.setting.method.setTodayWidgetActions=e=>{n.sheet(o)}}})),parcelRequire.register(\"2aNLD\",(function(e,t){var i=parcelRequire(\"gxpqj\").Sheet;class r{constructor(){this.listId=\"keyboard-script-list\"}static getAddins(){const e=$cache.get(\"keyboard.addins\");return void 0===e?(this.setAddins(),[]):JSON.parse(e)}static setAddins(e=[]){e.map(((t,i)=>{null===t&&e.splice(i,1)})),$cache.set(\"keyboard.addins\",JSON.stringify(e))}getUnsetAddins(){const e=$addin.current.name,t=r.getAddins(),i=[];return $addin.list?.forEach((r=>{const s=r.displayName;-1===t.indexOf(s)&&e!==s&&i.push(s)})),i}add(){const e={type:\"list\",props:{data:this.getUnsetAddins()},events:{didSelect:(e,t,i)=>{const s=r.getAddins();s.unshift(i),r.setAddins(s),$(this.listId).insert({indexPath:$indexPath(0,0),value:i}),e.delete(t)}},layout:$layout.fill};(new i).setView(e).addNavBar({title:$l10n(\"ADD\")}).init().present()}getNavButtons(){return[{symbol:\"plus\",tapped:()=>this.add()}]}getListView(){return{type:\"list\",props:{id:this.listId,reorder:!0,data:r.getAddins(),actions:[{title:\"delete\",handler:(e,t)=>{r.setAddins(e.data)}}]},events:{reorderFinished:e=>{r.setAddins(e)}},layout:$layout.fill}}static sheet(){const e=new i,t=new r;e.setView(t.getListView()).addNavBar({title:$l10n(\"QUICK_START_SCRIPTS\"),popButton:{title:$l10n(\"CLOSE\")},rightButtons:t.getNavButtons()}),e.init().present()}}e.exports=r})),parcelRequire.register(\"ilpYs\",(function(e,t){var i=parcelRequire(\"gxpqj\").Sheet;class r{constructor(e){this.listId=\"today-action-list\",this.kernel=e}getActions(){let e=$cache.get(\"today.actions\")??[];\"string\"==typeof e&&(e=JSON.parse(e),this.setActions(e));const t={};this.kernel.actionManager.getActionTypes().forEach((e=>{this.kernel.actionManager.getActions(e).forEach((e=>{t[e.type+e.dir]=e}))}));const i=[];let r=!1;return e.forEach((e=>{const s=t[e.type+e.dir];s?i.push(s):r=!0})),r&&this.setActions(i),i}setActions(e=[]){e.map(((t,i)=>{t||e.splice(i,1)})),$cache.set(\"today.actions\",e)}getAllActions(){let e=[];return this.kernel.actionManager.getActionTypes().forEach((t=>{e=e.concat(this.kernel.actionManager.getActions(t))})),e}getUnsetActions(){const e=this.getActions().map((e=>e.name)),t=[];return this.getAllActions().forEach((i=>{const r=i.name;-1===e.indexOf(r)&&t.push(i)})),t}getListData(e){return e.map((e=>({action:{text:e.name,info:e},icon:\"icon_\"===e.icon.slice(0,5)?{icon:$icon(e.icon.slice(5,e.icon.indexOf(\".\")),$color(\"#ffffff\"))}:{image:$image(e.icon)},color:{bgcolor:this.kernel.setting.getColor(e.color)}})))}getListTemplate(){return{views:[{type:\"image\",props:{id:\"color\",cornerRadius:8,smoothCorners:!0},layout:e=>{e.top.left.inset(10),e.size.equalTo($size(30,30))}},{type:\"image\",props:{id:\"icon\",tintColor:$color(\"#ffffff\")},layout:e=>{e.top.left.inset(15),e.size.equalTo($size(20,20))}},{type:\"label\",props:{id:\"action\"},layout:(e,t)=>{e.bottom.top.inset(10),e.left.equalTo(t.prev.prev.right).offset(10),e.right.inset(10)}}]}}add(){const e={type:\"list\",props:{data:this.getListData(this.getUnsetActions()),template:this.getListTemplate(),rowHeight:50},events:{didSelect:(e,t,i)=>{const r=i.action.info,s=this.getActions();s.unshift(r),this.setActions(s),$(this.listId).insert({indexPath:$indexPath(0,0),value:this.getListData([r])[0]}),e.delete(t)}},layout:$layout.fill};(new i).setView(e).addNavBar({title:$l10n(\"ADD\"),popButton:{title:$l10n(\"CLOSE\")}}).init().present()}getNavButtons(){return[{symbol:\"plus\",tapped:()=>this.add()}]}getListView(){return{type:\"list\",props:{id:this.listId,data:this.getListData(this.getActions()),template:this.getListTemplate(),rowHeight:50,reorder:!0,actions:[{title:\"delete\",handler:(e,t)=>{this.setActions(e.data.map((e=>e.action.info)))}}]},events:{reorderFinished:e=>{const t=[];e.forEach((e=>{t.push(e.action.info)})),this.setActions(t)}},layout:$layout.fill}}static sheet(e){const t=new i,s=new r(e);t.setView(s.getListView()).addNavBar({title:$l10n(\"ACTIONS\"),popButton:{title:$l10n(\"CLOSE\")},rightButtons:s.getNavButtons()}),t.init().present()}}e.exports=r})),parcelRequire.register(\"7eNYp\",(function(e,t){var i=parcelRequire(\"eSp9Z\"),r=i.ActionData,s=i.ActionEnv,a=parcelRequire(\"gxpqj\"),n=a.UIKit,o=a.BarButtonItem,l=parcelRequire(\"imdB1\"),c=parcelRequire(\"2aNLD\");e.exports=class extends l{#ne;listId=\"keyboard-clips-list\";keyboardSwitchLockId=\"keyboard-switch-lock\";keyboardSwitchLockKey=\"caio.keyboard.switch.lock\";deleteTimer=void 0;continuousDeleteTimer=void 0;continuousDeleteDelay=.5;horizontalMargin=15;verticalMargin=10;copiedIndicatorSize=5;containerMargin=5;fontSize=14;navHeight=50;menuItemActionMaxCount=3;constructor(e){super(e),this.backgroundImage=this.kernel.setting.getImage(\"keyboard.background.image\"),this.backgroundColor=this.kernel.setting.getColor(this.kernel.setting.get(\"keyboard.background.color\")),this.backgroundColorDark=this.kernel.setting.getColor(this.kernel.setting.get(\"keyboard.background.color.dark\")),this.deleteDelay=this.kernel.setting.get(\"keyboard.deleteDelay\"),this.keyboardSetting(),\"boolean\"!=typeof $cache.get(this.keyboardSwitchLockKey)&&$cache.set(this.keyboardSwitchLockKey,!1)}get keyboardHeight(){return this.kernel.setting.get(\"keyboard.previewAndHeight\")}set keyboardHeight(e){this.kernel.setting.set(\"keyboard.previewAndHeight\",e)}getKeyboardSwitchLock(){const e=$cache.get(this.keyboardSwitchLockKey);return\"boolean\"!=typeof e&&$cache.set(this.keyboardSwitchLockKey,!0),e}switchKeyboardSwitchLock(){const e=$cache.get(this.keyboardSwitchLockKey);$cache.set(this.keyboardSwitchLockKey,!e),$(this.keyboardSwitchLockId).symbol=e?\"lock.open\":\"lock\"}listReady(){this.updateList(),this.kernel.setting.get(\"clipboard.autoSave\")&&$app.env===$env.keyboard&&(this.#ne=$timer.schedule({interval:1,handler:()=>{this.kernel.setting.get(\"clipboard.autoSave\")?this.readClipboard():this.#ne.invalidate()}}))}keyboardSetting(){if($app.env!==$env.keyboard)return;const e=$timer.schedule({interval:0,handler:()=>{$keyboard.height!==this.keyboardHeight?$keyboard.height=this.keyboardHeight:e.invalidate()}});this.kernel.setting.get(\"keyboard.showJSBoxToolbar\")||($keyboard.barHidden=!0)}keyboardTapped(e,t=!0,i=1){return(...r)=>{t&&this.kernel.setting.get(\"keyboard.tapticEngine\")&&$device.taptic(i),e(...r)}}getTopButtons(){const e=[{symbol:\"keyboard.chevron.compact.down\",tapped:this.keyboardTapped((()=>$keyboard.dismiss()))},{symbol:\"square.and.arrow.down.on.square\",tapped:this.keyboardTapped((e=>{e.start(),this.readClipboard(!0),e.done()}))},{symbol:\"bolt.circle\",tapped:this.keyboardTapped(((e,t)=>{const i=$ui.popover({sourceView:t,directions:$popoverDirection.up,size:$size(200,300),views:[this.kernel.actionManager.getActionListView((e=>{i.dismiss(),$delay(.5,(async()=>{const t=new r({env:s.keyboard,textBeforeInput:$keyboard.textBeforeInput,textAfterInput:$keyboard.textAfterInput,text:$keyboard.selectedText??await $keyboard.getAllText()});e(t)}))}))]})}))}];return{type:\"view\",views:e.map(((e,t)=>(new o).setAlign(n.align.right).setSymbol(e.symbol).setEvent(\"tapped\",e.tapped).definition)),layout:(t,i)=>{const r=new o;t.height.equalTo(i.super),t.right.inset(this.containerMargin-r.edges),t.width.equalTo(r.width*e.length+r.edges)}}}getTopBarView(){return{type:\"view\",views:[{type:\"view\",layout:$layout.fill,views:[{type:\"label\",props:{text:$l10n(\"CAIO\"),font:$font(\"bold\",20)},events:{tapped:()=>this.kernel.openInJsbox(),ready:e=>{$cache.get(\"tips.keyboard.title\")||($cache.set(\"tips.keyboard.title\",!0),$ui.popover({sourceView:e,size:$size(200,60),directions:$popoverDirection.up,views:[{type:\"label\",props:{lines:0,text:$l10n(\"CLICK_TO_OPEN_JSBOX\"),align:$align.center},layout:$layout.fillSafeArea}]}))}},layout:(e,t)=>{e.centerY.equalTo(t.super),e.left.equalTo(t.super).offset(this.containerMargin)}}].concat(this.tabView(),this.getTopButtons())}],layout:(e,t)=>{e.top.width.equalTo(t.super),e.height.equalTo(this.navHeight)}}}getButtonView(e,t){const i=$size(38,38),r=this.containerMargin;return n.blurBox({info:{align:t},smoothCorners:!0,cornerRadius:5},[{type:\"button\",props:Object.assign({symbol:e.symbol,title:e.title,id:e.id??$text.uuid,font:$font(16),bgcolor:this.backgroundImage?$color($rgba(172,176,184,.3),$rgba(71,71,73,.3)):$color(\"#ACB0B8\",\"#474749\"),tintColor:n.textColor,titleColor:n.textColor,info:{align:t}},e.menu?{menu:e.menu}:{}),events:Object.assign({},e.tapped?{tapped:e.tapped}:{},e.events),layout:$layout.fill}],((s,a)=>{if(e.title){const t=$text.sizeThatFits({text:e.title,width:n.windowSize.width,font:$font(16)}),a=Math.ceil(t.width)+2*r;s.size.equalTo($size(a,i.height))}else s.size.equalTo(i);s.centerY.equalTo(a.super),a.prev&&a.prev.info.align===t?t===n.align.right?s.right.equalTo(a.prev.left).offset(-r):s.left.equalTo(a.prev.right).offset(r):t===n.align.right?s.right.inset(r):s.left.inset(r)}))}getBottomBarView(){const e=[],t=[];return $device.hasFaceID&&!$device.isIpadPro||e.push({symbol:\"globe\",tapped:this.keyboardTapped((()=>$keyboard.next())),menu:{pullDown:!0,items:[{title:$l10n(\"SWITCH_KEYBOARD\"),handler:this.keyboardTapped((()=>$keyboard.next()))},{title:$l10n(\"OPEN_IN_JSBOX\"),handler:()=>this.kernel.openInJsbox()}]}}),this.kernel.setting.get(\"keyboard.switchAfterInsert\")&&e.push({symbol:this.getKeyboardSwitchLock()?\"lock\":\"lock.open\",id:this.keyboardSwitchLockId,tapped:this.keyboardTapped((()=>this.switchKeyboardSwitchLock()))}),e.push({symbol:\"paperplane\",menu:{pullDown:!0,asPrimary:!0,items:c.getAddins().reverse().map((e=>({title:e,handler:this.keyboardTapped((()=>$addin.run(e)))})))}}),t.push({title:$l10n(\"SEND\"),tapped:this.keyboardTapped((()=>$keyboard.send()))},{symbol:\"delete.left\",events:{touchesBegan:this.keyboardTapped((()=>{$keyboard.delete(),this.continuousDeleteTimer=$delay(this.continuousDeleteDelay,(()=>{this.deleteTimer=$timer.schedule({interval:this.deleteDelay,handler:this.keyboardTapped((()=>$keyboard.delete()),this.kernel.setting.get(\"keyboard.tapticEngineForDelete\"),0)})}))})),touchesEnded:()=>{this.deleteTimer?.invalidate(),this.continuousDeleteTimer?.cancel(),this.deleteTimer=void 0,this.continuousDeleteTimer=void 0}}}),{type:\"view\",views:[...e.map((e=>this.getButtonView(e,n.align.left))),...t.map((e=>this.getButtonView(e,n.align.right)))],layout:(e,t)=>{e.bottom.left.right.equalTo(t.super.safeArea),e.top.equalTo(t.prev.bottom)}}}menuItems(){const e=super.menuItems();return[e[0],e[2]]}getListView(){const e=super.getListView();e.layout=(e,t)=>{e.top.equalTo(this.navHeight),e.width.equalTo(t.super),e.bottom.equalTo(t.super.safeAreaBottom).offset(-this.navHeight)};const t=e.views[0];t.events.didSelect=(e,t)=>{const i=this.clips[t.row],r=this.kernel.storage.keyToPath(i.text);r&&this.kernel.fileStorage.exists(r.original)?$quicklook.open({image:this.kernel.fileStorage.readSync(r.original)?.image}):($keyboard.insert(i.text),this.kernel.setting.get(\"keyboard.switchAfterInsert\")&&!this.getKeyboardSwitchLock()&&$keyboard.next())},t.props.separatorInset=$insets(0,this.horizontalMargin,0,this.horizontalMargin);const i=n.blurBox({style:$blurStyle.ultraThinMaterial,smoothCorners:!0,cornerRadius:2*this.containerMargin},[t],((e,t)=>{e.bottom.top.equalTo(t.super),e.left.right.inset(this.containerMargin)}));return e.views[0]=i,e}getView(){return{type:\"view\",props:{id:\"keyboard.main\",bgcolor:$color(this.backgroundColor,this.backgroundColorDark)},views:[{type:\"image\",props:{image:this.backgroundImage,hidden:null===this.backgroundImage},layout:$layout.fill},this.getTopBarView(),this.getListView(),this.getBottomBarView()],layout:$layout.fill}}}})),parcelRequire.register(\"49je6\",(function(e,t){var i=parcelRequire(\"eSp9Z\"),r=i.ActionData,s=i.ActionEnv,a=parcelRequire(\"gxpqj\"),n=a.View,o=a.UIKit,l=a.BarButtonItem,c=a.NavigationBarItems,h=a.NavigationBar,d=parcelRequire(\"imdB1\"),p=parcelRequire(\"ilpYs\");e.exports=class extends d{tabLeftMargin=8;horizontalMargin=15;verticalMargin=10;copiedIndicatorSize=5;fontSize=14;navHeight=38;taptic=1;tagFontSize=10;tagContainerHeight=12;matrixItemHeight=50;inLauncher=$app.env===$env.today&&-1===$app.widgetIndex;launcherNavHeight=44;constructor(e){super(e),this.actionsId=\"today-list-actions\",this.listContainerId=\"today-list-container\",this.readClipboardButtonId=\"today-nav-readClipboard\",this.listId=\"today-list\",this.tabItems.push($l10n(\"ACTIONS\")),this.navigationBarItems=new c,this.bottomBar=new h,this.bottomBar.navigationBarItems=this.navigationBarItems,this.todayActions=new p(this.kernel),this.setClipboarPageSize($widget.mode),this.listPageNow=[0,0],this.listSection=Math.min(this.tabIndex,1),this.setSingleLine()}get isActionPage(){return 2===this.tabIndex}set tabIndex(e){$cache.set(\"caio.today.tab.index\",e)}get tabIndex(){return $cache.get(\"caio.today.tab.index\")??0}listReady(){$widget.modeChanged=e=>{this.setClipboarPageSize(e),this.updateList()},this.setClipboarPageSize($widget.mode),this.updateList(!0),this.appListen(),$delay(.5,(()=>this.readClipboard()))}readClipboard(e=!1){return!this.isActionPage&&$app.env===$env.today&&(super.readClipboard(e),!0)}setClipboarPageSize(e){if(0===e)this.listPageSize=1;else{const e=(($app.env===$env.app?o.windowSize.height:$widget.height)-2*this.navHeight-(this.inLauncher?this.launcherNavHeight:0))/(this.singleLineHeight+2*this.verticalMargin),t=Math.floor(e);this.listPageSize=t,e-t>=.6&&this.listPageSize++}}buttonTapped(e,t=!0){return(...i)=>{t&&this.kernel.setting.get(\"keyboard.tapticEngine\")&&$device.taptic(this.taptic),e(...i)}}navButtons(){return[{symbol:\"square.and.arrow.down.on.square\",props:{id:this.readClipboardButtonId,hidden:this.isActionPage},tapped:this.buttonTapped((e=>{e.start(),this.readClipboard(!0)?e.done():e.cancel()}))}].map((e=>{const t=new l;return t.setAlign(o.align.right).setSymbol(e.symbol).setEvent(\"tapped\",e.tapped).setProps(e.props??{}),t.definition}))}switchTab(e){this.tabIndex=e,2===e?($(this.listContainerId).hidden=!0,$(this.actionsId).hidden=!1,$(this.readClipboardButtonId).hidden=!0):(this.listSection=e,$(this.actionsId).hidden=!0,$(this.listContainerId).hidden=!1,$(this.readClipboardButtonId).hidden=!1,this.updateList())}getNavBarView(){return{type:\"view\",views:[{type:\"view\",layout:$layout.fill,views:[this.tabView(),{type:\"label\"},...this.navButtons()]}],layout:(e,t)=>{e.top.width.equalTo(t.super),e.height.equalTo(this.navHeight)}}}getBottomBarView(){this.navigationBarItems.setLeftButtons([{symbol:\"chevron.backward.circle\",tapped:this.buttonTapped((()=>{this.clipboardPrevPage()}))}]).setRightButtons([{symbol:\"chevron.forward.circle\",tapped:this.buttonTapped((()=>{this.clipboardNextPage()}))}]),this.bottomBar.setTitle(this.listPageNow[this.listSection]+1).setLargeTitleDisplayMode(h.largeTitleDisplayModeNever);const e=this.bottomBar.getNavigationBarView();return e.layout=(e,t)=>{e.bottom.left.right.equalTo(t.super.safeArea),e.top.equalTo(t.prev.bottom)},e}updateList(){const e=this.listPageNow[this.listSection]*this.listPageSize,t=e+this.listPageSize;$(this.listId).data=this.allClips[this.listSection].slice(e,t).map((e=>this.lineData(e,this.copied.uuid===e.uuid))),$(this.bottomBar.id+\"-small-title\").text=this.listPageNow[this.listSection]+1}clipboardPrevPage(){this.listPageNow[this.listSection]>0&&(this.listPageNow[this.listSection]--,this.updateList())}clipboardNextPage(){const e=Math.ceil(this.allClips[this.listSection].length/this.listPageSize);this.listPageNow[this.listSection]this.listReady(),rowHeight:(e,t)=>{const i=e.object(t).tag.text?this.tagContainerHeight:this.verticalMargin;return this.singleLineHeight+this.verticalMargin+i},didSelect:this.buttonTapped(((e,t)=>{const i=this.clips[t.row],r=this.kernel.storage.keyToPath(i.text);r&&this.kernel.fileStorage.exists(r.original)?$clipboard.image=this.kernel.fileStorage.readSync(r.original).image:(this.setClipboardText(i.text),this.setCopied(i.uuid,t.row)),$ui.toast($l10n(\"COPIED\"))}))},layout:(e,t)=>{e.top.width.equalTo(t.super),e.bottom.equalTo(t.super).offset(-this.navHeight)}},this.getBottomBarView()],layout:(e,t)=>{e.top.equalTo(this.navHeight),e.bottom.left.right.equalTo(t.super.safeArea)}}}getActionView(){let e=this.todayActions.getActions();0===e.length&&(e=this.todayActions.getAllActions());const t={type:\"matrix\",props:{bgcolor:$color(\"clear\"),columns:2,itemHeight:this.matrixItemHeight,spacing:this.tabLeftMargin,data:e.map((e=>this.kernel.actionManager.actionToData(e))),template:{props:{smoothCorners:!0,cornerRadius:10,bgcolor:$color($rgba(255,255,255,.3),$rgba(0,0,0,.3))},views:[{type:\"image\",props:{id:\"color\",cornerRadius:8,smoothCorners:!0},layout:e=>{const t=this.matrixItemHeight-20;e.top.left.inset((this.matrixItemHeight-t)/2),e.size.equalTo($size(t,t))}},{type:\"image\",props:{id:\"icon\",tintColor:$color(\"#ffffff\")},layout:(e,t)=>{e.edges.equalTo(t.prev).insets(5)}},{type:\"label\",props:{id:\"name\",font:$font(14)},layout:(e,t)=>{e.bottom.top.inset(10),e.left.equalTo(t.prev.prev.right).offset(10),e.right.inset(10)}},{type:\"view\",props:{id:\"info\",hidden:!0}}]}},layout:$layout.fill,events:{didSelect:(e,t,i)=>{const a=i.info.info,n=new r({env:s.today,text:\"clipboard\"===a.type||\"uncategorized\"===a.type?$clipboard.text:null});this.kernel.actionManager.getActionHandler(a.type,a.dir)(n)}}};return{type:\"view\",props:{id:this.actionsId,hidden:2!==this.tabIndex},views:[t],layout:(e,t)=>{e.top.equalTo(this.navHeight),e.bottom.left.right.equalTo(t.super.safeArea)}}}getView(){return n.create({props:{titleColor:o.textColor,barColor:o.primaryViewBackgroundColor},views:[{type:\"view\",views:[this.getNavBarView(),this.getListView(),this.getActionView()],layout:$layout.fill}],events:{appeared:async()=>{if($app.env!==$env.today)return;const e=$timer.schedule({interval:0,handler:()=>{$ui.animate({duration:.3,animation:()=>{$ui.vc.ocValue().$view().$setBackgroundColor($color(\"clear\"))},completion:()=>{e.invalidate()}})}})}}})}}})),$app.strings={en:{ALERT_INFO:\"Alert\",NONE:\"Nothing\",DONE:\"Done\",CLOSE:\"Close\",FAILED_TO_LOAD_VIEW:\"Faild to load view\",VIEW_NOT_PROVIDED:\"The view is not provided\",UNCATEGORIZED:\"Uncategorized\",SHARE:\"Share\",CLICK_TO_OPEN_JSBOX:\"Click the title to open the main app.\",CLIPS:\"Clips\",CLIPBOARD:\"Clipboard\",UNIVERSAL_CLIPBOARD:\"Universal Clipboard\",UNIVERSAL_CLIPBOARD_TIPS:\"Universal Clipboard allows you to copy something on your iPhone, and paste it on your Mac–or vice-versa–using iCloud.\",CLIPS_STRUCTURE_ERROR:\"Clips data structure is abnormal\",CLIPBOARD_NO_CHANGE:\"Clipboard no change\",ADD:\"Add\",TAG:\"Tag\",ADD_TAG:\"Add Tag\",EDIT:\"Edit\",SEARCH:\"Search\",SEARCH_HISTORY:\"Search History\",SEARCH_RESULT:\"Search Result\",NO_SEARCH_RESULT:\"No item found.\",FAVORITE:\"Favorite\",COPY:\"Copy\",COPIED:\"Copied\",SORT:\"Sort\",ACTIONS:\"Actions\",MORE_ACTIONS:\"More Actions\",PREVIEW:\"Preview\",MAX_ITEM_LENGTH:\"Line Limit\",TEXT_MAX_LENGTH:\"Display Character Length\",AUTO_SAVE:\"Auto Save\",AUTO_SYNC:\"Auto Sync\",SYNC_NOW:\"Sync Now\",UNZIP_FAILED:\"Unzip file failed\",SYNC_ALERT_INFO:\"If it has not been synced locally, the iCloud data will be pulled directly. \\\\nDo you want to continue?\",DELETE_ICLOUD_DATA:\"Delete iCloud Data\",REBUILD:\"Rebuild\",REBUILD_DATABASE:\"Rebuild Database\",REBUILD_DATABASE_ALERT:\"Rebuilding the database will lose the order information, do you want to confirm the rebuild?\",DELETE_ALL_DATA:\"Delete All Data\",DELETE_ALL_DATA_ALERT:\"Are you sure you want to delete all your data?\",DELETE_DATA:\"Delete Data\",DELETE_TABLE:\"Delete all data from ${table}?\",SELECT_ALL:\"Select All\",DESELECT_ALL:\"Deselect All\",EDITOR:\"Editor\",CREATE_NEW:\"Create New\",CREATE_NEW_ACTION:\"New Action\",CREATE_NEW_TYPE:\"New Category\",TYPE_ALREADY_EXISTS:\"This category already exists\",EDIT_DETAILS:\"Edit Details\",EDIT_SCRIPT:\"Edit Script\",INFORMATION:\"Information\",NAME:\"Name\",ICON:\"Icon\",TYPE:\"Category\",DESCRIPTION:\"Description\",CODE:\"Code\",TEXT_INSETS:\"Text bottom margin\",SHOW_LINE_NUMBER:\"Show line number\",LIGHT_MODE_THEME:\"Light Mode Theme\",DARK_MODE_THEME:\"Dark Mode Theme\",SAVE:\"Save\",SAVE_SUCCESS:\"Save success\",SAVE_ERROR:\"Save failed\",DELETE:\"Delete\",CONFIRM_DELETE_TITLE:\"Delete Confirmation\",CONFIRM_DELETE_MSG:\"Are you sure you want to delete?\",DELETE_SUCCESS:\"Delete success\",DELETE_ERROR:\"Delete failed\",IMPORT_EXAMPLE_ACTIONS:\"Import example actions\",REBUILD_ACTION_DATABASE:\"Rebuild Action Database\",REBUILD_ACTION_DATABASE_ALERT_TITLE:\"Are you sure you want to rebuild?\",REBUILD_ACTION_DATABASE_ALERT_MESSAGE:\"Rebuild also deletes the data saved in iCloud Drive!\",EXPORT:\"Export\",IMPORT:\"Import\",FILE_TYPE_ERROR:\"File type does not match\",OVERWRITE_ALERT:\"This operation will overwrite the current data. Do you want to continue?\",KEYBOARD:\"Keyboard\",KEYBOARD_HEIGHT:\"Keyboard Height\",BACKGROUND_COLOR:\"Background Color\",BACKGROUND_COLOR_DARK:\"Dark Background Color\",BACKGROUND_IMAGE:\"Background Image\",DELETE_DELAY:\"Delete Delay\",SWITCH_AFTER_INSERT:\"Switch After Insert\",JSBOX_TOOLBAR:\"JSBox Toolbar\",QUICK_START_SCRIPTS:\"Quick Start Scripts\",SEND:\"Send\",OPEN_IN_JSBOX:\"Open in JSBox\",SWITCH_KEYBOARD:\"Switch Keyboard\",TAPTIC_ENGINE:\"Taptic Engine\",TAPTIC_ENGINE_FOR_DELETE:\"Taptic Engine For Delete\",CHECK_UPDATE:\"Check Update\",UPDATE:\"Update\",WIDGET:\"Widget\",RECENT:\"Recent\",CLICK_ACTION:\"Click Action\",TODAY_WIDGET:\"Today Widget\",PREV_PAGE:\"Prev\",NEXT_PAGE:\"Next\",DISPLAY_MODE:\"Display Mode\",CLASSIC:\"Classic\",MODERN:\"Modern\",FILE_MANAGEMENT:\"File Management\",\"compatibility.rebuildUserAction.alert.title\":\"We need to rebuild some of the action!\",\"compatibility.rebuildUserAction.alert.message\":\"If you tap the OK button, the following actions will be rebuilt:\",\"compatibility.rebuildUserAction.alert.message2\":\"Only the action logic will be changed, and the name and icon will remain as it is.\",EXPERIMENTAL:\"Experimental\",SYNC_ACTIONS:\"Sync Actions\",SYNCING:\"Syncing...\",LAST_SYNC_AT:\"Last sync at: \"},\"zh-Hans\":{ALERT_INFO:\"提示\",NONE:\"什么都没有\",DONE:\"完成\",CLOSE:\"关闭\",FAILED_TO_LOAD_VIEW:\"加载视图失败\",VIEW_NOT_PROVIDED:\"未提供该视图\",UNCATEGORIZED:\"未分类\",SHARE:\"分享\",CLICK_TO_OPEN_JSBOX:\"点击标题打开主应用。\",CLIPS:\"剪切板\",CLIPBOARD:\"剪切板\",UNIVERSAL_CLIPBOARD:\"通用剪贴板\",UNIVERSAL_CLIPBOARD_TIPS:\"用剪贴板允许您在iPhone上复制某些内容,然后使用iCloud将其粘贴到Mac上(反之亦然)。\",CLIPS_STRUCTURE_ERROR:\"剪切板数据结构异常\",CLIPBOARD_NO_CHANGE:\"剪切板无变化\",ADD:\"添加\",TAG:\"标签\",ADD_TAG:\"添加标签\",EDIT:\"编辑\",SEARCH:\"搜索\",SEARCH_HISTORY:\"搜索历史\",SEARCH_RESULT:\"搜索结果\",NO_SEARCH_RESULT:\"搜索无结果\",FAVORITE:\"收藏\",COPY:\"复制\",COPIED:\"已复制\",SORT:\"排序\",ACTIONS:\"动作\",MORE_ACTIONS:\"更多动作\",PREVIEW:\"预览\",MAX_ITEM_LENGTH:\"行数限制\",TEXT_MAX_LENGTH:\"显示字符长度\",AUTO_SAVE:\"自动保存\",AUTO_SYNC:\"自动同步\",SYNC_NOW:\"立即同步\",UNZIP_FAILED:\"解压文件失败\",SYNC_ALERT_INFO:\"若未在本机进行过同步则会直接拉取 iCloud 数据。\\\\n是否继续?\",DELETE_ICLOUD_DATA:\"删除 iCloud 数据\",REBUILD:\"重建\",REBUILD_DATABASE:\"重建数据库\",REBUILD_DATABASE_ALERT:\"重建数据库将会丢失顺序信息,是否确认重建?\",DELETE_ALL_DATA:\"删除所有数据\",DELETE_ALL_DATA_ALERT:\"确定要删除所有数据吗?\",DELETE_DATA:\"删除数据\",DELETE_TABLE:\"删除${table}的所有数据?\",SELECT_ALL:\"全选\",DESELECT_ALL:\"取消全选\",EDITOR:\"编辑器\",CREATE_NEW:\"新建\",CREATE_NEW_ACTION:\"新建动作\",CREATE_NEW_TYPE:\"新建分类\",TYPE_ALREADY_EXISTS:\"该类别已经存在\",EDIT_DETAILS:\"编辑信息\",EDIT_SCRIPT:\"编辑脚本\",INFORMATION:\"信息\",NAME:\"名称\",ICON:\"图标\",TYPE:\"分类\",DESCRIPTION:\"描述\",CODE:\"代码\",TEXT_INSETS:\"文本下边距\",SHOW_LINE_NUMBER:\"显示行号\",LIGHT_MODE_THEME:\"浅色模式主题\",DARK_MODE_THEME:\"深色模式主题\",SAVE:\"保存\",SAVE_SUCCESS:\"保存成功\",SAVE_ERROR:\"保存失败\",DELETE:\"删除\",CONFIRM_DELETE_TITLE:\"删除前确认\",CONFIRM_DELETE_MSG:\"确认要删除吗?\",DELETE_SUCCESS:\"删除成功\",DELETE_ERROR:\"删除失败\",IMPORT_EXAMPLE_ACTIONS:\"导入示例动作\",REBUILD_ACTION_DATABASE:\"重建动作库\",REBUILD_ACTION_DATABASE_ALERT_TITLE:\"您确认要重建?\",REBUILD_ACTION_DATABASE_ALERT_MESSAGE:\"重建会同时删除保存在 iCloud 云盘中的数据!\",EXPORT:\"导出\",IMPORT:\"导入\",FILE_TYPE_ERROR:\"文件类型不符\",OVERWRITE_ALERT:\"该操作将会覆盖当前数据,是否继续?\",KEYBOARD:\"键盘\",KEYBOARD_HEIGHT:\"键盘高度\",BACKGROUND_COLOR:\"背景色\",BACKGROUND_COLOR_DARK:\"深色模式背景色\",BACKGROUND_IMAGE:\"背景图片\",DELETE_DELAY:\"删除延时\",SWITCH_AFTER_INSERT:\"输入后切换\",JSBOX_TOOLBAR:\"JSBox 工具栏\",QUICK_START_SCRIPTS:\"快速启动脚本\",SEND:\"发送\",OPEN_IN_JSBOX:\"在 JSBox 中打开\",SWITCH_KEYBOARD:\"切换键盘\",TAPTIC_ENGINE:\"触感反馈\",TAPTIC_ENGINE_FOR_DELETE:\"删除按钮触感反馈\",CHECK_UPDATE:\"检查更新\",UPDATE:\"更新\",WIDGET:\"小组件\",RECENT:\"最近内容\",CLICK_ACTION:\"点击事件\",TODAY_WIDGET:\"通知中心小组件\",PREV_PAGE:\"上一页\",NEXT_PAGE:\"下一页\",DISPLAY_MODE:\"显示模式\",CLASSIC:\"经典\",MODERN:\"现代\",FILE_MANAGEMENT:\"文件管理\",\"compatibility.rebuildUserAction.alert.title\":\"我们需要重建部分动作!\",\"compatibility.rebuildUserAction.alert.message\":\"如果您点击 好,以下动作将会被重建:\",\"compatibility.rebuildUserAction.alert.message2\":\"只有动作逻辑会被更改,名称和图标将维持现状。\",EXPERIMENTAL:\"实验功能\",SYNC_ACTIONS:\"动作同步\",SYNCING:\"正在同步...\",LAST_SYNC_AT:\"最后同步:\"}},$app.theme=\"auto\",$app.minSDKVer=\"2.19.0\",$app.minOSVer=\"14.0.0\",$app.idleTimerDisabled=!1,$app.keyboardToolbarEnabled=!0,$app.rotateDisabled=!1,__INFO__={name:\"CAIO\",version:\"1.8.2\",author:\"ipuppet\",module:!1},__README__={\"README.md\":\"# CAIO\\r\\n\\r\\n> Clipboard all in one.\\r\\n> \\r\\n> A Clipboard tool based on JSBox.\\r\\n\\r\\nSupport for home widget and notification center widgets.\\r\\n\\r\\n## Build Taio Action\\r\\n\\r\\nBuild script depend on [Parcel](https://parceljs.org/).\\r\\n\\r\\n```shell\\r\\nnpm i -g parcel\\r\\nnpm run build\\r\\n```\\r\\n\\r\\nYou can also use the packaged files directly [dist/CAIO-en.json](./dist/CAIO-en.json).\\r\\n\\r\\n## Actions\\r\\n\\r\\n> For details on how to write, see `scripts/action/README.md` or the book button in the upper right corner of the `Action` edit page in the app.\\r\\n\\r\\n### `Action` data difference in different environments\\r\\n\\r\\n- The data processed by the `Action` button at the top of the home page is the currently copied content.\\r\\n- The data processed by the `Action` menu that pops up by long-pressing the list is the selected content.\\r\\n- The data processed by the `Action` button in the editor is whatever is being edited.\\r\\n\\r\\n\\r\\n## Today Widget\\r\\n\\r\\n> Click to copy, long press to trigger the action.\\r\\n\\r\\nPlease try to avoid using the Today Widget when JSBox is running CAIO.\",\"README_CN.md\":\"# CAIO\\r\\n\\r\\n> Clipboard all in one.\\r\\n> \\r\\n> A Clipboard tool based on JSBox.\\r\\n\\r\\n支持桌面小组件和通知中心小组件\\r\\n\\r\\n## 构建 Taio 动作\\r\\n\\r\\n构建脚本依赖 [Parcel](https://parceljs.org/)\\r\\n\\r\\n```shell\\r\\nnpm i -g parcel\\r\\nnpm run build\\r\\n```\\r\\n\\r\\n您也可以直接使用已打包好的文件 [dist/CAIO-zh-Hans.json](./dist/CAIO-zh-Hans.json)\\r\\n\\r\\n## Actions\\r\\n\\r\\n> 编写方式详见 `scripts/action/README.md` 或应用内 `Action` 编辑页面右上角图书按钮。\\r\\n\\r\\n### 不同环境中 `Action` 数据区别\\r\\n\\r\\n- 首页顶部 `Action` 按钮处理的数据为当前复制的内容\\r\\n- 长按列表弹出的 `Action` 菜单处理的数据为被选中的内容\\r\\n- 编辑器中顶部 `Action` 按钮(闪电图形按钮)处理的数据为正在编辑的所有内容\\r\\n\\r\\n\\r\\n## Today Widget\\r\\n\\r\\n> 点击复制,长按触发动作。\\r\\n\\r\\n请尽量避免在 JSBox 运行 CAIO 时使用 Today Widget\"},__SETTING__=[{items:[{icon:[\"doc.on.clipboard\",\"#FFCC66\"],type:\"child\",title:\"CLIPS\",key:\"clipboard\",children:[{items:[{icon:[\"link\",\"#FF6633\"],title:\"UNIVERSAL_CLIPBOARD\",type:\"switch\",key:\"clipboard.universal\",value:!0},{icon:[\"cursorarrow.rays\",\"#FF6633\"],title:\"Tips\",type:\"script\",key:\"clipboard.tips.universal\",value:\"$ui.alert({title:$l10n('UNIVERSAL_CLIPBOARD'),message:$l10n('UNIVERSAL_CLIPBOARD_TIPS')})\"}]},{items:[{icon:[\"text.alignleft\",\"#FFCC66\"],title:\"MAX_ITEM_LENGTH\",type:\"number\",key:\"clipboard.maxItemLength\",value:100},{icon:[\"square.and.arrow.down.on.square\",\"#FF6633\"],title:\"AUTO_SAVE\",type:\"switch\",key:\"clipboard.autoSave\",value:!0}]},{items:[{icon:[\"square.and.arrow.up\"],title:\"EXPORT\",type:\"script\",key:\"clipboard.export\",value:\"this.method.exportClipboard\"},{icon:[\"square.and.arrow.down\",\"#FFCC33\"],title:\"IMPORT\",type:\"script\",key:\"clipboard.import\",value:\"this.method.importClipboard\"}]},{items:[{icon:[\"arrow.2.circlepath\",\"red\"],title:\"REBUILD_DATABASE\",type:\"script\",key:\"clipboard.rebuildDatabase\",value:\"this.method.rebuildDatabase\"},{icon:[\"trash\",\"red\"],title:\"DELETE_ALL_DATA\",type:\"script\",key:\"clipboard.deleteAllData\",value:\"this.method.deleteAllData\"}]}]},{icon:[\"bolt.circle\",\"#FF6633\"],type:\"child\",title:\"ACTIONS\",key:\"action\",children:[{items:[{icon:[\"bolt.circle\",\"#FF6633\"],title:\"IMPORT_EXAMPLE_ACTIONS\",type:\"script\",key:\"action.importExampleAction\",value:\"this.method.importExampleAction\"}]},{items:[{icon:[\"square.and.arrow.up\"],title:\"EXPORT\",type:\"script\",key:\"action.export\",value:\"this.method.exportAction\"},{icon:[\"square.and.arrow.down\",\"#FFCC33\"],title:\"IMPORT\",type:\"script\",key:\"action.import\",value:\"this.method.importAction\"}]},{items:[{icon:[\"arrow.2.circlepath\",\"red\"],title:\"REBUILD_ACTION_DATABASE\",type:\"script\",key:\"action.rebuildAction\",value:\"this.method.rebuildAction\"}]}]},{icon:[\"pencil.circle\",\"#CC0099\"],type:\"child\",title:\"EDITOR\",key:\"editor\",children:[{title:\"CLIPS\",items:[{icon:[\"wand.and.stars\",\"#FF6633\"],title:\"TEXT_INSETS\",type:\"number\",key:\"editor.text.insets\",value:300}]},{title:\"CODE\",items:[{icon:[\"list.number\",\"#6699CC\"],title:\"SHOW_LINE_NUMBER\",type:\"switch\",key:\"editor.code.lineNumbers\",value:!1},{icon:[\"wand.and.stars\",\"#FF6633\"],title:\"LIGHT_MODE_THEME\",type:\"input\",key:\"editor.code.lightTheme\",value:\"atom-one-light\"},{icon:[\"wand.and.stars\",\"#FF6633\"],title:\"DARK_MODE_THEME\",type:\"input\",key:\"editor.code.darkTheme\",value:\"atom-one-dark\"}]}]},{icon:[\"keyboard\",\"#a2a5a6\"],type:\"child\",title:\"KEYBOARD\",key:\"keyboard\",children:[{items:[{icon:[\"rectangle.3.offgrid.fill\"],title:\"PREVIEW\",type:\"push\",key:\"keyboard.previewAndHeight\",view:\"this.method.previewKeyboard\",value:267}]},{items:[{icon:[\"sun.min\",\"#A569BD\"],title:\"BACKGROUND_COLOR\",type:\"color\",key:\"keyboard.background.color\",value:\"#D1D3D9\"},{icon:[\"sun.min\",\"#A569BD\"],title:\"BACKGROUND_COLOR_DARK\",type:\"color\",key:\"keyboard.background.color.dark\",value:\"#313131\"},{icon:[\"photo\",\"#FFCC66\"],title:\"BACKGROUND_IMAGE\",type:\"image\",key:\"keyboard.background.image\"}]},{items:[{icon:[\"globe\",\"#1899c4\"],title:\"SWITCH_AFTER_INSERT\",type:\"switch\",key:\"keyboard.switchAfterInsert\",value:!1},{icon:[\"cursor.rays\",\"#FF8C00\"],title:\"TAPTIC_ENGINE\",type:\"switch\",key:\"keyboard.tapticEngine\",value:!0},{icon:[\"option\",\"#157EFB\"],title:\"JSBOX_TOOLBAR\",type:\"switch\",key:\"keyboard.showJSBoxToolbar\",value:!1},{icon:[\"paperplane\"],title:\"QUICK_START_SCRIPTS\",type:\"script\",key:\"keyboard.setKeyboardQuickStart\",value:\"this.method.setKeyboardQuickStart\"}]},{items:[{icon:[\"cursor.rays\",\"#FF8C00\"],title:\"TAPTIC_ENGINE_FOR_DELETE\",type:\"switch\",key:\"keyboard.tapticEngineForDelete\",value:!0},{icon:[\"rays\",\"#FFCC33\"],title:\"DELETE_DELAY\",type:\"number\",key:\"keyboard.deleteDelay\",value:.05}]}]},{icon:[\"rectangle.3.offgrid.fill\",\"#1899c4\"],type:\"child\",title:\"WIDGET\",key:\"widget\",children:[{items:[{icon:[\"rectangle.3.offgrid.fill\"],title:\"PREVIEW\",type:\"script\",key:\"previewWidget\",value:\"this.method.previewWidget\"}]},{title:\"2x2\",items:[{icon:[\"link\"],title:\"CLICK_ACTION\",type:\"menu\",key:\"widget.2x2.widgetURL\",items:[\"ADD\",\"ACTIONS\",\"CLIPS\"],value:2}]}]},{icon:[\"filemenu.and.selection\",\"#ebcc34\"],type:\"child\",title:\"TODAY_WIDGET\",key:\"todayWidget\",children:[{items:[{icon:[\"rectangle.3.offgrid.fill\"],title:\"PREVIEW\",type:\"script\",key:\"todayWidget.preview\",value:\"this.method.previewTodayWidget\"}]},{items:[{icon:[\"bolt.circle\"],title:\"ACTIONS\",type:\"script\",key:\"todayWidget.setTodayWidgetActions\",value:\"this.method.setTodayWidgetActions\"}]}]}]},{items:[{icon:[\"rectangle.topthird.inset.filled\",\"#A569BD\"],title:\"DISPLAY_MODE\",type:\"tab\",key:\"mainUIDisplayMode\",items:[\"CLASSIC\",\"MODERN\"],value:0},{icon:[\"folder.fill\",\"#FF9900\"],title:\"FILE_MANAGEMENT\",type:\"script\",key:\"fileManager\",value:\"this.method.fileManager\"}]},{items:[{icon:[\"wrench.and.screwdriver\"],title:\"EXPERIMENTAL\",type:\"child\",key:\"EXPERIMENTAL\",children:[{items:[{icon:[\"bolt.circle\"],title:\"SYNC_ACTIONS\",type:\"switch\",key:\"experimental.syncAction\",value:!1}]}]}]},{items:[{icon:[\"/assets/icon/github.com.jpeg\",\"white\"],title:\"Github\",type:\"info\",key:\"github\",value:[\"ipuppet/CAIO\",\"https://github.com/ipuppet/CAIO\"]},{icon:[\"/assets/icon/telegram.png\",\"white\"],title:\"Telegram\",type:\"info\",key:\"telegram\",value:[\"JSBoxTG\",\"https://t.me/JSBoxTG\"]},{icon:[\"person.fill\",\"#FF9900\"],title:\"AUTHOR\",type:\"info\",key:\"author\",value:[\"ipuppet\",\"https://blog.ultagic.com\"]},{icon:[\"arrow.2.circlepath\"],title:\"CHECK_UPDATE\",type:\"script\",key:\"checkUpdate\",value:\"this.method.checkUpdate\"},{icon:[\"book.fill\",\"#A569BD\"],title:\"README\",type:\"script\",key:\"readme\",value:\"this.method.readme\"}]}],__ACTIONS__={clipboard:{B23Clean:{\"config.json\":'{\\r\\n \"icon\": \"trash\",\\r\\n \"color\": \"#FF0000\",\\r\\n \"name\": \"b23 清除追踪\"\\r\\n}',\"main.js\":'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n */\\r\\nclass MyAction extends Action {\\r\\n l10n() {\\r\\n return {\\r\\n \"zh-Hans\": {\\r\\n \"b23clean.converting\": \"正在转换...\",\\r\\n \"b23clean.noUrl\": \"未检测到链接\",\\r\\n \"b23clean.noBiliUrl\": \"未检测到 bilibili 链接\",\\r\\n \"b23clean.success\": \"已转换为 BV 视频链接\",\\r\\n \"b23clean.noChange\": \"无变化\",\\r\\n \"b23clean.multipleLinks\": \"多条链接仅在编辑模式下可用。\"\\r\\n },\\r\\n en: {\\r\\n \"b23clean.converting\": \"Converting...\",\\r\\n \"b23clean.noUrl\": \"No link detected\",\\r\\n \"b23clean.noBiliUrl\": \"bilibili link not detected\",\\r\\n \"b23clean.success\": \"Converted to BV video link\",\\r\\n \"b23clean.noChange\": \"No change\",\\r\\n \"b23clean.multipleLinks\": \"Multiple links are only available in edit mode.\"\\r\\n }\\r\\n }\\r\\n }\\r\\n\\r\\n async cleanUrl(b23url) {\\r\\n if (b23url.indexOf(\"bilibili.com\") === -1 && b23url.indexOf(\"b23.tv\") === -1) {\\r\\n throw new Error($l10n(\"b23clean.noBiliUrl\"))\\r\\n }\\r\\n\\r\\n let url = b23url\\r\\n if (b23url.indexOf(\"b23.tv\") >= 0) {\\r\\n const resp = await $http.get(b23url)\\r\\n url = resp.response.url\\r\\n }\\r\\n\\r\\n const queryStart = url.indexOf(\"?\")\\r\\n if (queryStart > -1) {\\r\\n url = url.substring(0, queryStart - 1)\\r\\n }\\r\\n\\r\\n return url\\r\\n }\\r\\n\\r\\n /**\\r\\n * 系统会调用 do() 方法\\r\\n */\\r\\n async do() {\\r\\n $ui.toast($l10n(\"b23clean.converting\"), 1000)\\r\\n\\r\\n try {\\r\\n const b23url = this.getUrls()\\r\\n if (b23url.length === 0) {\\r\\n throw new Error($l10n(\"b23clean.noUrl\"))\\r\\n }\\r\\n\\r\\n if (b23url.length === 1) {\\r\\n let url = await this.cleanUrl(b23url[0])\\r\\n $ui.clearToast()\\r\\n $ui.alert({\\r\\n title: $l10n(\"b23clean.success\"),\\r\\n message: url,\\r\\n actions: [\\r\\n { title: $l10n(\"OK\") },\\r\\n {\\r\\n title: $l10n(\"COPY\"),\\r\\n handler: () => {\\r\\n $clipboard.text = url\\r\\n $ui.success($l10n(\"COPIED\"))\\r\\n }\\r\\n }\\r\\n ]\\r\\n })\\r\\n } else {\\r\\n if (this.env !== ActionEnv.editor) {\\r\\n $ui.toast($l10n(\"b23clean.multipleLinks\"))\\r\\n return\\r\\n }\\r\\n let flag = false\\r\\n for (let i = 0; i < b23url.length; i++) {\\r\\n try {\\r\\n const url = b23url[i].trim()\\r\\n const replacedUrl = await this.cleanUrl(url)\\r\\n flag = true\\r\\n\\r\\n if (url !== replacedUrl) {\\r\\n const newText = this.text.replace(url, replacedUrl)\\r\\n this.setContent(newText)\\r\\n }\\r\\n } catch {}\\r\\n }\\r\\n if (!flag) {\\r\\n throw new Error($l10n(\"b23clean.noBiliUrl\"))\\r\\n } else {\\r\\n $ui.toast($l10n(\"b23clean.noChange\"))\\r\\n }\\r\\n }\\r\\n } catch (error) {\\r\\n $ui.clearToast()\\r\\n $delay(0.5, () => $ui.error(error))\\r\\n }\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## B23Clean\\r\\n\\r\\n清除 b23.tv 分享链接中的追踪参数,转换为 BV 视频链接。\"},CleanClipboard:{\"config.json\":'{\\r\\n \"icon\": \"trash\",\\r\\n \"color\": \"#FF0000\",\\r\\n \"name\": \"清除剪切板\"\\r\\n}',\"main.js\":'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n */\\r\\nclass MyAction extends Action {\\r\\n l10n() {\\r\\n return {\\r\\n \"zh-Hans\": {\\r\\n \"clipboard.clean.success\": \"剪切板已清空\"\\r\\n },\\r\\n en: {\\r\\n \"clipboard.clean.success\": \"Clipboard is cleaned\"\\r\\n }\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * 系统会调用 do() 方法\\r\\n */\\r\\n do() {\\r\\n $clipboard.clear()\\r\\n $ui.success($l10n(\"clipboard.clean.success\"))\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## CleanClipboard\\r\\n\\r\\n清空当前剪切板内容。\"},DownloadFromUrl:{\"config.json\":'{\\r\\n \"icon\": \"square.and.arrow.down\",\\r\\n \"color\": \"#FF0099\",\\r\\n \"name\": \"从链接下载\"\\r\\n}',\"main.js\":'class MyAction extends Action {\\r\\n async downloadContent(url) {\\r\\n const response = await $http.get({\\r\\n url,\\r\\n showsProgress: true\\r\\n })\\r\\n if (response.error) {\\r\\n $ui.alert(response.error.localizedDescription)\\r\\n } else {\\r\\n return response\\r\\n }\\r\\n }\\r\\n\\r\\n async do() {\\r\\n const url = this.getUrls()\\r\\n let response = undefined\\r\\n if (url.length > 1) {\\r\\n $ui.menu({\\r\\n items: url,\\r\\n handler: async (title, index) => {\\r\\n response = await this.downloadContent(url[index])\\r\\n }\\r\\n })\\r\\n } else if (url.length === 1) {\\r\\n response = await this.downloadContent(url[0])\\r\\n } else {\\r\\n $ui.warning(\"未检测到链接\")\\r\\n return\\r\\n }\\r\\n $share.sheet([\\r\\n {\\r\\n name: response.response.suggestedFilename,\\r\\n data: response.data\\r\\n }\\r\\n ])\\r\\n return response\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## DownloadFromUrl\\r\\n\\r\\n从链接下载内容,如 js 文件内容等。\"},GetFromWin:{\"config.json\":'{\\r\\n \"icon\": \"square.and.arrow.down\",\\r\\n \"color\": \"#33CC33\",\\r\\n \"name\": \"读取 clipsync\"\\r\\n}',\"main.js\":'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n */\\r\\nclass MyAction extends Action {\\r\\n async getIp(refresh = false) {\\r\\n let address = $cache.get(\"caio.action.clipsync.address\")\\r\\n if (refresh || !address) {\\r\\n address = await $input.text({\\r\\n placeholder: \"Address\",\\r\\n text: $cache.get(\"caio.action.clipsync.address\")\\r\\n })\\r\\n }\\r\\n\\r\\n $cache.set(\"caio.action.clipsync.address\", address)\\r\\n\\r\\n if (!address.startsWith(\"http\")) {\\r\\n address = \"http://\" + address\\r\\n }\\r\\n\\r\\n return address\\r\\n }\\r\\n\\r\\n async do() {\\r\\n let address = await this.getIp()\\r\\n\\r\\n $ui.toast(\"Loading...\", 5)\\r\\n try {\\r\\n const resp = await this.request(address + \"/api/clip\", \"GET\")\\r\\n if (resp.data.status) {\\r\\n $ui.success(\"success\")\\r\\n $clipboard.text = resp.data.data\\r\\n }\\r\\n } catch (error) {\\r\\n $ui.clearToast()\\r\\n $ui.alert({\\r\\n title: \"Error\",\\r\\n message: String(error),\\r\\n actions: [\\r\\n { title: \"OK\" },\\r\\n {\\r\\n title: \"Reset Adress\",\\r\\n handler: () => this.getIp(true)\\r\\n }\\r\\n ]\\r\\n })\\r\\n }\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## GetFromWin\\r\\n\\r\\n通 clipsync 读取 PC 剪切板。\\r\\n\\r\\n服务端:[clipsync](https://github.com/ipuppet/clipsync)\\r\\n\"},OpenUrl:{\"config.json\":'{\\r\\n \"icon\": \"link\",\\r\\n \"color\": \"#FF0099\",\\r\\n \"name\": \"打开链接\"\\r\\n}',\"main.js\":'class MyAction extends Action {\\r\\n l10n() {\\r\\n return {\\r\\n \"zh-Hans\": {\\r\\n \"openLink.nourl\": \"未检测到链接\"\\r\\n },\\r\\n en: {\\r\\n \"openLink.nourl\": \"No link detected\"\\r\\n }\\r\\n }\\r\\n }\\r\\n\\r\\n openUrl(url) {\\r\\n $app.openURL(url.trim())\\r\\n }\\r\\n\\r\\n do() {\\r\\n const url = this.getUrls()\\r\\n if (url.length > 1) {\\r\\n $ui.menu({\\r\\n items: url,\\r\\n handler: (title, index) => {\\r\\n this.openUrl(url[index])\\r\\n }\\r\\n })\\r\\n } else if (url.length === 1) {\\r\\n this.openUrl(url[0])\\r\\n } else {\\r\\n $ui.warning($l10n(\"openLink.nourl\"))\\r\\n }\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## OpenUrl\\r\\n\\r\\n提取文本中的URL并打开。\"},SendToWin:{\"config.json\":'{\\r\\n \"icon\": \"square.and.arrow.up\",\\r\\n \"color\": \"#33CC33\",\\r\\n \"name\": \"推送 clipsync\"\\r\\n}',\"main.js\":'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n */\\r\\nclass MyAction extends Action {\\r\\n async getIp(refresh = false) {\\r\\n let address = $cache.get(\"caio.action.clipsync.address\")\\r\\n if (refresh || !address) {\\r\\n address = await $input.text({\\r\\n placeholder: \"Address\",\\r\\n text: $cache.get(\"caio.action.clipsync.address\")\\r\\n })\\r\\n }\\r\\n\\r\\n $cache.set(\"caio.action.clipsync.address\", address)\\r\\n\\r\\n if (!address.startsWith(\"http\")) {\\r\\n address = \"http://\" + address\\r\\n }\\r\\n\\r\\n return address\\r\\n }\\r\\n\\r\\n async do() {\\r\\n let address = await this.getIp()\\r\\n\\r\\n $ui.toast(\"Loading...\", 5)\\r\\n try {\\r\\n const resp = await this.request(address + \"/api/clip\", \"POST\", {\\r\\n data: $clipboard.text\\r\\n })\\r\\n if (resp.data.status) {\\r\\n $ui.success(\"success\")\\r\\n }\\r\\n } catch (error) {\\r\\n $ui.clearToast()\\r\\n $ui.alert({\\r\\n title: \"Error\",\\r\\n message: String(error),\\r\\n actions: [\\r\\n { title: \"OK\" },\\r\\n {\\r\\n title: \"Reset Adress\",\\r\\n handler: () => this.getIp(true)\\r\\n }\\r\\n ]\\r\\n })\\r\\n }\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## SendToWin\\r\\n\\r\\n通 clipsync 推送剪切板至 PC。\\r\\n\\r\\n服务端:[clipsync](https://github.com/ipuppet/clipsync)\\r\\n\"},Tokenize:{\"config.json\":'{\\r\\n \"icon\": \"pencil.and.ellipsis.rectangle\",\\r\\n \"color\": \"#0099FF\",\\r\\n \"name\": \"分词复制\"\\r\\n}',\"main.js\":'class MyAction extends Action {\\r\\n getView() {\\r\\n const color = {\\r\\n background: {\\r\\n normal: $color(\"#E7F2FF\", \"#E7F2FF\"),\\r\\n highlight: $color(\"##074FF\", \"#BBDAFF\")\\r\\n },\\r\\n text: {\\r\\n normal: $color(\"##074FF\", \"##074FF\"),\\r\\n highlight: $color(\"#FFFFFF\", \"#ADADAD\")\\r\\n }\\r\\n }\\r\\n const fontSize = 16\\r\\n const edges = 10\\r\\n return {\\r\\n type: \"matrix\",\\r\\n layout: $layout.fill,\\r\\n props: {\\r\\n spacing: edges,\\r\\n data: this.results.map(item => ({ label: { text: item } })),\\r\\n template: {\\r\\n views: [{\\r\\n type: \"label\",\\r\\n props: {\\r\\n id: \"label\",\\r\\n align: $align.center,\\r\\n cornerRadius: edges,\\r\\n bgcolor: color.background.normal,\\r\\n font: $font(fontSize),\\r\\n textColor: color.text.normal\\r\\n },\\r\\n layout: $layout.fill\\r\\n }]\\r\\n }\\r\\n },\\r\\n events: {\\r\\n highlighted: () => { },\\r\\n itemSize: (sender, indexPath) => {\\r\\n const width = fontSize * this.results[indexPath.item].length + 1\\r\\n if (this.maxtrixItemHeight === undefined)\\r\\n this.maxtrixItemHeight = fontSize + edges * 2\\r\\n return $size(width + edges * 2, this.maxtrixItemHeight)\\r\\n },\\r\\n didSelect: (sender, indexPath) => {\\r\\n const index = this.selected.indexOf(indexPath.item)\\r\\n const label = sender.cell(indexPath).get(\"label\")\\r\\n if (index === -1) {\\r\\n this.selected.push(indexPath.item)\\r\\n label.bgcolor = color.background.highlight\\r\\n label.textColor = color.text.highlight\\r\\n } else {\\r\\n this.selected.splice(index, 1)\\r\\n label.bgcolor = color.background.normal\\r\\n label.textColor = color.text.normal\\r\\n }\\r\\n }\\r\\n }\\r\\n }\\r\\n }\\r\\n /**\\r\\n * 系统会调用 do() 方法\\r\\n */\\r\\n do() {\\r\\n this.selected = []\\r\\n this.results = []\\r\\n $text.tokenize({\\r\\n text: this.text,\\r\\n handler: results => {\\r\\n this.results = results\\r\\n this.pageSheet({\\r\\n view: this.getView(),\\r\\n done: () => {\\r\\n const result = []\\r\\n this.selected.sort().forEach(i => {\\r\\n result.push(this.results[i])\\r\\n })\\r\\n if (result.length > 0) {\\r\\n const text = result.join(\"\")\\r\\n $clipboard.text = text\\r\\n $ui.alert({\\r\\n title: \"完成\",\\r\\n message: `已复制内容:${text}`\\r\\n })\\r\\n }\\r\\n }\\r\\n })\\r\\n }\\r\\n })\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## Tokenize\\r\\n\\r\\n将文本分词处理后复制。\"}},editor:{PreviewMarkdown:{\"config.json\":'{\\r\\n \"icon\": \"book\",\\r\\n \"color\": \"#9900CC\",\\r\\n \"name\": \"预览Markdown\"\\r\\n}',\"main.js\":'class MyAction extends Action {\\r\\n do() {\\r\\n this.pageSheet({\\r\\n view: {\\r\\n type: \"markdown\",\\r\\n props: { content: this.text },\\r\\n layout: $layout.fill\\r\\n }\\r\\n })\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## PreviewMarkdown\\r\\n\\r\\n预览Markdown。\"},SelectedText:{\"config.json\":'{\\r\\n \"icon\": \"crop\",\\r\\n \"color\": \"#6699CC\",\\r\\n \"name\": \"选中的文本\"\\r\\n}',\"main.js\":\"class MyAction extends Action {\\r\\n do() {\\r\\n if (this.selectedRange.length > 0) {\\r\\n const selectedText = this.text\\r\\n $ui.alert(selectedText)\\r\\n }\\r\\n }\\r\\n}\\r\\n\",\"README.md\":\"## SelectedText\\r\\n\\r\\n显示选中的文本。\"}},uncategorized:{DeleteClips:{\"config.json\":'{\\r\\n \"icon\": \"trash\",\\r\\n \"color\": \"#FF0000\",\\r\\n \"name\": \"删除所有剪切板\"\\r\\n}',\"main.js\":'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n */\\r\\n\\r\\nclass MyAction extends Action {\\r\\n async do() {\\r\\n try {\\r\\n const action = await this.clearAllClips()\\r\\n if (action) {\\r\\n $ui.success($l10n(\"DONE\"))\\r\\n }\\r\\n } catch (error) {\\r\\n $ui.error(error)\\r\\n }\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## DeleteClips\\r\\n\\r\\n删除所有已保存的剪切板(不包括收藏)。\"},DisplayClipboard:{\"config.json\":'{\\r\\n \"icon\": \"option\",\\r\\n \"color\": \"#FF6633\",\\r\\n \"name\": \"显示剪切板\"\\r\\n}',\"main.js\":'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n */\\r\\n\\r\\nclass MyAction extends Action {\\r\\n do() {\\r\\n this.pageSheet({\\r\\n view: {\\r\\n type: \"label\",\\r\\n props: {\\r\\n lines: 0,\\r\\n text: $clipboard.text,\\r\\n align: $align.center\\r\\n },\\r\\n layout: $layout.fill\\r\\n }\\r\\n })\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## DisplayClipboard\\r\\n\\r\\n显示当前剪切板内的内容。\"},ExportAllContent:{\"config.json\":'{\\r\\n \"icon\": \"square.and.arrow.up\",\\r\\n \"color\": \"#FF3300\",\\r\\n \"name\": \"导出数据\"\\r\\n}',\"main.js\":'class MyAction extends Action {\\r\\n do() {\\r\\n const data = this.getAllClips()\\r\\n if (data.clips.length > 0 || data.favorite.length > 0) {\\r\\n $share.sheet(JSON.stringify(data, null, 2))\\r\\n } else {\\r\\n $ui.alert(\"无数据\")\\r\\n }\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## ExportAllContent\\r\\n\\r\\n导出所有保存的数据。\"},Replace:{\"config.json\":'{\\r\\n \"icon\": \"square.and.arrow.up\",\\r\\n \"color\": \"#FF3300\",\\r\\n \"name\": \"查找替换\"\\r\\n}',\"main.js\":'function HtmlTemplate(html) {\\r\\n return `\\r\\n\\r\\n\\r\\n \\r\\n\\r\\n\\r\\n${html}\\r\\n\\r\\n\\r\\n`\\r\\n}\\r\\n\\r\\nclass MyAction extends Action {\\r\\n do() {\\r\\n $ui.menu({\\r\\n items: [\"忽略大小写\", \"大小写敏感\", \"正则表达式\"],\\r\\n handler: async (title, idx) => {\\r\\n const patternText = await $input.text({\\r\\n placeholder: \"查找内容\"\\r\\n })\\r\\n const replaceString = await $input.text({\\r\\n placeholder: \"替换内容\"\\r\\n })\\r\\n let pattern = undefined\\r\\n if (idx === 0) {\\r\\n pattern = new RegExp(`(${patternText})+`, \"gi\")\\r\\n } else if (idx === 1) {\\r\\n pattern = new RegExp(`(${patternText})+`, \"g\")\\r\\n } else if (idx === 2) {\\r\\n pattern = new RegExp(patternText, \"g\")\\r\\n }\\r\\n\\r\\n const matchResultPreview = this.text.replace(pattern, `${replaceString}`)\\r\\n const matchResult = this.text.replace(pattern, replaceString)\\r\\n this.pageSheet({\\r\\n title: \"替换预览\",\\r\\n doneText: \"替换\",\\r\\n view: {\\r\\n type: \"web\",\\r\\n props: {\\r\\n html: HtmlTemplate(matchResultPreview)\\r\\n },\\r\\n layout: $layout.fill\\r\\n },\\r\\n done: () => {\\r\\n this.setContent(matchResult)\\r\\n }\\r\\n })\\r\\n }\\r\\n })\\r\\n // this.setContent(\"Hello world!\")\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## Replace\\r\\n\\r\\n查找替换\"}}};var $8Makm=parcelRequire(\"8Makm\");$8Makm.run()})();" } } } diff --git a/dist/CAIO.js b/dist/CAIO.js index 925ec097..f551553e 100644 --- a/dist/CAIO.js +++ b/dist/CAIO.js @@ -1 +1 @@ -(()=>{var $parcel$global="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},$parcel$modules={},$parcel$inits={},parcelRequire=$parcel$global.parcelRequire94c2;null==parcelRequire&&(parcelRequire=function(e){if(e in $parcel$modules)return $parcel$modules[e].exports;if(e in $parcel$inits){var t=$parcel$inits[e];delete $parcel$inits[e];var i={id:e,exports:{}};return $parcel$modules[e]=i,t.call(i.exports,i,i.exports),i.exports}var r=new Error("Cannot find module '"+e+"'");throw r.code="MODULE_NOT_FOUND",r},parcelRequire.register=function(e,t){$parcel$inits[e]=t},$parcel$global.parcelRequire94c2=parcelRequire),parcelRequire.register("8Makm",(function(e,t){var i=parcelRequire("gxpqj"),r=i.UIKit,s=i.ViewController,a=i.TabBarController,n=i.Kernel,o=i.FileStorage,l=i.Setting,c=i.FileManager,h=parcelRequire("hOw2h"),d=parcelRequire("imdB1"),p=parcelRequire("44eiF"),u=parcelRequire("gYDdO"),g=parcelRequire("9RsVy");const $=new o;class f extends n{constructor(){let e;super(),this.query=$context.query,this.fileStorage=$;try{e=__SETTING__}catch{}this.setting=new l({fileStorage:this.fileStorage,structure:e}),this.setting.loadConfig(),this.storage=new h(this),this.initComponents(),g(this)}addOpenInJsboxButton(){this.useJsboxNav(),this.setNavButtons([{image:$image("assets/icon.png"),handler:()=>this.openInJsbox()}])}initComponents(){this.clips=new d(this),this.actionManager=new p(this),this.fileManager=new c}deleteConfirm(e,t){$ui.alert({title:$l10n("CONFIRM_DELETE_TITLE"),message:e,actions:[{title:$l10n("DELETE"),style:$alertActionType.destructive,handler:()=>{t()}},{title:$l10n("CANCEL")}]})}}class b{static kernel=$app.env!==$env.widget?new f:void 0;static renderMainUI(){const e={clips:{icon:"doc.on.clipboard",title:$l10n("CLIPS")},actions:{icon:"command",title:$l10n("ACTIONS")},setting:{icon:"gear",title:$l10n("SETTING")}};if(this.kernel.setting.setEvent("onSet",(e=>{"mainUIDisplayMode"===e&&$delay(.3,(()=>$addin.restart()))})),0===this.kernel.setting.get("mainUIDisplayMode"))this.kernel.useJsboxNav(),this.kernel.setting.useJsboxNav(),this.kernel.setNavButtons([{symbol:e.setting.icon,title:e.setting.title,handler:()=>{r.push({title:e.setting.title,views:[this.kernel.setting.getListView()]})}},{symbol:e.actions.icon,title:e.actions.title,handler:()=>{this.kernel.actionManager.present()}}]),this.kernel.UIRender(this.kernel.clips.getNavigationView().getPage());else{this.kernel.fileManager.setViewController(new s),this.kernel.tabBarController=new a;const t=this.kernel.clips.getNavigationView();this.kernel.tabBarController.setPages({clips:t.getPage(),actions:this.kernel.actionManager.getPage(),setting:this.kernel.setting.getPage()}).setCells({clips:e.clips,actions:e.actions,setting:e.setting}),this.kernel.UIRender(this.kernel.tabBarController.generateView().definition)}}static renderKeyboardUI(){this.kernel.addOpenInJsboxButton();const e=new(parcelRequire("7eNYp"))(this.kernel);this.kernel.UIRender(e.getView())}static renderTodayUI(){this.kernel.addOpenInJsboxButton();const e=new(parcelRequire("49je6"))(this.kernel);this.kernel.UIRender(e.getView())}static renderUnsupported(){$intents.finish("不支持在此环境中运行"),$ui.render({views:[{type:"label",props:{text:"不支持在此环境中运行",align:$align.center},layout:$layout.fill}]})}}class y{static widgetInstance(e,...t){if($file.exists(`/scripts/widget/${e}.js`)){const{Widget:i}=require(`./widget/${e}.js`);return new i(...t)}return!1}static renderError(){$widget.setTimeline({render:()=>({type:"text",props:{text:"Invalid argument"}})})}static renderClipboard(){const e=new l;e.loadConfig().setReadonly();y.widgetInstance("Clipboard",e,new h({fileStorage:$})).render()}static render(e=$widget.inputValue){"Clipboard"===(e=e??"Clipboard")?y.renderClipboard():y.renderError()}}e.exports={Widget:y,run:()=>{u(b.kernel),$app.env===$env.app||$app.env===$env.action?b.renderMainUI():$app.env===$env.keyboard?b.renderKeyboardUI():$app.env===$env.widget?y.render():$app.env===$env.today?b.renderTodayUI():b.renderUnsupported()}}})),parcelRequire.register("gxpqj",(function(module,exports){var $parcel$global="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==$parcel$global?$parcel$global:{},$parcel$modules={},$parcel$inits={},parcelRequire=$parcel$global.parcelRequire94c2;null==parcelRequire&&(parcelRequire=function(e){if(e in $parcel$modules)return $parcel$modules[e].exports;if(e in $parcel$inits){var t=$parcel$inits[e];delete $parcel$inits[e];var i={id:e,exports:{}};return $parcel$modules[e]=i,t.call(i.exports,i,i.exports),i.exports}var r=new Error("Cannot find module '"+e+"'");throw r.code="MODULE_NOT_FOUND",r},parcelRequire.register=function(e,t){$parcel$inits[e]=t},$parcel$global.parcelRequire94c2=parcelRequire),parcelRequire.register("45Ip7",(function(e,t){class i{static#e=$objc("UIApplication").$sharedApplication();static#t=$objc("UINotificationFeedbackGenerator").$new();static feedbackSuccess(){i.#t.$notificationOccurred(0)}static feedbackError(){i.#t.$notificationOccurred(2)}static align={left:0,right:1,top:2,bottom:3};static textColor=$color("primaryText");static linkColor=$color("systemLink");static primaryViewBackgroundColor=$color("primarySurface");static scrollViewBackgroundColor=$color("insetGroupedBackground");static scrollViewList=["list","matrix"];static isLargeScreen=$device.isIpad||$device.isIpadPro;static get windowSize(){return $objc("UIWindow").$keyWindow().jsValue().size}static NavigationBarNormalHeight=$objc("UINavigationController").invoke("alloc.init").$navigationBar().jsValue().frame.height;static NavigationBarLargeTitleHeight=$objc("UITabBarController").invoke("alloc.init").$tabBar().jsValue().frame.height+i.NavigationBarNormalHeight;static get isSplitScreenMode(){return i.isLargeScreen&&$device.info.screen.width!==i.windowSize.width}static get topSafeAreaInsets(){return i.#e?.$keyWindow()?.$safeAreaInsets()?.top??0}static get bottomSafeAreaInsets(){return i.#e?.$keyWindow()?.$safeAreaInsets()?.bottom??0}static get statusBarOrientation(){return i.#e.$statusBarOrientation()}static get consoleBarHeight(){if($app.isDebugging){let e=i.#e.$statusBarFrame().height+26;return $device.isIphoneX&&(e+=30),e}return 0}static get isHorizontal(){return 3===i.statusBarOrientation||4===i.statusBarOrientation}static loading(){const e=$ui.create(i.blurBox({cornerRadius:15},[{type:"spinner",props:{loading:!0,style:0},layout:(e,t)=>{e.size.equalTo(t.prev),e.center.equalTo(t.super)}}]));return{start:()=>{$ui.controller.view.insertAtIndex(e,0),e.layout(((e,t)=>{e.center.equalTo(t.super);const r=Math.min(.6*Math.min(i.windowSize.width,i.windowSize.height),260);e.size.equalTo($size(r,r))})),e.moveToFront()},end:()=>{e.remove()}}}static defaultBackgroundColor(e){return i.scrollViewList.indexOf(e)>-1?i.scrollViewBackgroundColor:i.primaryViewBackgroundColor}static separatorLine(e={},t=i.align.bottom){return{type:"canvas",props:e,layout:(e,r)=>{void 0===r.prev?e.top.equalTo(r.super):t===i.align.bottom?e.top.equalTo(r.prev.bottom):e.top.equalTo(r.prev.top),e.height.equalTo(1/$device.info.screen.scale),e.left.right.inset(0)},events:{draw:(t,i)=>{i.strokeColor=e.bgcolor??$color("separatorColor"),i.setLineWidth(1),i.moveToPoint(0,0),i.addLineToPoint(t.frame.width,0),i.strokePath()}}}}static blurBox(e={},t=[],i=$layout.fill){return{type:"blur",props:Object.assign({style:$blurStyle.thinMaterial},e),views:t,layout:i}}static getContentSize(e,t="A",r=i.windowSize.width,s){const a={text:t,width:r,font:e};return void 0!==s&&(a.lineSpacing=s),$text.sizeThatFits(a)}static push({views:e,statusBarStyle:t=0,title:i="",navButtons:r=[{title:""}],bgcolor:s=e[0]?.props?.bgcolor??"primarySurface",disappeared:a}={}){$ui.push({props:{statusBarStyle:t,navButtons:r,title:i,bgcolor:"string"==typeof s?$color(s):s},events:{disappeared:()=>{void 0!==a&&a()}},views:[{type:"view",views:e,layout:(e,t)=>{e.top.equalTo(t.super.safeArea),e.bottom.equalTo(t.super),e.left.right.equalTo(t.super.safeArea)}}]})}}e.exports={UIKit:i}})),parcelRequire.register("7D8Kb",(function(module,exports){var $fYz8N=parcelRequire("fYz8N"),$58e2f5443faff7c0$require$Controller=$fYz8N.Controller,$8aDdQ=parcelRequire("8aDdQ"),$58e2f5443faff7c0$require$FileStorageFileNotFoundError=$8aDdQ.FileStorageFileNotFoundError,$58e2f5443faff7c0$require$FileStorage=$8aDdQ.FileStorage,$cgaQ6=parcelRequire("cgaQ6"),$58e2f5443faff7c0$require$Kernel=$cgaQ6.Kernel,$45Ip7=parcelRequire("45Ip7"),$58e2f5443faff7c0$require$UIKit=$45Ip7.UIKit,$aXWmO=parcelRequire("aXWmO"),$58e2f5443faff7c0$require$Sheet=$aXWmO.Sheet,$12xzj=parcelRequire("12xzj"),$58e2f5443faff7c0$require$NavigationView=$12xzj.NavigationView,$dcStC=parcelRequire("dcStC"),$58e2f5443faff7c0$require$NavigationBar=$dcStC.NavigationBar,$gMc1q=parcelRequire("gMc1q"),$58e2f5443faff7c0$require$ViewController=$gMc1q.ViewController;class SettingLoadConfigError extends Error{constructor(){super("Call loadConfig() first."),this.name="SettingLoadConfigError"}}class SettingReadonlyError extends Error{constructor(){super("Attempted to assign to readonly property."),this.name="SettingReadonlyError"}}class Setting extends $58e2f5443faff7c0$require$Controller{name;setting={};userData;fileStorage;imagePath;viewController=new $58e2f5443faff7c0$require$ViewController;method={readme:()=>{const e=(()=>{const e=$device.info?.language?.startsWith("zh")?"README_CN.md":"README.md";try{return __README__[e]??__README__["README.md"]}catch{return $file.read(e)?.string??$file.read("README.md")?.string}})();(new $58e2f5443faff7c0$require$Sheet).setView({type:"markdown",props:{content:e},layout:(e,t)=>{e.size.equalTo(t.super)}}).init().present()}};rowHeight=50;edgeOffset=10;iconSize=30;#i={};#r=!1;#s=!1;#a;constructor(e={}){super(),"function"==typeof e.set&&"function"==typeof e.get?(this.set=e.set,this.get=e.get,this.userData=e.userData):(this.fileStorage=e.fileStorage??new $58e2f5443faff7c0$require$FileStorage,this.dataFile=e.dataFile??"setting.json"),e.structure?this.setStructure(e.structure):this.setStructurePath(e.structurePath??"setting.json"),this.isUseJsboxNav=e.isUseJsboxNav??!1,this.imagePath=(e.name??"default")+".image/",this.setName(e.name??$text.uuid),this.loadL10n()}useJsboxNav(){return this.isUseJsboxNav=!0,this}#n(){if(!this.#s)throw new SettingLoadConfigError}loadConfig(){const e=["script","info"],t=this.userData??this.fileStorage.readAsJSON(this.dataFile,{});return this.setting=function i(r){const s={};for(let a of r)for(let r of a.items)if("child"===r.type){const e=i(r.children);Object.assign(s,e)}else-1===e.indexOf(r.type)?s[r.key]=r.key in t?t[r.key]:r.value:s[r.key]=r.value;return s}(this.structure),this.#s=!0,this}hasSectionTitle(e){return this.#n(),!!e[0]?.title}loadL10n(){$58e2f5443faff7c0$require$Kernel.l10n("zh-Hans",{OK:"好",DONE:"完成",CANCEL:"取消",CLEAR:"清除",BACK:"返回",ERROR:"发生错误",SUCCESS:"成功",LOADING:"加载中",INVALID_VALUE:"非法参数",CONFIRM_CHANGES:"数据已变化,确认修改?",SETTING:"设置",GENERAL:"一般",ADVANCED:"高级",TIPS:"小贴士",COLOR:"颜色",COPY:"复制",COPIED:"复制成功",JSBOX_ICON:"JSBox 内置图标",SF_SYMBOLS:"SF Symbols",IMAGE_BASE64:"图片 / base64",PREVIEW:"预览",SELECT_IMAGE:"选择图片",CLEAR_IMAGE:"清除图片",NO_IMAGE:"无图片",ABOUT:"关于",VERSION:"Version",AUTHOR:"作者",AT_BOTTOM:"已经到底啦~"},!1),$58e2f5443faff7c0$require$Kernel.l10n("en",{OK:"OK",DONE:"Done",CANCEL:"Cancel",CLEAR:"Clear",BACK:"Back",ERROR:"Error",SUCCESS:"Success",LOADING:"Loading",INVALID_VALUE:"Invalid value",CONFIRM_CHANGES:"The data has changed, confirm the modification?",SETTING:"Setting",GENERAL:"General",ADVANCED:"Advanced",TIPS:"Tips",COLOR:"Color",COPY:"Copy",COPIED:"Copide",JSBOX_ICON:"JSBox in app icon",SF_SYMBOLS:"SF Symbols",IMAGE_BASE64:"Image / base64",PREVIEW:"Preview",SELECT_IMAGE:"Select Image",CLEAR_IMAGE:"Clear Image",NO_IMAGE:"No Image",ABOUT:"About",VERSION:"Version",AUTHOR:"Author",AT_BOTTOM:"It's the end~"},!1)}setUserData(e){this.userData=e}setStructure(e){return this.structure=e,this}setStructurePath(e){return this.structure||this.setStructure($58e2f5443faff7c0$require$FileStorage.readFromRootAsJSON(e)),this}setName(e){return this.name=e,this}setFooter(e){return this.#a=e,this}set footer(e){this.#a=e}get footer(){if(void 0===this.#a){let e=$58e2f5443faff7c0$require$FileStorage.readFromRootAsJSON("config.json",{}).info??{};if(!e.version||!e.author)try{e=__INFO__}catch{}this.#a={},e.version&&e.author&&(this.#a={type:"view",props:{height:70},views:[{type:"label",props:{font:$font(14),text:`${$l10n("VERSION")} ${e.version} ♥ ${e.author}`,textColor:$color({light:"#C0C0C0",dark:"#545454"}),align:$align.center},layout:e=>{e.left.right.inset(0),e.top.inset(10)}}]})}return this.#a}setReadonly(){return this.#r=!0,this}set(e,t){if(this.#r)throw new SettingReadonlyError;return this.#n(),this.setting[e]=t,this.fileStorage.write(this.dataFile,$data({string:JSON.stringify(this.setting)})),this.callEvent("onSet",e,t),!0}get(e,t=null){return this.#n(),Object.prototype.hasOwnProperty.call(this.setting,e)?this.setting[e]:t}getColor(e){return"string"==typeof e?$color(e):$rgba(e.red,e.green,e.blue,e.alpha)}getImagePath(e,t=!1){let i=$text.MD5(e)+".jpg";return t&&(i="compress."+i),this.imagePath+i}getImage(e,t=!1){try{return this.fileStorage.readSync(this.getImagePath(e,t)).image}catch(e){if(e instanceof $58e2f5443faff7c0$require$FileStorageFileNotFoundError)return null;throw e}}getId(e){return`setting-${this.name}-${e}`}#o(e){$(e).bgcolor=$color("systemFill")}#l(e,t=.3){0===t?$(e).bgcolor=$color("clear"):$ui.animate({duration:t,animation:()=>{$(e).bgcolor=$color("clear")}})}#c(e,t,i=!1,r=0){if(t=Object.assign(t,{touchesBegan:()=>{this.#o(e),this.#i[e]=$delay(1,(()=>this.#l(e,0)))},touchesMoved:()=>{this.#i[e]?.cancel(),this.#l(e,0)}}),i){const i=t.tapped;t.tapped=()=>{this.#o(e),setTimeout((()=>this.#l(e)),1e3*r),"function"==typeof i&&i()}}return t}createLineLabel(e,t){return t[1]||(t[1]="#00CC00"),"object"!=typeof t[1]&&(t[1]=[t[1],t[1]]),"object"!=typeof t[0]&&(t[0]=[t[0],t[0]]),{type:"view",views:[{type:"view",props:{bgcolor:$color(t[1][0],t[1][1]),cornerRadius:5,smoothCorners:!0},views:[{type:"image",props:{tintColor:$color("white"),image:$image(t[0][0],t[0][1])},layout:(e,t)=>{e.center.equalTo(t.super),e.size.equalTo(20)}}],layout:(e,t)=>{e.centerY.equalTo(t.super),e.size.equalTo(this.iconSize),e.left.inset(this.edgeOffset)}},{type:"label",props:{text:e,lines:1,textColor:this.textColor,align:$align.left},layout:(e,t)=>{e.centerY.equalTo(t.super),e.height.equalTo(t.super),e.left.equalTo(t.prev.right).offset(this.edgeOffset),e.width.greaterThanOrEqualTo(10)}}],layout:(e,t)=>{e.height.centerY.equalTo(t.super),e.left.inset(0)}}}createInfo(e,t,i){const r=Array.isArray(i),s=r?i[0]:i,a=r?i[1]:i;return{type:"view",props:{selectable:!0},views:[this.createLineLabel(t,e),{type:"label",props:{text:s,align:$align.right,textColor:$color("darkGray")},layout:(e,t)=>{e.centerY.equalTo(t.prev),e.right.inset(this.edgeOffset),e.width.equalTo(180)}},{type:"view",events:{tapped:()=>{$ui.alert({title:t,message:a,actions:[{title:$l10n("COPY"),handler:()=>{$clipboard.text=a,$ui.toast($l10n("COPIED"))}},{title:$l10n("OK")}]})}},layout:(e,t)=>{e.right.inset(0),e.size.equalTo(t.super)}}],layout:$layout.fill}}createSwitch(e,t,i){return{type:"view",props:{id:this.getId(e),selectable:!0},views:[this.createLineLabel(i,t),{type:"switch",props:{on:this.get(e),onColor:$color("#00CC00")},events:{changed:t=>{try{this.set(e,t.on)}catch(e){throw t.on=!t.on,e}}},layout:(e,t)=>{e.centerY.equalTo(t.prev),e.right.inset(this.edgeOffset)}}],layout:$layout.fill}}createString(e,t,i){return{type:"view",props:{id:this.getId(e),selectable:!0},views:[this.createLineLabel(i,t),{type:"button",props:{symbol:"square.and.pencil",bgcolor:$color("clear"),tintColor:$color("primaryText")},events:{tapped:t=>{const i=$ui.popover({sourceView:t,sourceRect:t.bounds,directions:$popoverDirection.down,size:$size(320,150),views:[{type:"text",props:{id:`${this.name}-string-${e}`,align:$align.left,text:this.get(e)},layout:e=>{e.left.right.inset(10),e.top.inset(20),e.height.equalTo(90)}},{type:"button",props:{symbol:"checkmark",bgcolor:$color("clear"),titleEdgeInsets:10,contentEdgeInsets:0},layout:e=>{e.right.inset(10),e.bottom.inset(25),e.size.equalTo(30)},events:{tapped:()=>{this.set(e,$(`${this.name}-string-${e}`).text),i.dismiss()}}}]})}},layout:(e,t)=>{e.centerY.equalTo(t.prev),e.right.inset(0),e.size.equalTo(50)}}],layout:$layout.fill}}createStepper(e,t,i,r,s){const a=this.getId(e),n=`${a}-label`;return{type:"view",props:{id:a,selectable:!0},views:[this.createLineLabel(i,t),{type:"label",props:{id:n,text:this.get(e),textColor:this.textColor,align:$align.left},layout:(e,t)=>{e.height.equalTo(t.super),e.right.inset(120)}},{type:"stepper",props:{min:r,max:s,value:this.get(e)},events:{changed:t=>{$(n).text=t.value;try{this.set(e,t.value)}catch(t){throw $(n).text=this.get(e),t}}},layout:(e,t)=>{e.centerY.equalTo(t.prev),e.right.inset(this.edgeOffset)}}],layout:$layout.fill}}createScript(key,icon,title,script){const id=this.getId(key),buttonId=`${id}-button`,actionStart=()=>{$(buttonId).alpha=0,$(`${buttonId}-spinner`).alpha=1,this.#o(id)},actionCancel=()=>{$(buttonId).alpha=1,$(`${buttonId}-spinner`).alpha=0,this.#l(id)},actionDone=(e=!0,t=$l10n("ERROR"))=>{$(`${buttonId}-spinner`).alpha=0,this.#l(id);const i=$(buttonId);if(!e)return $ui.toast(t),void(i.alpha=1);i.symbol="checkmark",$ui.animate({duration:.6,animation:()=>{i.alpha=1},completion:()=>{setTimeout((()=>{$ui.animate({duration:.4,animation:()=>{i.alpha=0},completion:()=>{i.symbol="chevron.right",$ui.animate({duration:.4,animation:()=>{i.alpha=1},completion:()=>{i.alpha=1}})}})}),600)}})};return{type:"view",props:{id:id},views:[this.createLineLabel(title,icon),{type:"view",views:[{type:"image",props:{id:buttonId,symbol:"chevron.right",tintColor:$color("secondaryText")},layout:(e,t)=>{e.centerY.equalTo(t.super),e.right.inset(0),e.size.equalTo(15)}},{type:"spinner",props:{id:`${buttonId}-spinner`,loading:!0,alpha:0},layout:(e,t)=>{e.size.equalTo(t.prev),e.left.top.equalTo(t.prev)}}],layout:(e,t)=>{e.right.inset(this.edgeOffset),e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],events:this.#c(id,{tapped:()=>{const animate={actionStart:actionStart,actionCancel:actionCancel,actionDone:actionDone,touchHighlightStart:()=>this.#o(id),touchHighlightEnd:()=>this.#l(id)};"function"==typeof script?script(animate):script.startsWith("this")?eval(`(()=>{return ${script}(animate)})()`):eval(script)}}),layout:$layout.fill}}createTab(key,icon,title,items,values){"string"==typeof items?items=eval(`(()=>{return ${items}()})()`):"function"==typeof items&&(items=items()),"string"==typeof values?values=eval(`(()=>{return ${values}()})()`):"function"==typeof values&&(values=values());const id=this.getId(key),isCustomizeValues=items?.length>0&&values?.length===items?.length;return{type:"view",props:{id:id,selectable:!0},views:[this.createLineLabel(title,icon),{type:"tab",props:{items:items??[],index:isCustomizeValues?values.indexOf(this.get(key)):this.get(key),dynamicWidth:!0},layout:(e,t)=>{e.right.inset(this.edgeOffset),e.centerY.equalTo(t.prev)},events:{changed:e=>{isCustomizeValues?this.set(key,values[e.index]):this.set(key,e.index)}}}],layout:$layout.fill}}createMenu(key,icon,title,items,values){const id=this.getId(key),labelId=`${id}-label`,getItems=()=>{let res;return res="string"==typeof items?eval(`(()=>{return ${items}()})()`):"function"==typeof items?items():items??[],res},getValues=()=>{let res;return res="string"==typeof values?eval(`(()=>{return ${values}()})()`):"function"==typeof values?values():values,res},tmpItems=getItems(),tmpValues=getValues(),isCustomizeValues=tmpItems?.length>0&&tmpValues?.length===tmpItems?.length;return{type:"view",props:{id:id,selectable:!0},views:[this.createLineLabel(title,icon),{type:"view",views:[{type:"label",props:{text:isCustomizeValues?tmpItems[tmpValues.indexOf(this.get(key))]:tmpItems[this.get(key)],color:$color("secondaryText"),id:labelId},layout:(e,t)=>{e.right.inset(0),e.height.equalTo(t.super)}}],layout:(e,t)=>{e.right.inset(this.edgeOffset),e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],events:{tapped:()=>{const e=getItems(),t=getValues();$ui.menu({items:e,handler:(e,i)=>{isCustomizeValues?this.set(key,t[i]):this.set(key,i),$(labelId).text=$l10n(e)}})}},layout:$layout.fill}}createColor(e,t,i){const r=this.getId(e),s=`${r}-color`;return{type:"view",props:{id:r,selectable:!0},views:[this.createLineLabel(i,t),{type:"view",views:[{type:"view",props:{id:s,bgcolor:this.getColor(this.get(e)),circular:!0,borderWidth:1,borderColor:$color("#e3e3e3")},layout:(e,t)=>{e.centerY.equalTo(t.super),e.right.inset(this.edgeOffset),e.size.equalTo(20)}},{type:"view",events:{tapped:async()=>{const t=await $picker.color({color:this.getColor(this.get(e))});this.set(e,t.components),$(s).bgcolor=$rgba(t.components.red,t.components.green,t.components.blue,t.components.alpha)}},layout:(e,t)=>{e.right.inset(0),e.height.width.equalTo(t.super.height)}}],layout:(e,t)=>{e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],layout:$layout.fill}}createDate(e,t,i,r=2){const s=this.getId(e),a=e=>{let t="";switch("number"==typeof e&&(e=new Date(e)),r){case 0:t=e.toLocaleTimeString();break;case 1:t=e.toLocaleDateString();break;case 2:t=e.toLocaleString()}return t};return{type:"view",props:{id:s,selectable:!0},views:[this.createLineLabel(i,t),{type:"view",views:[{type:"label",props:{id:`${s}-label`,color:$color("secondaryText"),text:this.get(e)?a(this.get(e)):"None"},layout:(e,t)=>{e.right.inset(0),e.height.equalTo(t.super)}}],events:{tapped:async()=>{const t=this.get(e),i=await $picker.date({props:{mode:r,date:t||Date.now()}});this.set(e,i.getTime()),$(`${s}-label`).text=a(i)}},layout:(e,t)=>{e.right.inset(this.edgeOffset),e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],layout:$layout.fill}}createNumber(e,t,i){return this.createInput(e,t,i,!1,$kbType.decimal,(t=>""!==t&&/^[0-9]+.?[0-9]*$/.test(t)?this.set(e,Number(t)):($ui.toast($l10n("INVALID_VALUE")),!1)))}createInput(e,t,i,r=!1,s=$kbType.default,a){void 0===a&&(a=t=>this.set(e,t));const n=this.getId(e),o=n+"-input";return{type:"view",props:{id:n,selectable:!0},views:[this.createLineLabel(i,t),{type:"input",props:{id:o,type:s,align:$align.right,bgcolor:$color("clear"),textColor:$color("secondaryText"),text:this.get(e),font:$font(16),secure:r,accessoryView:$58e2f5443faff7c0$require$UIKit.blurBox({height:44},[$58e2f5443faff7c0$require$UIKit.separatorLine({},$58e2f5443faff7c0$require$UIKit.align.top),{type:"button",props:{title:$l10n("DONE"),bgcolor:$color("clear"),titleColor:$color("primaryText")},layout:(e,t)=>{e.right.inset(this.edgeOffset),e.centerY.equalTo(t.super)},events:{tapped:()=>{$(o).blur()}}},{type:"button",props:{title:$l10n("CANCEL"),bgcolor:$color("clear"),titleColor:$color("primaryText")},layout:(e,t)=>{e.left.inset(this.edgeOffset),e.centerY.equalTo(t.super)},events:{tapped:()=>{const t=$(o),i=this.get(e,"");t.text!==i&&(t.text=i),t.blur()}}}])},layout:(t,i)=>{t.left.equalTo(i.prev.get("label").right).offset(this.edgeOffset),t.right.inset(this.edgeOffset);const r=$58e2f5443faff7c0$require$UIKit.getContentSize($font(16),this.get(e)).width;t.width.greaterThanOrEqualTo(r+30),t.height.equalTo(i.super)},events:{didBeginEditing:e=>{e.secure=!1,$app.autoKeyboardEnabled||($app.autoKeyboardEnabled=!0)},returned:e=>{e.blur()},didEndEditing:async t=>{const i=this.get(e,"");a(t.text)||(t.text=i),r&&(t.secure=r)}}}],layout:$layout.fill}}createIcon(e,t,i,r="#000000"){const s=this.getId(e),a=`${s}-image`;return{type:"view",props:{id:s,selectable:!0},views:[this.createLineLabel(i,t),{type:"view",views:[{type:"image",props:{cornerRadius:8,bgcolor:"string"==typeof r?$color(r):r,smoothCorners:!0},layout:(e,t)=>{e.right.inset(this.edgeOffset),e.centerY.equalTo(t.super),e.size.equalTo($size(30,30))}},{type:"image",props:{id:a,image:$image(this.get(e)),icon:$icon(this.get(e).slice(5,this.get(e).indexOf(".")),$color("#ffffff")),tintColor:$color("#ffffff")},layout:(e,t)=>{e.right.equalTo(t.prev).offset(-5),e.centerY.equalTo(t.super),e.size.equalTo($size(20,20))}}],events:{tapped:()=>{$ui.menu({items:[$l10n("JSBOX_ICON"),$l10n("SF_SYMBOLS"),$l10n("IMAGE_BASE64")],handler:async(t,i)=>{if(0===i){const t=await $ui.selectIcon();this.set(e,t),$(a).icon=$icon(t.slice(5,t.indexOf(".")),$color("#ffffff"))}else 1!==i&&2!==i||$input.text({text:"",placeholder:t,handler:t=>{""!==t?(this.set(e,t),1===i?$(a).symbol=t:$(a).image=$image(t)):$ui.toast($l10n("INVALID_VALUE"))}})}})}},layout:(e,t)=>{e.right.inset(0),e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],layout:$layout.fill}}createPush(key,icon,title,view,tapped){const id=this.getId(key);return{type:"view",layout:$layout.fill,props:{id:id,selectable:!0},views:[this.createLineLabel(title,icon),{type:"image",props:{symbol:"chevron.right",tintColor:$color("secondaryText")},layout:(e,t)=>{e.centerY.equalTo(t.super),e.right.inset(this.edgeOffset),e.size.equalTo(15)}}],events:{tapped:()=>{const push=view=>{if("string"==typeof view&&view.startsWith("this.method")?view=eval(`(()=>{return ${view}()})()`):"function"==typeof view&&(view=view()),this.isUseJsboxNav)$58e2f5443faff7c0$require$UIKit.push({title:title,props:view.props??{},views:[view]});else{const e=new $58e2f5443faff7c0$require$NavigationView;e.setView(view).navigationBarTitle(title),e.navigationBarItems.addPopButton(),e.navigationBar.setLargeTitleDisplayMode($58e2f5443faff7c0$require$NavigationBar.largeTitleDisplayModeNever),this.hasSectionTitle(view)&&e.navigationBar.setContentViewHeightOffset(-10),this.viewController.push(e)}};"function"==typeof tapped?tapped(push):push(view)}}}}createChild(e,t,i,r){return this.createPush(e,t,i,void 0,(e=>{this.events?.onChildPush?this.callEvent("onChildPush",this.getListView(r,{}),i):e(this.getListView(r,{}))}))}createImage(e,t,i){const r=this.getId(e),s=`${r}-image`,a=$image("questionmark.square.dashed");return{type:"view",props:{id:r,selectable:!0},views:[this.createLineLabel(i,t),{type:"view",views:[{type:"image",props:{id:s,image:this.getImage(e,!0)??a},layout:(e,t)=>{e.right.inset(this.edgeOffset),e.centerY.equalTo(t.super),e.size.equalTo($size(30,30))}}],events:{tapped:()=>{this.#o(r),$ui.menu({items:[$l10n("PREVIEW"),$l10n("SELECT_IMAGE"),$l10n("CLEAR_IMAGE")],handler:(t,i)=>{if(0===i){const t=this.getImage(e);t?$quicklook.open({image:t}):$ui.toast($l10n("NO_IMAGE"))}else 1===i?$photo.pick({format:"data"}).then((t=>{if($ui.toast($l10n("LOADING")),!t.status||!t.data)return void("canceled"!==t?.error?.description&&$ui.toast($l10n("ERROR")));const i=$58e2f5443faff7c0$require$Kernel.compressImage(t.data.image);this.fileStorage.write(this.getImagePath(e,!0),i.jpg(.8)),this.fileStorage.write(this.getImagePath(e),t.data),$(s).image=i,$ui.success($l10n("SUCCESS"))})):2===i&&(this.fileStorage.delete(this.getImagePath(e,!0)),this.fileStorage.delete(this.getImagePath(e)),$(s).image=a,$ui.success($l10n("SUCCESS")))},finished:()=>{this.#l(r)}})}},layout:(e,t)=>{e.right.inset(0),e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],layout:$layout.fill}}#h(e){const t=[];for(let i of e){const e=[];for(let t of i.items){const i=this.get(t.key);let r=null;switch(t.icon||(t.icon=["square.grid.2x2.fill","#00CC00"]),"object"==typeof t.items&&(t.items=t.items.map((e=>$l10n(e)))),t.title=$l10n(t.title),t.type){case"switch":r=this.createSwitch(t.key,t.icon,t.title);break;case"stepper":r=this.createStepper(t.key,t.icon,t.title,t.min??1,t.max??12);break;case"string":r=this.createString(t.key,t.icon,t.title);break;case"info":r=this.createInfo(t.icon,t.title,i);break;case"script":r=this.createScript(t.key,t.icon,t.title,i);break;case"tab":r=this.createTab(t.key,t.icon,t.title,t.items,t.values);break;case"menu":r=this.createMenu(t.key,t.icon,t.title,t.items,t.values);break;case"color":r=this.createColor(t.key,t.icon,t.title);break;case"date":r=this.createDate(t.key,t.icon,t.title,t.mode);break;case"number":r=this.createNumber(t.key,t.icon,t.title);break;case"input":r=this.createInput(t.key,t.icon,t.title,t.secure);break;case"icon":r=this.createIcon(t.key,t.icon,t.title,t.bgcolor);break;case"push":r=this.createPush(t.key,t.icon,t.title,t.view);break;case"child":r=this.createChild(t.key,t.icon,t.title,t.children);break;case"image":r=this.createImage(t.key,t.icon,t.title);break;default:continue}e.push(r)}t.push({title:$l10n(i.title??""),rows:e})}return t}getListView(e,t=this.footer){return{type:"list",props:{id:this.name,style:2,separatorInset:$insets(0,this.iconSize+2*this.edgeOffset,0,this.edgeOffset),bgcolor:$58e2f5443faff7c0$require$UIKit.scrollViewBackgroundColor,footer:t,data:this.#h(e??this.structure)},layout:$layout.fill,events:{rowHeight:(e,t)=>(e.object(t)?.props?.info??{}).rowHeight??this.rowHeight}}}getPage(){const e=new $58e2f5443faff7c0$require$NavigationView;return e.setView(this.getListView(this.structure)).navigationBarTitle($l10n("SETTING")),this.hasSectionTitle(this.structure)&&e.navigationBar.setContentViewHeightOffset(-10),e.getPage()}}module.exports={Setting:Setting}})),parcelRequire.register("fYz8N",(function(e,t){e.exports={Controller:class{events={};setEvents(e){return Object.keys(e).forEach((t=>this.setEvent(t,e[t]))),this}setEvent(e,t){return this.events[e]=t,this}callEvent(e,...t){"function"==typeof this.events[e]&&this.events[e](...t)}}}})),parcelRequire.register("8aDdQ",(function(e,t){class i extends Error{constructor(e){super(`Parameter [${e}] is required.`),this.name="FileStorageParameterError"}}class r extends Error{constructor(e){super(`File not found: ${e}`),this.name="FileStorageFileNotFoundError"}}class s{basePath;constructor({basePath:e="storage"}={}){this.basePath=e,this.#d(this.basePath)}#d(e){$file.isDirectory(e)||$file.mkdir(e)}filePath(e="",t=!0){e.startsWith("/")&&(e=e.substring(1));let i="";if(!(e=`${this.basePath}/${e}`).endsWith("/")){const t=e.lastIndexOf("/");e.lastIndexOf(".")>t&&(i=e.substring(t+1),e=e.substring(0,t+1))}return t&&this.#d(e),e+i}exists(e=""){return e=this.filePath(e,!1),!!$file.exists(e)}write(e="",t){return new Promise(((i,r)=>{try{const s=this.writeSync(e,t);s?i(s):r(s)}catch(e){r(e)}}))}writeSync(e="",t){if(!t)throw new i("data");return $file.write({data:t,path:this.filePath(e)})}read(e=""){return new Promise(((t,i)=>{try{const r=this.readSync(e);r?t(r):i()}catch(e){i(e)}}))}readSync(e=""){if(e=this.filePath(e),!$file.exists(e))throw new r(e);return $file.isDirectory(e)?$file.list(e):$file.read(e)}readAsJSON(e="",t=null){try{const t=this.readSync(e)?.string;return JSON.parse(t)}catch(e){return t}}static readFromRoot(e=""){return new Promise(((t,i)=>{try{const r=s.readFromRootSync(e);r?t(r):i()}catch(e){i(e)}}))}static readFromRootSync(e=""){if(!e)throw new i("path");if(!$file.exists(e))throw new r(e);return $file.isDirectory(e)?$file.list(e):$file.read(e)}static readFromRootAsJSON(e="",t=null){try{const t=s.readFromRootSync(e)?.string;return JSON.parse(t)}catch(e){return t}}delete(e=""){return $file.delete(this.filePath(e,!1))}copy(e,t){e=this.filePath(e),t=this.filePath(t),$file.copy({src:e,dst:t})}move(e,t){e=this.filePath(e),t=this.filePath(t),$file.move({src:e,dst:t})}}e.exports={FileStorageParameterError:i,FileStorageFileNotFoundError:r,FileStorage:s}})),parcelRequire.register("cgaQ6",(function(e,t){var i=parcelRequire("czAIJ").VERSION;class r{startTime=Date.now();isUseJsboxNav=!1;title=$addin?.current?.name;constructor(){$app.isDebugging&&this.debug()}static isTaio=$app.info.bundleID.includes("taio");static l10n(e,t,i=!0){if("string"==typeof t){const e={};t.split(";").forEach((t=>{if(""!==(t=t.trim())){const i=t.split("=");e[i[0].trim().slice(1,-1)]=i[1].trim().slice(1,-1)}})),t=e}const r=$app.strings;r[e]=i?Object.assign($app.strings[e],t):Object.assign(t,$app.strings[e]),$app.strings=r}static compressImage(e,t=921600){const i=$imagekit.info(e);if(i.height*i.width>t){const r=t/(i.height*i.width);e=$imagekit.scaleBy(e,r)}return e}static objectEqual(e,t){let i=Object.getOwnPropertyNames(e),s=Object.getOwnPropertyNames(t);if(i.length!==s.length)return!1;for(let s=0;se?i[e]:0,s=isNaN(Number(t))?t.charCodeAt():Number(t),n=r.length>e?r[e]:0,o=isNaN(Number(n))?n.charCodeAt():Number(n);if(so){a=1;break}}return a}static deleteConfirm(e,t){$ui.alert({title:$l10n("DELETE_CONFIRM_TITLE"),message:e,actions:[{title:$l10n("DELETE"),style:$alertActionType.destructive,handler:()=>{t()}},{title:$l10n("CANCEL")}]})}static bytesToSize(e){if(0===e)return"0 B";const t=Math.floor(Math.log(e)/Math.log(1024));return(e/Math.pow(1024,t)).toPrecision(3)+" "+["B","KB","MB","GB","TB","PB","EB","ZB","YB"][t]}debug(e,t){this.debugMode=!0,$app.idleTimerDisabled=!0,"function"==typeof e&&(this.debugPrint=e),"function"==typeof t&&(this.debugError=t),this.print("You are running EasyJsBox in debug mode.")}print(e){this.debugMode&&("function"==typeof this.debugPrint?this.debugPrint(e):console.log(e))}error(e){this.debugMode&&("function"==typeof this.debugError?this.debugError(e):console.error(e))}useJsboxNav(){return this.isUseJsboxNav=!0,this}setTitle(e){this.isUseJsboxNav&&($ui.title=e),this.title=e}setNavButtons(e){this.navButtons=e}openInJsbox(){$app.openURL(`jsbox://run?name=${this.title}`)}UIRender(e){try{e.props=Object.assign({title:this.title,navBarHidden:!this.isUseJsboxNav,navButtons:this.navButtons??[],statusBarStyle:0},e.props),e.events||(e.events={});const t=e.events.layoutSubviews,{UIKit:i}=parcelRequire("45Ip7");e.events.layoutSubviews=()=>{$app.notify({name:"interfaceOrientationEvent",object:{statusBarOrientation:i.statusBarOrientation,isHorizontal:i.isHorizontal}}),"function"==typeof t&&t()},$ui.render(e)}catch(e){this.print(e)}}async checkUpdate(){const e=await $http.get("https://raw.githubusercontent.com/ipuppet/EasyJsBox/dev/src/version.js");if(e.error)throw e.error;const t=srcRes.data.match(/.*VERSION.?\"([0-9\.]+)\"/)[1];if(this.print(`easy-jsbox latest version: ${t}`),r.versionCompare(t,i)>0){const e=await $http.get("https://raw.githubusercontent.com/ipuppet/EasyJsBox/dev/dist/easy-jsbox.js");if(e.error)throw e.error;return e.data}return!1}}r.l10n("zh-Hans",{DELETE_CONFIRM_TITLE:"删除前确认"},!1),r.l10n("en",{DELETE_CONFIRM_TITLE:"Delete Confirmation"},!1),e.exports={Kernel:r}})),parcelRequire.register("czAIJ",(function(e,t){e.exports={VERSION:"1.3.3"}})),parcelRequire.register("aXWmO",(function(e,t){var i=parcelRequire("6Xrbz").ValidationError,r=parcelRequire("liCrE").View,s=parcelRequire("45Ip7").UIKit,a=parcelRequire("12xzj").NavigationView,n=parcelRequire("dcStC").NavigationBar,o=parcelRequire("gAYmG").BarButtonItem;class l extends Error{constructor(){super("Please call setView(view) first."),this.name="SheetAddNavBarError"}}class c extends i{constructor(e,t){super(e,t),this.name="SheetViewTypeError"}}class h extends r{#p=()=>{};#u=()=>{};style=h.UIModalPresentationStyle.PageSheet;#g=!1;static UIModalPresentationStyle={Automatic:-2,FullScreen:0,PageSheet:1,FormSheet:2,CurrentContext:3,Custom:4,OverFullScreen:5,OverCurrentContext:6,Popover:7,BlurOverFullScreen:8};navigationView;init(){const{width:e,height:t}=$device.info.screen,i=$objc("UIView").invoke("initWithFrame",$rect(0,0,e,t)),r=$objc("UIViewController").invoke("alloc.init"),a=r.$view();return a.$setBackgroundColor(s.primaryViewBackgroundColor),a.$addSubview(i),r.$setModalPresentationStyle(this.style),r.$setModalInPresentation(this.#g),this.#p=()=>{a.jsValue().add(this.navigationView?.getPage().definition??this.view),$ui.vc.ocValue().invoke("presentViewController:animated:completion:",r,!0,void 0)},this.#u=()=>r.invoke("dismissViewControllerAnimated:completion:",!0,void 0),this}preventDismiss(){return this.#g=!0,this}setStyle(e){return this.style=e,this}setView(e={}){if("object"!=typeof e)throw new c("view","object");return this.view=e,this}addNavBar({title:e="",popButton:t={title:$l10n("DONE")},rightButtons:i=[]}={}){if(void 0===this.view)throw new l;this.navigationView=new a;const r=new o;r.setEvents(Object.assign({tapped:()=>{this.dismiss(),"function"==typeof t.tapped&&t.tapped()}},t.events)).setAlign(s.align.left).setSymbol(t.symbol).setTitle(t.title).setColor(t.color).setMenu(t.menu);const c=r.definition.views[0];return c.layout=(e,t)=>{e.left.equalTo(t.super.safeArea).offset(15),e.centerY.equalTo(t.super.safeArea)},this.navigationView.navigationBar.setLargeTitleDisplayMode(n.largeTitleDisplayModeNever).pageSheetMode(),this.navigationView.navigationBarItems.addPopButton("",c).setRightButtons(i),this.navigationView.setView(this.view).navigationBarTitle(e),this.view.props?.bgcolor&&this.navigationView?.getPage().setProp("bgcolor",this.view.props?.bgcolor),this}present(){this.#p()}dismiss(){this.#u()}}e.exports={Sheet:h}})),parcelRequire.register("6Xrbz",(function(e,t){class i extends Error{constructor(e,t){super(`The type of the parameter '${e}' must be '${t}'`),this.name="ValidationError"}}e.exports={ValidationError:i}})),parcelRequire.register("liCrE",(function(e,t){var i=parcelRequire("45Ip7").UIKit;class r{id=$text.uuid;type;props;views;events;layout;#$=void 0;#f=null;constructor({type:e="view",props:t={},views:i=[],events:r={},layout:s=$layout.fill}={}){this.type=e,this.props=t,this.views=i,this.events=r,this.layout=s,this.props.id?this.id=this.props.id:this.props.id=this.id}static create(e){return new this(e)}static createFromViews(e){return new this({views:e})}get scrollableView(){return this.scrollable?this.#f:null}set scrollableView(e){this.#f=e}get scrollable(){if(void 0===this.#$)if(this.#$=!1,i.scrollViewList.indexOf(this.type)>-1)this.scrollableView=this,this.#$=!0;else if(this.views.length>0){const e=t=>{if(!this.#$&&t?.length>0)for(let s=0;s-1)return typeof t[s]!==r&&(t[s]=r.create(t[s])),this.scrollableView=t[s],void(this.#$=!0);e(t[s].views)}};e(this.views)}return this.#$}set scrollable(e){throw new Error("[scrollable] is readonly prop.")}setProps(e){return Object.keys(e).forEach((t=>this.setProp(t,e[t]))),this}setProp(e,t){return"id"===e&&(this.id=t),this.props[e]=t,this}setViews(e){return this.views=e,this.#$=void 0,this}setEvents(e){return Object.keys(e).forEach((t=>this.setEvent(t,e[t]))),this}setEvent(e,t){return this.events[e]=t,this}eventMiddleware(e,t){const i=this.events[e];return this.events[e]=(...e)=>{"function"==typeof i&&t(i,...e)},this}assignEvent(e,t){const i=this.events[e];return this.events[e]=(...e)=>{"function"==typeof i&&i(...e),t(...e)},this}setLayout(e){return this.layout=e,this}getView(){return this}get definition(){return this.getView()}}e.exports={View:r,PageView:class extends r{constructor(e={}){super(e),this.activeStatus=!0}show(){$(this.props.id).hidden=!1,this.activeStatus=!0}hide(){$(this.props.id).hidden=!0,this.activeStatus=!1}setHorizontalSafeArea(e){return this.horizontalSafeArea=e,this}#b(e,t){e.top.bottom.equalTo(t.super),this.horizontalSafeArea?e.left.right.equalTo(t.super.safeArea):e.left.right.equalTo(t.super)}getView(){return this.layout=this.#b,this.props.clipsToBounds=!0,this.props.hidden=!this.activeStatus,super.getView()}}}})),parcelRequire.register("12xzj",(function(e,t){var i=parcelRequire("fYz8N").Controller,r=parcelRequire("liCrE"),s=r.View,a=r.PageView,n=parcelRequire("6Xrbz").ValidationError,o=parcelRequire("cgaQ6").Kernel,l=parcelRequire("45Ip7").UIKit,c=parcelRequire("dcStC"),h=c.NavigationBar,d=c.NavigationBarController,p=parcelRequire("gAYmG").NavigationBarItems;class u extends n{constructor(e,t){super(e,t),this.name="NavigationViewTypeError"}}e.exports={NavigationView:class extends i{page;navigationController=new d;navigationBar=new h;navigationBarItems=new p;constructor(){super(),this.navigationBar.navigationBarItems=this.navigationBarItems,this.navigationController.navigationBar=this.navigationBar}navigationBarTitle(e){return this.navigationBar.setTitle(e),this}setView(e){if("object"!=typeof e)throw new u("view","object");return this.view=s.create(e),this}#y(){if(!(this.view instanceof s))throw new u("view","View");const e=this.view.scrollableView,t=$app.isDebugging||o.isTaio?0:l.topSafeAreaInsets,i=this.navigationBar.largeTitleDisplayMode===h.largeTitleDisplayModeNever?this.navigationBar.navigationBarNormalHeight:this.navigationBar.navigationBarLargeTitleHeight;let r=this.navigationBar.contentViewHeightOffset+i;if(this.navigationBarItems.titleView&&(r+=this.navigationBarItems.titleView.topOffset,r+=this.navigationBarItems.titleView.height,r+=this.navigationBarItems.titleView.bottomOffset),!this.view.scrollable||!1===e.props.associateWithNavigationBar)return void(this.view.layout=(e,i)=>{e.left.right.equalTo(i.super.safeArea),e.bottom.equalTo(i.super);let s=r-this.navigationBar.contentViewHeightOffset;l.isHorizontal&&!l.isLargeScreen||!this.navigationBar.topSafeArea||(s+=t),e.top.equalTo(s)});e.props.stickyHeader&&(r-=i,r+=this.navigationBar.largeTitleFontHeight),e.props.header?e.props.header={type:"view",props:{height:r+(e.props.header?.props?.height??0)},views:[{type:"view",props:{clipsToBounds:!0},views:[e.props.header],layout:(e,t)=>{e.top.equalTo(r),e.bottom.width.equalTo(t.super)}}]}:e.props.header={props:{height:r}},e.props.footer=Object.assign({props:{}},e.props.footer??{}),e.props.footer.props.height=(this.navigationBarItems.fixedFooterView?.height??0)+(e.props.footer.props?.height??0);const a=this.navigationBarItems.isPinTitleView?this.navigationBarItems.titleView.height+this.navigationBarItems.titleView.bottomOffset+this.navigationBar.contentViewHeightOffset:0;if(e.props.indicatorInsets){const t=e.props.indicatorInsets;e.props.indicatorInsets=$insets(t.top+this.navigationBar.navigationBarNormalHeight+a,t.left,t.bottom+(this.navigationBarItems.fixedFooterView?.height??0),t.right)}else e.props.indicatorInsets=$insets(this.navigationBar.navigationBarNormalHeight+a,0,this.navigationBarItems.fixedFooterView?.height??0,0);e.layout=(t,i)=>{e.props.stickyHeader?t.top.equalTo(i.super.safeArea).offset(this.navigationBar.navigationBarNormalHeight):t.top.equalTo(i.super),t.left.right.equalTo(i.super.safeArea),t.bottom.equalTo(i.super)},e.assignEvent("didScroll",(i=>{let r=i.contentOffset.y;l.isHorizontal&&!l.isLargeScreen||!this.navigationBar.topSafeArea||e.props.stickyHeader||(r+=t),this.navigationController.didScroll(r)})).assignEvent("didEndDragging",((i,r)=>{let s=i.contentOffset.y,a=0;l.isHorizontal&&!l.isLargeScreen||!this.navigationBar.topSafeArea||e.props.stickyHeader||(s+=t,a=t),this.navigationController.didEndDragging(s,r,((...e)=>i.scrollToOffset(...e)),a)})).assignEvent("didEndDecelerating",((...t)=>{t[0].tracking||e.events?.didEndDragging(...t)}))}#m(){if(this.navigationBar.prefersLargeTitles){this.#y();let e={};if(this.navigationBarItems.titleView){const t=this.navigationBar.largeTitleDisplayMode===h.largeTitleDisplayModeNever?1:0;e=s.create({views:[this.navigationBar.backgroundColor?{type:"view",props:{alpha:t,bgcolor:this.navigationBar.backgroundColor,id:this.navigationBar.id+"-title-view-background"},layout:$layout.fill}:l.blurBox({alpha:t,id:this.navigationBar.id+"-title-view-background"}),l.separatorLine({id:this.navigationBar.id+"-title-view-underline",alpha:t}),this.navigationBarItems.titleView.definition],layout:(e,t)=>{e.top.equalTo(t.prev.bottom),e.width.equalTo(t.super),e.height.equalTo(this.navigationBarItems.titleView.topOffset+this.navigationBarItems.titleView.height+this.navigationBarItems.titleView.bottomOffset)}})}this.page=a.createFromViews([this.view,this.navigationBar.getLargeTitleView(),e,this.navigationBar.getNavigationBarView(),this.navigationBarItems.fixedFooterView?.definition??{}])}else this.page=a.createFromViews([this.view]);this.view.props?.bgcolor?this.page.setProp("bgcolor",this.view.props.bgcolor):this.page.setProp("bgcolor",l.defaultBackgroundColor(this.view.type))}getPage(){return this.page||this.#m(),this.page}}}})),parcelRequire.register("dcStC",(function(e,t){var i=parcelRequire("liCrE").View,r=parcelRequire("fYz8N").Controller,s=parcelRequire("45Ip7").UIKit;parcelRequire("gAYmG").BarButtonItem;class a extends i{static largeTitleDisplayModeAutomatic=0;static largeTitleDisplayModeAlways=1;static largeTitleDisplayModeNever=2;static pageSheetNavigationBarHeight=56;navigationBarItems;title="";prefersLargeTitles=!0;largeTitleDisplayMode=a.largeTitleDisplayModeAutomatic;largeTitleFontSize=34;largeTitleFontFamily="bold";largeTitleFontHeight=$text.sizeThatFits({text:"A",width:100,font:$font(this.largeTitleFontFamily,this.largeTitleFontSize)}).height;navigationBarTitleFontSize=17;topSafeArea=!0;contentViewHeightOffset=10;navigationBarNormalHeight=s.NavigationBarNormalHeight;navigationBarLargeTitleHeight=s.NavigationBarLargeTitleHeight;pageSheetMode(){return this.navigationBarLargeTitleHeight-=this.navigationBarNormalHeight,this.navigationBarNormalHeight=a.pageSheetNavigationBarHeight,this.navigationBarLargeTitleHeight+=this.navigationBarNormalHeight,this.topSafeArea=!1,this}setTopSafeArea(){return this.topSafeArea=!0,this}removeTopSafeArea(){return this.topSafeArea=!1,this}setLargeTitleDisplayMode(e){return this.largeTitleDisplayMode=e,this}setBackgroundColor(e){return this.backgroundColor=e,this}setTitle(e){return this.title=e,this}setPrefersLargeTitles(e){return this.prefersLargeTitles=e,this}setContentViewHeightOffset(e){return this.contentViewHeightOffset=e,this}getLargeTitleView(){return this.prefersLargeTitles&&this.largeTitleDisplayMode!==a.largeTitleDisplayModeNever?{type:"label",props:{id:this.id+"-large-title",text:this.title,textColor:s.textColor,align:$align.left,font:$font(this.largeTitleFontFamily,this.largeTitleFontSize),line:1},layout:(e,t)=>{e.left.equalTo(t.super.safeArea).offset(15),e.height.equalTo(this.largeTitleFontHeight),e.top.equalTo(t.super.safeAreaTop).offset(this.navigationBarNormalHeight)}}:{props:{id:this.id+"-large-title"},layout:(e,t)=>{e.left.top.right.inset(0),e.bottom.equalTo(t.super.safeAreaTop).offset(this.navigationBarNormalHeight)}}}getNavigationBarView(){const e=(e,t)=>{let i=0;const r=[];return e.forEach((e=>{i+=e.width,r.push(e.definition)})),i+=e[0]?.edges??0,e.length>0?{type:"view",views:r,layout:(e,r)=>{e.top.equalTo(r.super.safeAreaTop),e.bottom.equalTo(r.super.safeAreaTop).offset(this.navigationBarNormalHeight),t===s.align.left?e.left.equalTo(r.super.safeArea):e.right.equalTo(r.super.safeArea),e.width.equalTo(i)}}:{}},t=e(this.navigationBarItems.rightButtons,s.align.right),i=this.navigationBarItems.popButtonView??e(this.navigationBarItems.leftButtons,s.align.left),r=this.prefersLargeTitles,n=!this.prefersLargeTitles||this.largeTitleDisplayMode===a.largeTitleDisplayModeNever;return{type:"view",props:{id:this.id+"-navigation",bgcolor:$color("clear")},layout:(e,t)=>{e.left.top.right.inset(0),e.bottom.equalTo(t.super.safeAreaTop).offset(this.navigationBarNormalHeight)},views:[this.backgroundColor?{type:"view",props:{hidden:r,bgcolor:this.backgroundColor,id:this.id+"-background"},layout:$layout.fill}:s.blurBox({hidden:r,id:this.id+"-background"}),s.separatorLine({id:this.id+"-underline",alpha:r?0:1}),{type:"view",props:{alpha:0,bgcolor:$color("clear"),id:this.id+"-large-title-mask"},events:{ready:e=>{e.bgcolor=$(this.id+"-large-title")?.prev.bgcolor}},layout:$layout.fill},{type:"label",props:{id:this.id+"-small-title",alpha:n?1:0,text:this.title,font:$font(this.largeTitleFontFamily,this.navigationBarTitleFontSize),align:$align.center,bgcolor:$color("clear"),textColor:s.textColor},layout:(e,t)=>{e.left.right.inset(0),e.height.equalTo(20),e.centerY.equalTo(t.super.safeArea)}}].concat(t,i)}}}class n extends r{static largeTitleViewSmallMode=0;static largeTitleViewLargeMode=1;navigationBar;updateSelector(){this.selector={navigation:$(this.navigationBar.id+"-navigation"),largeTitleView:$(this.navigationBar.id+"-large-title"),smallTitleView:$(this.navigationBar.id+"-small-title"),underlineView:this.navigationBar.navigationBarItems.isPinTitleView?$(this.navigationBar.id+"-title-view-underline"):$(this.navigationBar.id+"-underline"),largeTitleMaskView:$(this.navigationBar.id+"-large-title-mask"),backgroundView:$(this.navigationBar.id+"-background"),titleViewBackgroundView:$(this.navigationBar.id+"-title-view-background")}}toNormal(e=!0){this.updateSelector(),this.selector.backgroundView.hidden=!1,$ui.animate({duration:.2,animation:()=>{this.selector.underlineView.alpha=1,this.selector.smallTitleView.alpha=1,this.selector.largeTitleView.alpha=0}}),e&&this.navigationBar.navigationBarItems&&(this.navigationBar.largeTitleDisplayMode=a.largeTitleDisplayModeNever)}toLargeTitle(e=!0){this.updateSelector(),this.selector.backgroundView.hidden=!0,$ui.animate({duration:.2,animation:()=>{this.selector.underlineView.alpha=0,this.selector.smallTitleView.alpha=0,this.selector.largeTitleView.alpha=1}}),e&&this.navigationBar.navigationBarItems&&(this.navigationBar.largeTitleDisplayMode=a.largeTitleDisplayModeAlways)}#v(e){const t=e===n.largeTitleViewSmallMode;this.selector.largeTitleView.alpha=t?0:1,$ui.animate({duration:.2,animation:()=>{this.selector.smallTitleView.alpha=t?1:0}})}#w(e){if(this.selector.largeTitleView.updateLayout(((t,i)=>{this.navigationBar.navigationBarNormalHeight-e>0?t.top.equalTo(i.super.safeAreaTop).offset(this.navigationBar.navigationBarNormalHeight-e):t.top.equalTo(i.super.safeAreaTop).offset(0)})),e>0)e>=this.navigationBar.navigationBarNormalHeight?this.#v(n.largeTitleViewSmallMode):this.#v(n.largeTitleViewLargeMode);else{this.#v(n.largeTitleViewLargeMode);let t=this.navigationBar.largeTitleFontSize-.04*e;t>40&&(t=40),this.selector.largeTitleView.font=$font(this.navigationBar.largeTitleFontFamily,t)}}#T(e){const t=this.navigationBar.largeTitleDisplayMode===a.largeTitleDisplayModeNever?5:this.navigationBar.navigationBarNormalHeight,i=void 0!==this.selector.titleViewBackgroundView;if(e>t){this.selector.backgroundView.hidden=!1;const r=()=>{i&&this.navigationBar.navigationBarItems.isPinTitleView&&(this.selector.titleViewBackgroundView.alpha=1),this.selector.largeTitleMaskView.alpha=0,this.selector.underlineView.alpha=1};(e-t)/3>=1?r():$ui.animate({duration:.2,animation:()=>{r()}})}else this.selector.largeTitleMaskView.alpha=e>0?1:0,this.selector.underlineView.alpha=0,i&&(this.selector.titleViewBackgroundView.alpha=0),this.selector.backgroundView.hidden=!0}didScroll(e){if(!this.navigationBar.prefersLargeTitles)return;const t=this.navigationBar.largeTitleDisplayMode;t!==a.largeTitleDisplayModeAlways&&(this.updateSelector(),t===a.largeTitleDisplayModeAutomatic?(!this.navigationBar.navigationBarItems?.isPinTitleView&&(this.navigationBar.navigationBarItems?.titleView?.controller.didScroll(e),e>0)&&(e-=this.navigationBar.navigationBarItems?.titleView?.height??0)<0&&(e=0),this.#w(e),this.#T(e)):t===a.largeTitleDisplayModeNever&&this.#T(e))}didEndDragging(e,t,i,r){if(!this.navigationBar.prefersLargeTitles)return;const s=this.navigationBar.largeTitleDisplayMode;if(s!==a.largeTitleDisplayModeAlways&&(this.updateSelector(),s===a.largeTitleDisplayModeAutomatic)){let s=0;this.navigationBar.navigationBarItems?.isPinTitleView||(this.navigationBar.navigationBarItems?.titleView?.controller.didEndDragging(e,t,i,r),s=this.navigationBar.navigationBarItems?.titleView?.height??0,e-=s),e>=0&&e<=this.navigationBar.largeTitleFontHeight&&i($point(0,e>=this.navigationBar.largeTitleFontHeight/2?this.navigationBar.navigationBarNormalHeight+s-r:s-r))}}}e.exports={NavigationBar:a,NavigationBarController:n}})),parcelRequire.register("gAYmG",(function(e,t){var i=parcelRequire("liCrE").View,r=parcelRequire("45Ip7").UIKit;class s extends i{static#E;edges=15;iconSize=$size(23,23);fontSize=16;color=r.textColor;title;symbol;align=r.align.right;get width(){if(this.title){const e=$text.sizeThatFits({text:this.title,width:r.windowSize.width,font:$font(this.fontSize)});return Math.ceil(e.width)+this.edges}return this.iconSize.width+this.edges}static get style(){return void 0===this.#E&&(this.#E=new s),this.#E}setEdges(e){return this.edges=e,this}setFontSize(e){return this.fontSize=e,this}setColor(e=r.textColor){return this.color=e,this}setTitle(e){return this.title=e,this}setSymbol(e){return this.symbol=e,this}setMenu(e){return this.menu=e,this}setAlign(e){return this.align=e,this}#I(){$(this.id).hidden=!0,$("spinner-"+this.id).hidden=!1}#C(){const e=$(`icon-button-${this.id}`),t=$(`icon-checkmark-${this.id}`);e.alpha=0,$(this.id).hidden=!1,$("spinner-"+this.id).hidden=!0,$ui.animate({duration:.6,animation:()=>{t.alpha=1},completion:()=>{$delay(.3,(()=>$ui.animate({duration:.6,animation:()=>{t.alpha=0},completion:()=>{$ui.animate({duration:.4,animation:()=>{e.alpha=1},completion:()=>{e.alpha=1}})}})))}})}#A(){$(this.id).hidden=!1,$("spinner-"+this.id).hidden=!0}getView(){const e=this.events.tapped;return this.events.tapped=t=>{e&&e({start:()=>this.#I(),done:()=>this.#C(),cancel:()=>this.#A()},t)},{type:"view",props:{info:{align:this.align}},views:[{type:"button",props:Object.assign({id:this.id,bgcolor:$color("clear"),font:$font(this.fontSize),titleColor:this.color,contentEdgeInsets:$insets(0,0,0,0),titleEdgeInsets:$insets(0,0,0,0),imageEdgeInsets:$insets(0,0,0,0)},this.menu?{menu:this.menu}:{},this.title?{title:this.title}:{},this.props),views:[{type:"image",props:Object.assign({id:`icon-button-${this.id}`,hidden:void 0===this.symbol,tintColor:this.color},void 0===this.symbol?{}:"string"==typeof this.symbol?{symbol:this.symbol}:{data:this.symbol.png}),layout:(e,t)=>{e.center.equalTo(t.super),e.size.equalTo(this.iconSize)}},{type:"image",props:{id:`icon-checkmark-${this.id}`,alpha:0,tintColor:this.color,symbol:"checkmark"},layout:(e,t)=>{e.center.equalTo(t.super),e.size.equalTo(this.iconSize)}}],events:this.events,layout:$layout.fill},{type:"spinner",props:{id:"spinner-"+this.id,loading:!0,hidden:!0},layout:$layout.fill}],layout:(e,t)=>{if(e.size.equalTo($size(this.width,r.NavigationBarNormalHeight)),e.centerY.equalTo(t.super),t.prev&&t.prev?.info?.align===this.align)this.align===r.align.right?e.right.equalTo(t.prev.left):e.left.equalTo(t.prev.right);else{const t=this.edges/2;this.align===r.align.right?e.right.inset(t):e.left.inset(t)}}}}static creat({symbol:e,title:t,tapped:i,menu:a,events:n,color:o,align:l=r.align.right}={}){const c=new s;return c.setEvents(Object.assign({tapped:i},n)).setAlign(l).setSymbol(e).setTitle(t).setColor(o).setMenu(a),c}}e.exports={BarTitleView:class extends i{controller={};setController(e){return this.controller=e,this}},BarButtonItem:s,NavigationBarItems:class{rightButtons=[];leftButtons=[];hasbutton=!1;isPinTitleView=!1;setTitleView(e){return this.titleView=e,this}pinTitleView(){return this.isPinTitleView=!0,this}setFixedFooterView(e){return this.fixedFooterView=e,this}setRightButtons(e){return e.forEach((e=>this.addRightButton(e))),this.hasbutton||(this.hasbutton=!0),this}setLeftButtons(e){return e.forEach((e=>this.addLeftButton(e))),this.hasbutton||(this.hasbutton=!0),this}addRightButton({symbol:e,title:t,tapped:i,menu:a,events:n,color:o}={}){return this.rightButtons.push(s.creat({symbol:e,title:t,tapped:i,menu:a,events:n,color:o,align:r.align.right})),this.hasbutton||(this.hasbutton=!0),this}addLeftButton({symbol:e,title:t,tapped:i,menu:a,events:n,color:o}={}){return this.leftButtons.push(s.creat({symbol:e,title:t,tapped:i,menu:a,events:n,color:o,align:r.align.left})),this.hasbutton||(this.hasbutton=!0),this}addPopButton(e,t,i){return e||(e=$l10n("BACK")),this.popButtonView=t??{type:"button",props:{bgcolor:$color("clear"),symbol:"chevron.left",tintColor:r.linkColor,title:` ${e}`,titleColor:r.linkColor,font:$font("bold",16)},layout:(e,t)=>{e.left.equalTo(t.super.safeArea).offset(s.style.edges),e.centerY.equalTo(t.super.safeArea)},events:{tapped:()=>{$ui.pop(),"function"==typeof i&&i()}}},this}removePopButton(){return this.popButtonView=void 0,this}}}})),parcelRequire.register("gMc1q",(function(e,t){var i=parcelRequire("fYz8N").Controller;e.exports={ViewController:class extends i{#S=[];#x(e){e.callEvent("onPop"),this.callEvent("onPop",e),this.#S.pop()}push(e){const t=this.#S[this.#S.length-1];e.navigationBarItems.addPopButton(t?.navigationBar.title),this.#S.push(e),$ui.push({props:{statusBarStyle:0,navBarHidden:!0},events:{dealloc:()=>{this.#x(e)}},views:[e.getPage().definition],layout:$layout.fill})}}}})),String.prototype.trim=function(e,t){return e?"l"===t?this.replace(new RegExp("^\\"+e+"+","g"),""):"r"===t?this.replace(new RegExp("\\"+e+"+$","g"),""):this.replace(new RegExp("^\\"+e+"+|\\"+e+"+$","g"),""):this.replace(/^\s+|\s+$/g,"")};var $czAIJ=parcelRequire("czAIJ"),$bb0fea222fc5aea5$require$VERSION=$czAIJ.VERSION,$fYz8N=parcelRequire("fYz8N"),$bb0fea222fc5aea5$require$Controller=$fYz8N.Controller,$272f042430a952c6$exports={},$45Ip7=parcelRequire("45Ip7"),$272f042430a952c6$require$UIKit=$45Ip7.UIKit,$aXWmO=parcelRequire("aXWmO"),$272f042430a952c6$require$Sheet=$aXWmO.Sheet,$cgaQ6=parcelRequire("cgaQ6"),$272f042430a952c6$require$Kernel=$cgaQ6.Kernel,$12xzj=parcelRequire("12xzj"),$272f042430a952c6$require$NavigationView=$12xzj.NavigationView,$dcStC=parcelRequire("dcStC"),$272f042430a952c6$require$NavigationBar=$dcStC.NavigationBar;class $272f042430a952c6$var$FileManager{viewController;constructor(){this.listId="file-manager-list",this.edges=10,this.iconSize=25,this.loadL10n()}loadL10n(){$272f042430a952c6$require$Kernel.l10n("zh-Hans",{FILE_MANAGER_DELETE_CONFIRM_MSG:"确认要删除吗",DELETE:"删除",CANCEL:"取消",CLOSE:"关闭",SHARE:"分享",SAVE:"保存",SAVE_SUCCESS:"保存成功"},!1),$272f042430a952c6$require$Kernel.l10n("en",{FILE_MANAGER_DELETE_CONFIRM_MSG:"Are you sure you want to delete",DELETE:"Delete",CANCEL:"Cancel",CLOSE:"Close",SHARE:"Share",SAVE:"Save",SAVE_SUCCESS:"Save Success"},!1)}setViewController(e){this.viewController=e}get menu(){return{items:[{title:$l10n("SHARE"),symbol:"square.and.arrow.up",handler:async(e,t)=>{const i=e.object(t).info.info;$share.sheet([$file.absolutePath(i.path)])}}]}}delete(e){$file.delete(e.path)}edit(e){const t=$file.read(e.path);if(t.image)$quicklook.open({image:t.image});else{const i=new $272f042430a952c6$require$Sheet,r=$text.uuid;i.setView({type:"code",layout:$layout.fill,props:{id:r,lineNumbers:!0,theme:$device.isDarkMode?"atom-one-dark":"atom-one-light",text:t.string,insets:$insets(15,15,15,15)}}).addNavBar({title:e.file,popButton:{title:$l10n("CLOSE")},rightButtons:[{title:$l10n("SAVE"),tapped:()=>{$file.write({data:$data({string:$(r).text}),path:e.path}),$ui.success($l10n("SAVE_SUCCESS"))}}]}),i.init().present()}}getFiles(e=""){return $file.list(e).map((t=>{const i=e+"/"+t,r=$file.isDirectory(i);return{info:{info:{path:i,file:t,isDirectory:r}},icon:{symbol:r?"folder.fill":"doc"},name:{text:t},size:{text:r?"":"--"}}})).sort(((e,t)=>e.info.info.isDirectory!==t.info.info.isDirectory?e.info.info.isDirectory?-1:1:e.info.info.isDirectory===t.info.info.isDirectory?e.info.info.file.localeCompare(t.info.info.file):void 0))}async loadFileSize(e){return e.map(((t,i)=>{const r=t.info.info;if(!r.isDirectory)try{e[i].size.text=$272f042430a952c6$require$Kernel.bytesToSize($file.read(r.path).info.size)}catch(t){e[i].size.text=t}})),e}get listTemplate(){return{props:{bgcolor:$color("clear")},views:[{props:{id:"info"}},{type:"image",props:{id:"icon"},layout:(e,t)=>{e.centerY.equalTo(t.super),e.left.inset(this.edges),e.size.equalTo(this.iconSize)}},{type:"label",props:{id:"name",lines:1},layout:(e,t)=>{e.centerY.equalTo(t.super),e.left.equalTo(t.prev.right).offset(this.edges)}},{type:"label",props:{id:"size",color:$color("secondaryText"),lines:1},layout:(e,t)=>{e.centerY.equalTo(t.super),e.right.inset(this.edges)}}]}}#k(e,t){if(this.viewController){const i=new $272f042430a952c6$require$NavigationView;i.setView(t).navigationBarTitle(e),i.navigationBar.setLargeTitleDisplayMode($272f042430a952c6$require$NavigationBar.largeTitleDisplayModeNever),this.viewController.push(i)}else $272f042430a952c6$require$UIKit.push({title:e,views:[t]})}getListView(e=""){return{type:"list",props:{id:this.listId,menu:this.menu,info:{basePath:e},bgcolor:$272f042430a952c6$require$UIKit.primaryViewBackgroundColor,separatorInset:$insets(0,this.edges,0,0),data:[],template:this.listTemplate,actions:[{title:" "+$l10n("DELETE")+" ",color:$color("red"),handler:(e,t)=>{const i=e.object(t).info.info;$272f042430a952c6$require$Kernel.deleteConfirm($l10n("FILE_MANAGER_DELETE_CONFIRM_MSG")+' "'+i.file+'" ?',(()=>{this.delete(i),e.delete(t)}))}}]},layout:$layout.fill,events:{ready:()=>{const t=this.getFiles(e);$(this.listId).data=t,this.loadFileSize(t).then((e=>{$(this.listId).data=e}))},pulled:async e=>{const t=this.getFiles($(this.listId).info.basePath);$(this.listId).data=t,$(this.listId).data=await this.loadFileSize(t),$delay(.5,(()=>{e.endRefreshing()}))},didSelect:(e,t,i)=>{const r=i.info.info;r.isDirectory?this.#k(r.file,this.getListView(r.path)):this.edit(r)}}}}push(e=""){const t=e.substring(e.lastIndexOf("/"));this.#k(t,this.getListView(e))}}$272f042430a952c6$exports={FileManager:$272f042430a952c6$var$FileManager};var $bb0fea222fc5aea5$require$FileManager=$272f042430a952c6$exports.FileManager,$8aDdQ=parcelRequire("8aDdQ"),$bb0fea222fc5aea5$require$FileStorageParameterError=$8aDdQ.FileStorageParameterError,$bb0fea222fc5aea5$require$FileStorageFileNotFoundError=$8aDdQ.FileStorageFileNotFoundError,$bb0fea222fc5aea5$require$FileStorage=$8aDdQ.FileStorage,$4c192cc93140b629$exports={},$liCrE=parcelRequire("liCrE"),$4c192cc93140b629$require$View=$liCrE.View,$45Ip7=parcelRequire("45Ip7"),$4c192cc93140b629$require$UIKit=$45Ip7.UIKit;class $4c192cc93140b629$var$FixedFooterView extends $4c192cc93140b629$require$View{height=60;getView(){return this.type="view",this.setProp("bgcolor",$4c192cc93140b629$require$UIKit.primaryViewBackgroundColor),this.layout=(e,t)=>{e.left.right.bottom.equalTo(t.super),e.top.equalTo(t.super.safeAreaBottom).offset(-this.height)},this.views=[$4c192cc93140b629$require$View.create({props:this.props,views:this.views,layout:(e,t)=>{e.left.right.top.equalTo(t.super),e.height.equalTo(this.height)}})],this}}$4c192cc93140b629$exports={FixedFooterView:$4c192cc93140b629$var$FixedFooterView};var $bb0fea222fc5aea5$require$FixedFooterView=$4c192cc93140b629$exports.FixedFooterView,$cgaQ6=parcelRequire("cgaQ6"),$bb0fea222fc5aea5$require$Kernel=$cgaQ6.Kernel,$50aa538fe0dbd3b0$exports={},$liCrE=parcelRequire("liCrE"),$50aa538fe0dbd3b0$require$View=$liCrE.View;class $50aa538fe0dbd3b0$var$Matrix extends $50aa538fe0dbd3b0$require$View{titleStyle={font:$font("bold",21),height:30};#B;#q;templateIdByIndex(e){return void 0===this.props.template.views[e]?.props?.id&&(void 0===this.props.template.views[e].props&&(this.props.template.views[e].props={}),this.props.template.views[e].props.id=$text.uuid),this.props.template.views[e].props.id}get templateHiddenStatus(){if(!this.#q){this.#q={};for(let e=0;e(e.items=e.items.map((e=>(Object.keys(e).forEach((t=>{e[t].hidden=this.templateHiddenStatus[t]??!1})),Object.keys(this.templateHiddenStatus).forEach((t=>{e[t]||(e[t]={}),e[t].hidden=this.templateHiddenStatus[t]})),e.__templateProps={hidden:!1},e.__title={hidden:!0},e))),e.title&&e.items.unshift(this.#R(e.title)),e)))}rebuildTemplate(){let e={};void 0!==this.props.template.props&&(e=Object.assign(this.props.template.props,{id:"__templateProps",hidden:!1})),this.props.template.props={};const t=[{type:"view",props:e,layout:$layout.fill},{type:"label",props:{id:"__title",hidden:!0,font:this.titleStyle.font},layout:(e,t)=>{e.top.inset(-this.titleStyle.height/4*3),e.height.equalTo(this.titleStyle.height),e.width.equalTo(t.super.safeArea)}}].concat(this.props.template.views);this.props.template.views=t}insert(e,t=!0){return e.indexPath=this.indexPath(e.indexPath,t),$(this.id).insert(e)}delete(e,t=!0){return e=this.indexPath(e,t),$(this.id).delete(e)}object(e,t=!0){return e=this.indexPath(e,t),$(this.id).object(e)}cell(e,t=!0){return e=this.indexPath(e,t),$(this.id).cell(e)}indexPath(e,t){let i=t?0:1;return"number"==typeof e&&(e=$indexPath(0,e)),$indexPath(e.section,e.row+i)}update(e){this.props.data=this.rebuildData(e),$(this.id).data=this.props.data}getView(){return this.props.data=this.rebuildData(this.props.data),this.rebuildTemplate(),this.setEvent("itemSize",((e,t)=>{const i=e.object(t)?.__title?.info;if(i?.title)return $size(Math.max($device.info.screen.width,$device.info.screen.height),0);const r=this.props.columns??2,s=this.props.spacing??15,a=this.props.itemWidth??this.props.itemSize?.width??(e.super.frame.width-s*(r+1))/r,n=this.props.itemHeight??this.props.itemSize?.height??100;return $size(a,n)})),this}}$50aa538fe0dbd3b0$exports={Matrix:$50aa538fe0dbd3b0$var$Matrix};var $bb0fea222fc5aea5$require$Matrix=$50aa538fe0dbd3b0$exports.Matrix,$619319e3f3656d3f$exports={};class $619319e3f3656d3f$var$Request{static method={get:"GET",post:"POST",delete:"DELETE",patch:"PATCH",head:"HEAD"};cacheContainerKey=$addin?.current?.name+".request.cache";#D=!1;#O=!1;cacheLife=2592e6;isLogRequest=!1;timeout=5;logger;constructor(e){"function"==typeof e&&(this.logger=e)}get cache(){return $cache.get(this.cacheContainerKey)??{}}#N(e){this.isLogRequest&&"function"==typeof logger&&this.logger(e)}logRequest(e){return this.isLogRequest=!0,"function"==typeof e&&(this.logger=e),this}getCacheKey(e){return $text.MD5(e)}getCache(e,t=null){return this.cache[e]??t}setCache(e,t){if(!t)return;const i=this.cache;i[e]=t,$cache.set(this.cacheContainerKey,i)}removeCache(e){let t=this.cache;delete t[e],$cache.set(this.cacheContainerKey,t)}clearCache(){$cache.remove(this.cacheContainerKey)}useCache(){return this.#D=!0,this}ignoreCacheExp(){this.#O=!0}async request(e,t,i={},r={},s=this.cacheLife){let a;const n=this.#D&&t===$619319e3f3656d3f$var$Request.method.get;if(n){a=this.getCacheKey(e);const t=this.getCache(a);if(t&&(this.#O||t.exp>Date.now()))return this.#N("get data from cache: "+e),t.data}try{this.#N(`sending request [${t}]: ${e}`);const o=await $http.request({header:r,url:e,method:t,body:i,timeout:this.timeout});if(o.error)throw o.error;if(o?.response?.statusCode>=400){let e=o.data;throw"object"==typeof e&&(e=JSON.stringify(e)),new Error("http error: ["+o.response.statusCode+"] "+e)}return n&&this.setCache(a,{exp:Date.now()+s,data:o}),o}catch(e){throw e.code&&(e=new Error("network error: ["+e.code+"] "+e.localizedDescription)),e}}}$619319e3f3656d3f$exports={Request:$619319e3f3656d3f$var$Request};var $bb0fea222fc5aea5$require$Request=$619319e3f3656d3f$exports.Request,$7D8Kb=parcelRequire("7D8Kb"),$bb0fea222fc5aea5$require$Setting=$7D8Kb.Setting,$aXWmO=parcelRequire("aXWmO"),$bb0fea222fc5aea5$require$Sheet=$aXWmO.Sheet,$7dfcabb1e936a92c$exports={},$liCrE=parcelRequire("liCrE"),$7dfcabb1e936a92c$require$View=$liCrE.View,$7dfcabb1e936a92c$require$PageView=$liCrE.PageView,$fYz8N=parcelRequire("fYz8N"),$7dfcabb1e936a92c$require$Controller=$fYz8N.Controller,$45Ip7=parcelRequire("45Ip7"),$7dfcabb1e936a92c$require$UIKit=$45Ip7.UIKit;class $7dfcabb1e936a92c$var$TabBarCellView extends $7dfcabb1e936a92c$require$View{constructor(e={}){super(e),this.setIcon(e.icon),this.setTitle(e.title),void 0!==e.activeStatus&&(this.activeStatus=e.activeStatus)}setIcon(e){return this.icon=e instanceof Array?e:[e,e],this}setTitle(e){return this.title=e,this}active(){$(`${this.props.id}-icon`).image=$image(this.icon[1]),$(`${this.props.id}-icon`).tintColor=$color("systemLink"),$(`${this.props.id}-title`).textColor=$color("systemLink"),this.activeStatus=!0}inactive(){$(`${this.props.id}-icon`).image=$image(this.icon[0]),$(`${this.props.id}-icon`).tintColor=$color("lightGray"),$(`${this.props.id}-title`).textColor=$color("lightGray"),this.activeStatus=!1}getView(){return this.views=[{type:"image",props:{id:`${this.props.id}-icon`,image:$image(this.activeStatus?this.icon[1]:this.icon[0]),bgcolor:$color("clear"),tintColor:$color(this.activeStatus?"systemLink":"lightGray")},layout:(e,t)=>{e.centerX.equalTo(t.super);const i=$7dfcabb1e936a92c$var$TabBarController.tabBarHeight/2;e.size.equalTo(i),e.top.inset(($7dfcabb1e936a92c$var$TabBarController.tabBarHeight-i-13)/2)}},{type:"label",props:{id:`${this.props.id}-title`,text:this.title,font:$font(10),textColor:$color(this.activeStatus?"systemLink":"lightGray")},layout:(e,t)=>{e.centerX.equalTo(t.prev),e.top.equalTo(t.prev.bottom).offset(3)}}],this}}class $7dfcabb1e936a92c$var$TabBarHeaderView extends $7dfcabb1e936a92c$require$View{height=60;getView(){return this.type="view",this.setProp("bgcolor",this.props.bgcolor??$7dfcabb1e936a92c$require$UIKit.primaryViewBackgroundColor),this.layout=(e,t)=>{e.left.right.bottom.equalTo(t.super),e.top.equalTo(t.super.safeAreaBottom).offset(-this.height-$7dfcabb1e936a92c$var$TabBarController.tabBarHeight)},this.views=[$7dfcabb1e936a92c$require$View.create({props:this.props,views:this.views,layout:(e,t)=>{e.left.right.top.equalTo(t.super),e.height.equalTo(this.height)}})],this}}class $7dfcabb1e936a92c$var$TabBarController extends $7dfcabb1e936a92c$require$Controller{static tabBarHeight=50;#L={};#_={};#V;#P;#M=$text.uuid;#F=$text.uuid;bottomSafeAreaInsets=$app.isDebugging?0:$7dfcabb1e936a92c$require$UIKit.bottomSafeAreaInsets;get selected(){return this.#P}set selected(e){this.switchPageTo(e)}get contentOffset(){return $7dfcabb1e936a92c$var$TabBarController.tabBarHeight+(this.#V?.height??0)}setPages(e={}){return Object.keys(e).forEach((t=>this.setPage(t,e[t]))),this}setPage(e,t){return void 0===this.#P&&(this.#P=e),this.#L[e]=t instanceof $7dfcabb1e936a92c$require$PageView?t:$7dfcabb1e936a92c$require$PageView.create(t),this.#P!==e&&(this.#L[e].activeStatus=!1),this}switchPageTo(e){if(this.#L[e]){if(this.#P===e)return;$ui.animate({duration:.4,animation:()=>{this.#_[e].active()}}),this.#_[this.#P].inactive(),this.#L[this.#P].hide(),this.#L[e].show(),this.callEvent("onChange",this.#P,e),this.#P=e,this.initBackground()}}hideBackground(e=!0){$(this.#F).hidden=!0,$ui.animate({duration:e?.2:1e-4,animation:()=>{$(this.#M).alpha=0}})}showBackground(e=!0){$(this.#F).hidden=!1,$ui.animate({duration:e?.2:1e-4,animation:()=>{$(this.#M).alpha=1}})}initBackground(){const e=this.#L[this.selected];e.scrollable&&$delay(0,(()=>{const t=$(e.id).get(e.scrollableView.id),i=t.contentOffset.y;t.contentSize.height+this.bottomSafeAreaInsets-t.frame.height-i<=0?this.hideBackground(!1):this.showBackground(!1)}))}setCells(e={}){return Object.keys(e).forEach((t=>this.setCell(t,e[t]))),this}setCell(e,t){return void 0===this.#P&&(this.#P=e),t instanceof $7dfcabb1e936a92c$var$TabBarCellView||(t=new $7dfcabb1e936a92c$var$TabBarCellView({props:{info:{key:e}},icon:t.icon,title:t.title,activeStatus:this.#P===e})),this.#_[e]=t,this}setHeader(e){return this.#V=e,this}#H(){const e=[];return Object.values(this.#_).forEach((t=>{t.setEvent("tapped",(e=>{const t=e.info.key;this.switchPageTo(t)})),e.push(t.getView())})),e}#U(){return Object.values(this.#L).map((e=>{if(e.scrollable){const t=e.scrollableView;if(t.props.indicatorInsets){const e=t.props.indicatorInsets;t.props.indicatorInsets=$insets(e.top,e.left,e.bottom+this.contentOffset,e.right)}else t.props.indicatorInsets=$insets(0,0,this.contentOffset,0);t.props.footer=Object.assign({props:{}},t.props.footer??{}),t.props.footer.props.height?t.props.footer.props.height+=this.contentOffset:t.props.footer.props.height=this.contentOffset,"function"==typeof t.assignEvent&&t.assignEvent("didScroll",(e=>{const t=e.contentOffset.y;e.contentSize.height+this.bottomSafeAreaInsets-e.frame.height-t<=1?this.hideBackground():this.showBackground()}))}return e.definition}))}generateView(){const e={type:"view",layout:(e,t)=>{e.centerX.equalTo(t.super),e.width.equalTo(t.super),e.top.equalTo(t.super.safeAreaBottom).offset(-$7dfcabb1e936a92c$var$TabBarController.tabBarHeight),e.bottom.equalTo(t.super)},views:[$7dfcabb1e936a92c$require$UIKit.blurBox({id:this.#M}),{type:"stack",layout:$layout.fillSafeArea,props:{axis:$stackViewAxis.horizontal,distribution:$stackViewDistribution.fillEqually,spacing:0,stack:{views:this.#H()}}},$7dfcabb1e936a92c$require$UIKit.separatorLine({id:this.#F},$7dfcabb1e936a92c$require$UIKit.align.top)],events:{ready:()=>this.initBackground()}};return $7dfcabb1e936a92c$require$View.createFromViews(this.#U().concat(this.#V?.definition??[],e))}}$7dfcabb1e936a92c$exports={TabBarCellView:$7dfcabb1e936a92c$var$TabBarCellView,TabBarHeaderView:$7dfcabb1e936a92c$var$TabBarHeaderView,TabBarController:$7dfcabb1e936a92c$var$TabBarController};var $bb0fea222fc5aea5$require$TabBarCellView=$7dfcabb1e936a92c$exports.TabBarCellView,$bb0fea222fc5aea5$require$TabBarHeaderView=$7dfcabb1e936a92c$exports.TabBarHeaderView,$bb0fea222fc5aea5$require$TabBarController=$7dfcabb1e936a92c$exports.TabBarController,$3839e9f9bae78bdd$exports={};class $3839e9f9bae78bdd$var$Tasks{#z={};addTask(e,t=0){const i=$text.uuid;return this.#z[i]=$delay(t,(async()=>{await e(),delete this.#z[i]})),i}cancelTask(e){this.#z[e].cancel()}clearTasks(){Object.values(this.#z).forEach((e=>e.cancel()))}}$3839e9f9bae78bdd$exports={Tasks:$3839e9f9bae78bdd$var$Tasks};var $bb0fea222fc5aea5$require$Tasks=$3839e9f9bae78bdd$exports.Tasks,$895b2d75ea56b5f0$exports={},$45Ip7=parcelRequire("45Ip7"),$895b2d75ea56b5f0$require$UIKit=$45Ip7.UIKit;class $895b2d75ea56b5f0$var$Toast{static type={info:void 0,success:"checkmark",warning:"exclamationmark.triangle",error:"xmark.circle"};static edges=40;static iconSize=100;static labelTopMargin=10;width=Math.min(.6*$895b2d75ea56b5f0$require$UIKit.windowSize.width,260);labelWidth=this.width-2*$895b2d75ea56b5f0$var$Toast.edges;id=$text.uuid;#j="";type=$895b2d75ea56b5f0$var$Toast.type.info;labelLines=2;font=$font("default",26);constructor(e,t=$895b2d75ea56b5f0$var$Toast.type.info,i=2,r=$font("default",26)){this.type=t,this.message=e,this.labelLines=i,this.font=r}get message(){return this.#j}set message(e){this.#j=e,this.fontHeight=$895b2d75ea56b5f0$require$UIKit.getContentSize(this.font,this.message,this.labelWidth,this.labelLines).height,this.height=(this.hasIcon?$895b2d75ea56b5f0$var$Toast.labelTopMargin+$895b2d75ea56b5f0$var$Toast.iconSize:0)+this.fontHeight+2*$895b2d75ea56b5f0$var$Toast.edges}get hasIcon(){return void 0!==this.type}get blurBox(){const e=$895b2d75ea56b5f0$require$UIKit.blurBox({id:this.id,cornerRadius:15,alpha:0},[{type:"image",props:{symbol:this.type,hidden:!this.hasIcon,tintColor:$color("lightGray")},layout:(e,t)=>{e.top.inset($895b2d75ea56b5f0$var$Toast.edges),e.size.equalTo($895b2d75ea56b5f0$var$Toast.iconSize),e.centerX.equalTo(t.super)}},{type:"label",props:{font:this.font,text:this.message,align:$align.center,lines:this.labelLines,color:$color("lightGray")},layout:(e,t)=>{e.bottom.equalTo(t.supper).offset(-$895b2d75ea56b5f0$var$Toast.edges),e.width.equalTo(this.labelWidth),e.height.equalTo(this.fontHeight),e.centerX.equalTo(t.super)}}]);return e.events={tapped:()=>{this.remove()}},e}show(){$ui.controller.view.insertAtIndex($ui.create(this.blurBox),0);const e=$(this.id);e.layout(((e,t)=>{e.center.equalTo(t.super),e.size.equalTo($size(this.width,this.height))})),e.moveToFront(),$ui.animate({duration:.2,animation:()=>{e.alpha=1}})}remove(){const e=$(this.id);e&&$ui.animate({duration:.2,animation:()=>{e.alpha=0},completion:()=>{e.remove()}})}static toast({message:e,type:t=$895b2d75ea56b5f0$var$Toast.type.info,displayTime:i=2,labelLines:r=2,font:s=$font("default",26)}){const a=new $895b2d75ea56b5f0$var$Toast(e,t,r,s);a.show(),$delay(i,(()=>{a.remove()}))}static info(e,t={}){$895b2d75ea56b5f0$var$Toast.toast(Object.assign({message:e,type:$895b2d75ea56b5f0$var$Toast.type.info},t))}static success(e,t={}){$895b2d75ea56b5f0$var$Toast.toast(Object.assign({message:e,type:$895b2d75ea56b5f0$var$Toast.type.success},t))}static warning(e,t={}){$895b2d75ea56b5f0$var$Toast.toast(Object.assign({message:e,type:$895b2d75ea56b5f0$var$Toast.type.warning},t))}static error(e,t={}){$895b2d75ea56b5f0$var$Toast.toast(Object.assign({message:e,type:$895b2d75ea56b5f0$var$Toast.type.error},t))}}$895b2d75ea56b5f0$exports={Toast:$895b2d75ea56b5f0$var$Toast};var $bb0fea222fc5aea5$require$Toast=$895b2d75ea56b5f0$exports.Toast,$45Ip7=parcelRequire("45Ip7"),$bb0fea222fc5aea5$require$UIKit=$45Ip7.UIKit,$86d2ffde19fb8791$exports={};class $86d2ffde19fb8791$var$UILoading{#K;text="";interval;fullScreen=!1;#Y=()=>{};constructor(){this.#K=$text.uuid}updateText(e){$(this.#K).text=e}setLoop(e){if("function"!=typeof e)throw"loop must be a function";this.#Y=e}done(){clearInterval(this.interval)}load(){$ui.render({props:{navBarHidden:this.fullScreen},views:[{type:"spinner",props:{loading:!0},layout:(e,t)=>{e.centerY.equalTo(t.super).offset(-15),e.width.equalTo(t.super)}},{type:"label",props:{id:this.#K,align:$align.center,text:""},layout:(e,t)=>{e.top.equalTo(t.prev.bottom).offset(10),e.left.right.equalTo(t.super)}}],layout:$layout.fill,events:{appeared:()=>{this.interval=setInterval((()=>{this.#Y()}),100)}}})}}$86d2ffde19fb8791$exports={UILoading:$86d2ffde19fb8791$var$UILoading};var $bb0fea222fc5aea5$require$UILoading=$86d2ffde19fb8791$exports.UILoading,$6Xrbz=parcelRequire("6Xrbz"),$bb0fea222fc5aea5$require$ValidationError=$6Xrbz.ValidationError,$liCrE=parcelRequire("liCrE"),$bb0fea222fc5aea5$require$View=$liCrE.View,$bb0fea222fc5aea5$require$PageView=$liCrE.PageView,$gMc1q=parcelRequire("gMc1q"),$bb0fea222fc5aea5$require$ViewController=$gMc1q.ViewController,$12xzj=parcelRequire("12xzj"),$bb0fea222fc5aea5$require$NavigationView=$12xzj.NavigationView,$dcStC=parcelRequire("dcStC"),$bb0fea222fc5aea5$require$NavigationBar=$dcStC.NavigationBar,$bb0fea222fc5aea5$require$NavigationBarController=$dcStC.NavigationBarController,$gAYmG=parcelRequire("gAYmG"),$bb0fea222fc5aea5$require$NavigationBarItems=$gAYmG.NavigationBarItems,$bb0fea222fc5aea5$require$BarButtonItem=$gAYmG.BarButtonItem,$ee5e1f8d12d987dc$exports={},$fYz8N=parcelRequire("fYz8N"),$ee5e1f8d12d987dc$require$Controller=$fYz8N.Controller,$gAYmG=parcelRequire("gAYmG"),$ee5e1f8d12d987dc$require$BarTitleView=$gAYmG.BarTitleView;class $ee5e1f8d12d987dc$var$SearchBar extends $ee5e1f8d12d987dc$require$BarTitleView{height=35;topOffset=15;bottomOffset=10;kbType=$kbType.search;placeholder=$l10n("SEARCH");inputEvents={};keyboardView;accessoryView;constructor(e){super(e),this.setController(new $ee5e1f8d12d987dc$var$SearchBarController),this.controller.setSearchBar(this)}setEvent(e,t){return this.inputEvents[e]=t,this}setPlaceholder(e){return this.placeholder=e,this}setKbType(e){return this.kbType=e,this}setKeyboardView(e){return this.keyboardView=e,this}setAccessoryView(e){return this.accessoryView=e,this}getView(){return this.props={id:this.id,smoothCorners:!0,cornerRadius:6,bgcolor:$color("#EEF1F1","#212121")},this.views=[{type:"input",props:{id:this.id+"-input",type:this.kbType,bgcolor:$color("clear"),placeholder:this.placeholder,keyboardView:this.keyboardView,accessoryView:this.accessoryView},layout:$layout.fill,events:Object.assign({changed:e=>this.controller.callEvent("onChange",e.text),returned:e=>this.controller.callEvent("onReturn",e.text)},this.inputEvents)}],this.layout=(e,t)=>{e.height.equalTo(this.height),e.top.equalTo(t.super.safeArea).offset(this.topOffset),e.left.equalTo(t.super.safeArea).offset(15),e.right.equalTo(t.super.safeArea).offset(-15)},this}}class $ee5e1f8d12d987dc$var$SearchBarController extends $ee5e1f8d12d987dc$require$Controller{setSearchBar(e){return this.searchBar=e,this}updateSelector(){this.selector={inputBox:$(this.searchBar.id),input:$(this.searchBar.id+"-input")}}hide(){this.updateSelector(),this.selector.inputBox.updateLayout((e=>{e.height.equalTo(0)}))}show(){this.updateSelector(),this.selector.inputBox.updateLayout((e=>{e.height.equalTo(this.searchBar.height)}))}didScroll(e){this.updateSelector();let t=this.searchBar.height-e;if(t=t>0?t>this.searchBar.height?this.searchBar.height:t:0,this.selector.inputBox.updateLayout((e=>{e.height.equalTo(t)})),e>0){const t=(this.searchBar.height/2-5-e)/10;this.selector.input.alpha=t}else this.selector.input.alpha=1}didEndDragging(e,t,i){this.updateSelector(),e>=0&&e<=this.searchBar.height&&i($point(0,e>=this.searchBar.height/2?this.searchBar.height:0))}}$ee5e1f8d12d987dc$exports={SearchBar:$ee5e1f8d12d987dc$var$SearchBar,SearchBarController:$ee5e1f8d12d987dc$var$SearchBarController};var $bb0fea222fc5aea5$require$SearchBar=$ee5e1f8d12d987dc$exports.SearchBar,$bb0fea222fc5aea5$require$SearchBarController=$ee5e1f8d12d987dc$exports.SearchBarController;module.exports={VERSION:$bb0fea222fc5aea5$require$VERSION,Controller:$bb0fea222fc5aea5$require$Controller,FileManager:$bb0fea222fc5aea5$require$FileManager,FileStorageParameterError:$bb0fea222fc5aea5$require$FileStorageParameterError,FileStorageFileNotFoundError:$bb0fea222fc5aea5$require$FileStorageFileNotFoundError,FileStorage:$bb0fea222fc5aea5$require$FileStorage,FixedFooterView:$bb0fea222fc5aea5$require$FixedFooterView,Kernel:$bb0fea222fc5aea5$require$Kernel,Matrix:$bb0fea222fc5aea5$require$Matrix,Request:$bb0fea222fc5aea5$require$Request,Setting:$bb0fea222fc5aea5$require$Setting,Sheet:$bb0fea222fc5aea5$require$Sheet,TabBarCellView:$bb0fea222fc5aea5$require$TabBarCellView,TabBarHeaderView:$bb0fea222fc5aea5$require$TabBarHeaderView,TabBarController:$bb0fea222fc5aea5$require$TabBarController,Tasks:$bb0fea222fc5aea5$require$Tasks,Toast:$bb0fea222fc5aea5$require$Toast,UIKit:$bb0fea222fc5aea5$require$UIKit,UILoading:$bb0fea222fc5aea5$require$UILoading,ValidationError:$bb0fea222fc5aea5$require$ValidationError,View:$bb0fea222fc5aea5$require$View,PageView:$bb0fea222fc5aea5$require$PageView,ViewController:$bb0fea222fc5aea5$require$ViewController,NavigationView:$bb0fea222fc5aea5$require$NavigationView,NavigationBar:$bb0fea222fc5aea5$require$NavigationBar,NavigationBarController:$bb0fea222fc5aea5$require$NavigationBarController,NavigationBarItems:$bb0fea222fc5aea5$require$NavigationBarItems,BarButtonItem:$bb0fea222fc5aea5$require$BarButtonItem,SearchBar:$bb0fea222fc5aea5$require$SearchBar,SearchBarController:$bb0fea222fc5aea5$require$SearchBarController}})),parcelRequire.register("hOw2h",(function(e,t){var i=parcelRequire("gxpqj").Kernel;class r{sqlite;constructor(e){this.kernel=e,this.dbName="CAIO.db",this.localDb=`/${this.dbName}`,this.imagePath="/image",this.imageOriginalPath=`${this.imagePath}/original`,this.imagePreviewPath=`${this.imagePath}/preview`,this.tempPath="/temp",this.tempDbFile=`${this.tempPath}/${this.dbName}`,this.tempImagePath=`${this.tempPath}/image`,this.exportFileName="CAIO.zip",this.init()}init(){this.sqlite=$sqlite.open(this.kernel.fileStorage.filePath(this.localDb)),this.sqlite.update("CREATE TABLE IF NOT EXISTS clips(uuid TEXT PRIMARY KEY NOT NULL, text TEXT, md5 TEXT, prev TEXT, next TEXT)"),this.sqlite.update("CREATE TABLE IF NOT EXISTS pin(uuid TEXT PRIMARY KEY NOT NULL, text TEXT, md5 TEXT, prev TEXT, next TEXT)"),this.sqlite.update("CREATE TABLE IF NOT EXISTS tag(uuid TEXT PRIMARY KEY NOT NULL, tag TEXT)")}rebuild(){const e=this.tempPath+"/rebuild.db";this.kernel.fileStorage.delete(e);const t=new r(this.kernel);t.localDb=e,t.init();const i=(e,i)=>{const r=[];e.forEach((e=>{const s={uuid:e.uuid,text:e.text,md5:e.md5,tag:e.tag,image:e.image,prev:null,next:r[0]?.uuid??null};t.beginTransaction();try{t.insert(i,s),s.next&&(r[0].prev=s.uuid,t.update(i,r[0])),t.commit(),r.unshift(s)}catch(e){throw t.rollback(),this.kernel.error(e),e}}))};["clips","pin"].map((e=>{let t=this.all(e);try{const e=this.sort(JSON.parse(JSON.stringify(t)));if(e.length>t.length)throw new Error;t=e.reverse()}catch{}i(t,e)}));const s=this.sqlite.query("SELECT * FROM tag");this.parseTag(s).forEach((e=>{t.beginTransaction();try{t.setTag(e.uuid,e.tag),t.commit()}catch(e){throw t.rollback(),this.kernel.error(e),e}})),this.kernel.fileStorage.copy(e,this.localDb)}deleteAllData(){this.kernel.fileStorage.delete(this.imagePath),this.kernel.fileStorage.delete(this.localDb)}clearTemp(){this.kernel.fileStorage.delete(this.tempPath)}async export(e){this.clearTemp(),this.kernel.fileStorage.copy(this.localDb,this.tempDbFile),this.kernel.fileStorage.copy(this.imagePath,this.tempImagePath);const t=this.tempPath+"/"+this.exportFileName;await $archiver.zip({directory:this.kernel.fileStorage.filePath(this.tempPath),dest:this.kernel.fileStorage.filePath(t)}),$share.sheet({items:[{name:this.exportFileName,data:$data({path:this.kernel.fileStorage.filePath(t)})}],handler:i=>{this.kernel.fileStorage.delete(t),e(i)}})}async import(e){if("db"===e.fileName.slice(-2)){if(!this.kernel.fileStorage.writeSync(this.localDb,e))throw new Error("WRITE_DB_FILE_FAILED")}else if("zip"===e.fileName.slice(-3)){if(!await $archiver.unzip({file:e,dest:this.kernel.fileStorage.filePath(this.tempPath)}))throw new Error("UNZIP_FAILED");this.kernel.fileStorage.move(this.tempDbFile,this.localDb),this.kernel.fileStorage.move(this.tempImagePath,this.imagePath)}}sort(e,t=9e3){const i={};let r=0,s=null;e.forEach((e=>{i[e.uuid]=e,null===e.prev&&(s=e.uuid),r++}));const a=[];if(r>0)try{let e=i[s];for(;null!==e.next&&t>0;)t--,a.push(e),e=i[e.next];a.push(e)}catch(e){throw"Unable to sort: "+e}return a}parse(e){const t=e.result,i=e.error;if(null!==i)throw new Error(`Code [${i.code}] ${i.domain} ${i.localizedDescription}`);const r=[];for(;t.next();)r.push({uuid:t.get("uuid"),section:t.get("section"),text:t.get("text"),md5:t.get("md5"),tag:t.get("tag")??"",prev:t.get("prev")??null,next:t.get("next")??null});return t.close(),r}parseTag(e){if(null!==e.error)throw e.error;const t=[];for(;e.result.next();)t.push({uuid:e.result.get("uuid"),tag:e.result.get("tag")});return e.result.close(),t}beginTransaction(){this.sqlite.beginTransaction()}commit(){this.sqlite.commit()}rollback(){this.sqlite.rollback()}getByUUID(e){e=e.replace("'","");const t=this.sqlite.query({sql:`\n SELECT *, 'clips' AS section FROM clips WHERE uuid = '${e}'\n UNION\n SELECT *, 'pin' AS section FROM pin WHERE uuid = '${e}'\n `});return this.parse(t)[0]}getByMD5(e){e=e.replace("'","");const t=this.sqlite.query({sql:`\n SELECT *, 'clips' AS section FROM clips WHERE md5 = '${e}'\n UNION\n SELECT *, 'pin' AS section FROM pin WHERE md5 = '${e}'\n `});return this.parse(t)[0]}search(e){const t=this.sqlite.query({sql:"SELECT * from\n (SELECT clips.*, 'clips' AS section FROM clips WHERE text like ?\n UNION\n SELECT pin.*, 'pin' AS section FROM pin WHERE text like ?) a\n LEFT JOIN tag ON a.uuid = tag.uuid\n ",args:[`%${e}%`,`%${e}%`]});return this.parse(t)}isImage(e){return e?.startsWith("@image=")}pathToKey(e){return`@image=${e=JSON.stringify(e)}`}keyToPath(e){return!!this.isImage(e)&&JSON.parse(e.slice(7))}deleteTable(e){const t=this.sqlite.update(`DELETE FROM ${e}`);if(!t.result)throw t.error}all(e){const t=this.sqlite.query(`SELECT ${e}.*, tag, '${e}' AS section FROM ${e} LEFT JOIN tag ON ${e}.uuid = tag.uuid`);return this.parse(t)}insert(e,t){if(t.image){const e=t.image,r=$text.uuid,s={original:`${this.imageOriginalPath}/${r}.png`,preview:`${this.imagePreviewPath}/${r}.jpg`};this.kernel.fileStorage.write(s.original,e.png),this.kernel.fileStorage.write(s.preview,i.compressImage(e).jpg(.8)),t.text=this.pathToKey(s)}const r=this.sqlite.update({sql:`INSERT INTO ${e} (uuid, text, md5, prev, next) values (?, ?, ?, ?, ?)`,args:[t.uuid,t.text,$text.MD5(t.text),t.prev,t.next]});if(!r.result)throw r.error}update(e,t){if(Object.keys(t).length<4||"string"!=typeof t.uuid)return;const i=this.sqlite.update({sql:`UPDATE ${e} SET text = ?, md5 = ?, prev = ?, next = ? WHERE uuid = ?`,args:[t.text,$text.MD5(t.text),t.prev,t.next,t.uuid]});if(!i.result)throw i.error}updateText(e,t,i){if("string"!=typeof t)return;const r=this.sqlite.update({sql:`UPDATE ${e} SET text = ?, md5 = ? WHERE uuid = ?`,args:[i,$text.MD5(i),t]});if(!r.result)throw r.error}delete(e,t){const i=this.getByUUID(t);this.beginTransaction();try{const i=this.sqlite.update({sql:`DELETE FROM ${e} WHERE uuid = ?`,args:[t]});if(!i.result)throw i.error;this.deleteTag(t),this.commit()}catch(e){throw this.rollback(),e}const r=this.keyToPath(i?.text);r&&(this.kernel.fileStorage.delete(r.original),this.kernel.fileStorage.delete(r.preview))}setTag(e,t){const i=this.sqlite.update({sql:"INSERT OR REPLACE INTO tag (uuid, tag) values (?, ?)",args:[e,t]});if(!i.result)throw i.error}deleteTag(e){const t=this.sqlite.update({sql:"DELETE FROM tag WHERE uuid = ?",args:[e]});if(!t.result)throw t.error}}e.exports=r})),parcelRequire.register("imdB1",(function(e,t){var i=parcelRequire("gxpqj"),r=i.View,s=i.Kernel,a=i.UIKit,n=i.Sheet,o=i.ViewController,l=i.NavigationView,c=i.NavigationBar,h=i.Toast,d=parcelRequire("f0nX9"),p=parcelRequire("4ZHFw"),u=parcelRequire("ay4Kj"),g=parcelRequire("9LqeL"),f=parcelRequire("eSp9Z"),b=f.ActionData,y=f.ActionEnv;e.exports=class extends p{listId="clips-list";#G=!1;#W=-1;left_right=20;top_bottom=20;containerMargin=0;fontSize=16;copiedIndicatorSize=7;imageContentHeight=50;tagFontSize=14;tagContainerHeight=25;menuItemActionMaxCount=5;tabHeight=44;copied=$cache.get("clips.copied")??{};#J={};constructor(e){super(e),this.viewController=new o,this.search=new u(this.kernel),this.search.setCallback((e=>{(new n).setView(this.getListView(this.listId+"-search-result",e.map((e=>this.lineData(e))))).addNavBar({title:$l10n("SEARCH_RESULT"),popButton:{title:$l10n("DONE"),tapped:()=>this.search.dismiss()}}).init().present()}))}get singleLineHeight(){return this.#W<0&&(this.#W=$text.sizeThatFits({text:"A",width:this.fontSize,font:$font(this.fontSize)}).height),this.#W}setSingleLine(){this.#G=!0,this.imageContentHeight=this.singleLineHeight}getTextHeight(e){return this.#J[e]||(this.#J[e]=this.#G?this.singleLineHeight:Math.min($text.sizeThatFits({text:e,width:a.windowSize.width-2*(this.left_right+this.containerMargin),font:$font(this.fontSize)}).height,2*this.singleLineHeight)),this.#J[e]}appListen(){s.isTaio||$app.listen({resume:()=>{this.loadAllClips(),this.updateList(),$delay(.5,(()=>{this.readClipboard()}))}})}listReady(){this.updateList(),s.isTaio||($delay(.5,(()=>{if($context.query.copy){const e=$context.query.copy,t=this.kernel.storage.getByUUID(e);this.setClipboardText(t.text),this.setCopied(e,this.getRowByUUID(e)),$ui.success($l10n("COPIED"))}else $context.query.add?this.getAddTextView():$context.query.actions&&(this.kernel.isUseJsboxNav?this.kernel.actionManager.present():this.kernel.tabBarController.switchPageTo("actions"))})),$delay(.5,(()=>{this.readClipboard()})),this.appListen())}updateList(){$(this.listId).data=this.clips.map((e=>this.lineData(e,this.copied.uuid===e.uuid))),this.updateListBackground()}updateListBackground(){$(this.listId+"-empty-list-background").hidden=this.clips.length>0}updateCopied(e={}){Object.assign(this.copied,e),this.kernel.print(`this.copied: ${JSON.stringify(this.copied,null,2)}`),$cache.set("clips.copied",this.copied)}setCopied(e,t,i=!0){if(!e||e===this.copied.uuid&&this.tabIndex===this.copied?.tabIndex&&t===this.copied?.row)return;let r={};this.copied.uuid!==e&&(r=this.kernel.storage.getByUUID(e)??{}),r.tabIndex=this.tabIndex,r.row=t;const s=this.copied.row;if(this.updateCopied(r),i){const e=$(this.listId);$delay(.3,(()=>{e.cell($indexPath(0,s)).get("copied").hidden=!0,e.cell($indexPath(0,t)).get("copied").hidden=!1}))}}readClipboard(e=!1){if(e||this.kernel.setting.get("clipboard.autoSave")){if(this.kernel.print("read clipboard"),!this.isChanged)return void(e&&$ui.toast($l10n("CLIPBOARD_NO_CHANGE")));if(this.switchTab(1,!0),$clipboard.images?.length>0)return!!e&&($clipboard.images.forEach((e=>{this.add(e)})),!0);const t=$clipboard.text;if(!t||""===t)return!1;if(this.copied.text===t)return!1;const i=$text.MD5(t);if(this.savedClipboardIndex[i]){const e=this.kernel.storage.getByMD5(i);this.setCopied(e.uuid,this.getRowByUUID(e.uuid))}else{const e=this.add(t);this.copy(t,e.uuid,0)}}return!1}add(e,t){try{const i=super.add(e);return"function"==typeof t?t(i):($(this.listId).insert({indexPath:$indexPath(0,0),value:this.lineData(i)}),this.copied?.tabIndex===this.tabIndex&&this.setCopied(this.copied.uuid,this.copied?.row+1,!1)),i}catch(e){$ui.alert(e)}}delete(e,t){try{super.delete(e,t),this.copied.uuid===e&&(this.copied={},$clipboard.clear())}catch(e){$ui.alert(e)}}update(e,t,i){return!!super.update(e,t,i)&&(this.updateList(),e===this.copied.uuid&&(this.setClipboardText(t),this.updateCopied({text:t})),!0)}move(e,t,i=!0){if(e!==t)try{if(super.move(e,t),!i)return;const r=$(this.listId);ee&&this.copied.rowt||this.copied.row===t)&&this.setCopied(this.copied.uuid,e{i.text?$share.sheet(i.text):$ui.warning($l10n("NONE"))}}];if(this.kernel.isUseJsboxNav)i.uikitPush(e,(e=>t(e)),r);else{const s=i.getNavigationView(e,(e=>t(e)),r);this.viewController.push(s)}}getAddTextView(){this.edit("",(e=>{""!==e&&this.add(e)}))}menuItems(e=!1){const t=[{inline:!0,items:[{title:$l10n("TAG"),symbol:"tag",handler:(e,t)=>{const i=this.clips[t.row].uuid;$input.text({placeholder:$l10n("ADD_TAG"),text:e.text,handler:e=>{(e=e.trim()).length>0?this.kernel.storage.setTag(i,e):this.kernel.storage.deleteTag(i),this.loadAllClips(),this.updateList()}})}}]},{inline:!0,items:[{title:$l10n("SHARE"),symbol:"square.and.arrow.up",handler:(e,t)=>{const i=this.clips[t.row].text;let r=i;const s=this.kernel.storage.keyToPath(i);if(s&&this.kernel.fileStorage.exists(s.original)){const e=this.kernel.fileStorage.readSync(s.original)?.image?.png;r={name:e.fileName,data:e}}$share.sheet([r])}},{title:$l10n("COPY"),symbol:"square.on.square",handler:(e,t)=>{const i=this.clips[t.row];this.copy(i.text,i.uuid,t.row)}},{title:$l10n("DELETE"),symbol:"trash",destructive:!0,handler:(e,t)=>{this.kernel.deleteConfirm($l10n("CONFIRM_DELETE_MSG"),(()=>{const i=this.clips[t.row];this.delete(i.uuid,t.row),e.delete(t)}))}}]}];if(e)return t;const i=e=>{const t=this.kernel.actionManager.getActionHandler(e.type,e.dir);return e.handler=(e,i)=>{const r=this.clips[i.row],s=new b({env:y.clipboard,text:r.text,uuid:r.uuid});t(s)},e.title=e.name,e.symbol=e.icon,e},r=this.kernel.actionManager.getActions("clipboard"),s={inline:!0,items:r.slice(0,this.menuItemActionMaxCount).map(i)};return r.length>this.menuItemActionMaxCount&&s.items.push({title:$l10n("MORE_ACTIONS"),symbol:"square.grid.2x2",items:r.slice(this.menuItemActionMaxCount).map(i)}),[s,...t]}switchTab(e,t=!1){this.tabIndex=e,this.updateList(),t&&($(this.listId+"-tab").index=this.tabIndex)}tabView(){return{type:"tab",props:{id:this.listId+"-tab",items:this.tabItems,index:this.tabIndex,dynamicWidth:!0},events:{changed:e=>this.switchTab(e.index)},layout:(e,t)=>{e.centerY.equalTo(t.super),t.prev?e.left.equalTo(t.prev.right).offset(this.left_right):e.left.inset(this.left_right)}}}lineData(e,t=!1){const i={hidden:!0},r={text:""},s=this.kernel.storage.keyToPath(e.text);return s?(i.src=s.preview,i.hidden=!1):r.text=e.text,{copied:{hidden:!t},image:i,tag:{text:e.tag},content:r}}listTemplate(){return{props:{bgcolor:$color("clear")},views:[{type:"view",views:[{type:"view",props:{id:"copied",circular:this.copiedIndicatorSize,hidden:!0,bgcolor:$color("green")},layout:(e,t)=>{e.centerY.equalTo(t.super),e.size.equalTo(this.copiedIndicatorSize),e.left.equalTo(t.super).inset(this.left_right/2-this.copiedIndicatorSize/2)}},{type:"label",props:{id:"content",lines:this.#G?1:2,font:$font(this.fontSize)},layout:(e,t)=>{e.left.right.equalTo(t.super).inset(this.left_right),this.#G?e.top.inset(this.imageContentHeight/2):e.top.inset(this.top_bottom)}},{type:"image",props:{id:"image",hidden:!0},layout:$layout.fill}],layout:$layout.fill},{type:"label",props:{id:"tag",color:$color("systemGray2"),font:$font(this.tagFontSize)},layout:(e,t)=>{e.bottom.width.equalTo(t.super),e.left.inset(this.left_right),e.height.equalTo(this.tagContainerHeight)}}]}}getListView(e=this.listId,t=[]){const i={type:"list",props:{id:e,associateWithNavigationBar:!1,bgcolor:$color("clear"),separatorInset:$insets(0,this.left_right,0,0),menu:{items:this.menuItems()},data:t,template:this.listTemplate(),actions:[{title:$l10n("COPY"),color:$color("systemLink"),handler:(e,t)=>{const i=this.clips[t.row];this.copy(i.text,i.uuid,t.row)}},{title:$l10n("PIN"),color:$color("orange"),handler:(e,t)=>{const i=this.clips[t.row];this.pin(i,t.row)}}]},layout:$layout.fill,events:{ready:()=>this.listReady(),rowHeight:(e,t)=>{const i=e.object(t),r=i.tag.text?this.tagContainerHeight:this.top_bottom;return(this.kernel.storage.isImage(i.content.text)?this.imageContentHeight:this.getTextHeight(i.content.text))+this.top_bottom+r},didSelect:(e,t,i)=>{const r=this.clips[t.row],s=r.text,a=this.kernel.storage.keyToPath(s);a&&this.kernel.fileStorage.exists(a.original)?$quicklook.open({image:this.kernel.fileStorage.readSync(a.original)?.image}):this.edit(r.text,(e=>{r.md5!==$text.MD5(e)&&this.update(r.uuid,e,t.row)}))},pulled:e=>{this.loadAllClips(),this.updateList(),$delay(.5,(()=>e.endRefreshing()))}}},s={type:"label",props:{id:e+"-empty-list-background",color:$color("secondaryText"),hidden:this.clips.length>0,text:$l10n("NONE"),align:$align.center},layout:$layout.center};return r.createFromViews([i,s])}getNavigationView(){const e=this.tabView();e.type="menu",e.layout=(e,t)=>{e.top.left.right.equalTo(t.super),e.height.equalTo(this.tabHeight)};const t=this.getListView();t.views.unshift(e),t.views[1].layout=(e,t)=>{e.bottom.left.right.equalTo(t.super),e.top.equalTo(t.prev.bottom)},t.views.push(this.search.getSearchHistoryView());const i=(new l).navigationBarTitle($l10n("CLIPS")).setView(t);return i.navigationBarItems.setTitleView(this.search.getSearchBarView()).pinTitleView().setRightButtons([{symbol:"plus.circle",tapped:()=>this.getAddTextView()}]).setLeftButtons([{title:$l10n("EDIT"),tapped:()=>{new g(this).presentSheet()}},{symbol:"square.and.arrow.down.on.square",tapped:e=>{e.start(),this.readClipboard(!0),e.done()}}]),i.navigationBar.setBackgroundColor(a.primaryViewBackgroundColor).setLargeTitleDisplayMode(c.largeTitleDisplayModeNever),this.kernel.isUseJsboxNav&&i.navigationBar.removeTopSafeArea(),i}}})),parcelRequire.register("f0nX9",(function(e,t){var i=parcelRequire("gxpqj"),r=i.UIKit,s=i.NavigationBar,a=i.NavigationView,n=i.Sheet,o=parcelRequire("eSp9Z"),l=o.ActionEnv,c=o.ActionData;e.exports=class{#X="";constructor(e){this.kernel=e,this.id="editor",this.originalContent=void 0}set text(e=""){void 0===this.originalContent&&(this.originalContent=e),this.#X=e}get text(){return this.#X}getActionButton(){return{symbol:"bolt.circle",tapped:(e,t)=>{t&&(e=t);const i=$(this.id).selectedRange,r=new c({env:l.editor,editor:{setContent:e=>this.setContent(e)},text:i.length>0?this.text.slice(i.location,i.location+i.length):this.text,selectedRange:i}),s=$ui.popover({sourceView:e,directions:$popoverDirection.up,size:$size(200,300),views:[this.kernel.actionManager.getActionListView((e=>{s.dismiss(),$delay(.5,(()=>e(r)))}))]})}}}setContent(e){this.text=e,$(this.id).text=e}getView(e="text"){return{type:e,layout:$layout.fill,props:{id:this.id,lineNumbers:this.kernel.setting.get("editor.code.lineNumbers"),theme:this.kernel.setting.get($device.isDarkMode?"editor.code.darkTheme":"editor.code.lightTheme"),text:this.text,insets:$insets(15,15,"text"===e?this.kernel.setting.get("editor.text.insets"):15,15)},events:{ready:e=>{""===this.text&&setTimeout((()=>e.focus()),500)},didChange:e=>{this.text=e.text}}}}pageSheet(e="",t,i,r=[],s="text"){this.text=e,r.unshift(this.getActionButton());const a=new n;a.setView(this.getView(s)).addNavBar({title:i,popButton:{title:$l10n("DONE"),tapped:()=>t(this.text)},rightButtons:r}),a.navigationView.navigationBar.contentViewHeightOffset=0,a.init().present()}uikitPush(e="",t,i=[],s="text"){this.text=e,i.unshift(this.getActionButton()),r.push({title:"",navButtons:i.map((e=>(e.handler=e.tapped,e.tapped=void 0,e))),views:[this.getView(s)],disappeared:()=>t(this.text)})}getNavigationView(e="",t,i=[],r="text"){this.text=e,i.unshift(this.getActionButton());const n=new a;return n.navigationBar.contentViewHeightOffset=0,n.navigationBar.setLargeTitleDisplayMode(s.largeTitleDisplayModeNever),n.navigationBarItems.setRightButtons(i),n.setView(this.getView(r)).navigationBarTitle(""),n.setEvent("onPop",(()=>t(this.text))),n}}})),parcelRequire.register("eSp9Z",(function(e,t){var i=parcelRequire("gxpqj"),r=i.Kernel,s=i.Sheet;class a{static keyboard=0;static today=0;static editor=1;static clipboard=2;static action=3}e.exports={ActionEnv:a,ActionData:class{env;args;text;originalContent;uuid;selectedRange;textBeforeInput;textAfterInput;editor;constructor({env:e,args:t,text:i,uuid:r=null,selectedRange:s=null,textBeforeInput:a=null,textAfterInput:n=null,editor:o=null}={}){this.env=e,this.args=t,this.text=i,this.originalContent=i,this.uuid=r,this.selectedRange=s,this.textBeforeInput=a,this.textAfterInput=n,this.editor=o}},Action:class{#Q;constructor(e,t,i){this.#Q=e,this.config=t,Object.assign(this,i),this.originalContent=this.text;const s=this.l10n();Object.keys(s).forEach((e=>{r.l10n(e,s[e])}))}l10n(){return{}}pageSheet({view:e,title:t="",done:i,doneText:r=$l10n("DONE"),rightButtons:a=[]}){(new s).setView(e).addNavBar({title:t,popButton:{title:r,tapped:()=>{i&&i()}},rightButtons:a}).init().present()}getAllClips(){return{pin:this.#Q.storage.all("pin").map((e=>e.text)),clips:this.#Q.storage.all("clips").map((e=>e.text))}}async clearAllClips(){if(0!==(await $ui.alert({title:$l10n("DELETE_DATA"),message:$l10n("DELETE_TABLE").replace("${table}",$l10n("CLIPS")),actions:[{title:$l10n("DELETE"),style:$alertActionType.destructive},{title:$l10n("CANCEL")}]})).index)return!1;try{return this.#Q.storage.deleteTable("clips"),!0}catch(e){throw this.#Q.error(e),e}}setContent(e){this.text=e,this.env===a.editor&&this.editor.setContent(e)}getAction(e,t,i){return this.#Q.actionManager.getAction(e,t,i)}async runAction(e,t){const i=this.getAction(e,t);return await i.do()}async request(e,t,i={},r={}){try{this.#Q.print(`sending request [${t}]: ${e}`);const s=await $http.request({header:r,url:e,method:t,body:i,timeout:5});if(s.error)throw s.error;if(s?.response?.statusCode>=400){let e=s.data;throw"object"==typeof e&&(e=JSON.stringify(e)),new Error("http error: ["+s.response.statusCode+"] "+e)}return s}catch(e){throw e.code&&(e=new Error("network error: ["+e.code+"] "+e.localizedDescription)),e}}getUrls(){return(this.text??"").match(/(https?:\/\/)([\da-z\.-]+)\.([a-z\.]{2,6})([:0-9])*([\/\w\#\.\-\?\=\&])*\s?/gi)??[]}}}})),parcelRequire.register("4ZHFw",(function(e,t){var i=parcelRequire("gxpqj").UIKit;e.exports=class{kernel;pasteboard=$objc("UIPasteboard").$generalPasteboard();#Z=[];savedClipboardIndex={};tabItems=[$l10n("PIN"),$l10n("CLIPS")];tabItemsIndex=["pin","clips"];constructor(e){this.kernel=e}set tabIndex(e){$cache.set("caio.main.tab.index",e)}get tabIndex(){return $cache.get("caio.main.tab.index")??0}get table(){return this.tabItemsIndex[this.tabIndex]}get tableL10n(){return this.tabItems[this.tabIndex]}get allClips(){return 0===this.#Z.length&&this.loadAllClips(),this.#Z}set allClips(e){this.#Z=e.map((e=>new Proxy(e??[],{set:(e,t,i)=>Reflect.set(e,t,i)})))}get clips(){return this.allClips[this.tabIndex]}get isChanged(){const e=this.pasteboard.$changeCount(),t=$cache.get("clipboard.changeCount");return $cache.set("clipboard.changeCount",e),t!==e}getRowByUUID(e){let t=this.clips.length;for(let i=0;i{const i=JSON.parse(JSON.stringify(e));return Object.assign(i,t)},r=this.table;this.clips[t]||(this.clips[t]={uuid:null,text:"",next:null,prev:this.clips[t-1].uuid});try{this.kernel.storage.beginTransaction();const s=i(this.clips[e]),a=i(this.clips[t]);if(this.clips[e-1]){const t=i(this.clips[e-1],{next:this.clips[e].next});this.kernel.storage.update(r,t),this.clips[e-1]=t}if(this.clips[e+1]){const t=i(this.clips[e+1],{prev:this.clips[e].prev});this.kernel.storage.update(r,t),this.clips[e+1]=t}if(this.clips[t-1]){const s=i(this.clips[t-1],{next:this.clips[e].uuid});this.kernel.storage.update(r,s),this.clips[t-1]=s}const n=i(a,{prev:s.uuid,next:this.clips[t].next});this.kernel.storage.update(r,n);const o=i(s,{prev:this.clips[t].prev,next:a.uuid});this.kernel.storage.update(r,o),this.clips[t]=n,this.clips[e]=o,this.clips.splice(t,0,this.clips[e]),this.clips.splice(e>t?e+1:e,1),this.kernel.storage.commit()}catch(e){throw this.kernel.error(e),this.kernel.storage.rollback(),e}finally{null===this.clips[t].uuid&&this.clips.splice(t,1)}}pin(e,t){e.next=this.allClips[0][0]?.uuid??null,e.prev=null;try{this.kernel.storage.beginTransaction(),this.kernel.storage.insert("pin",e),e.next&&(this.allClips[0][0].prev=e.uuid,this.kernel.storage.update("pin",this.allClips[0][0])),this.kernel.storage.commit(),"pin"!==e?.section&&(e.section="pin",this.delete(e.uuid,t)),this.allClips[0].unshift(e),this.savedClipboardIndex[e.md5]=1}catch(e){throw this.kernel.error(e),this.kernel.storage.rollback(),e}}loadAllClips(){this.kernel.print("load all clips");const e=e=>{try{return this.kernel.storage.sort(e,this.kernel.setting.get("clipboard.maxItemLength")).map((e=>(this.savedClipboardIndex[e.md5]=1,e)))}catch(e){$ui.alert({title:$l10n("REBUILD_DATABASE"),message:$l10n("CLIPS_STRUCTURE_ERROR"),actions:[{title:$l10n("OK"),handler:()=>{const e=i.loading();e.start(),this.kernel.storage.rebuild(),e.end(),$delay(.8,(()=>$addin.restart()))}},{title:$l10n("CANCEL")}]}),this.kernel.error(e)}};this.allClips=[e(this.kernel.storage.all(this.tabItemsIndex[0])),e(this.kernel.storage.all(this.tabItemsIndex[1]))]}}})),parcelRequire.register("ay4Kj",(function(e,t){var i=parcelRequire("gxpqj"),r=i.UIKit,s=i.SearchBar;e.exports=class{listId="clips-list-search";kernel;callback=()=>{};onBegin=()=>{};onDismiss=()=>{};constructor(e){this.kernel=e,this.searchBar=new s,this.searchBarId=this.searchBar.id+"-input"}get searchHistoryView(){return{hide:()=>$(this.listId+"-history").hidden=!0,show:()=>$(this.listId+"-history").hidden=!1}}get searchHistory(){return[{title:$l10n("SEARCH_HISTORY"),rows:$cache.get("caio.search.history")?.reverse()??[]}]}getAccessoryView(){return r.blurBox({height:50},[{type:"button",props:{bgcolor:$color("clear"),tintColor:$color("primaryText"),symbol:"xmark.circle"},layout:(e,t)=>{e.right.inset(0),e.height.equalTo(t.super),e.width.equalTo(t.super.height)},events:{tapped:()=>this.dismiss()}},{type:"button",props:{bgcolor:$color("clear"),tintColor:$color("primaryText"),symbol:"keyboard.chevron.compact.down"},layout:(e,t)=>{e.right.equalTo(t.prev.left),e.height.equalTo(t.super),e.width.equalTo(t.super.height)},events:{tapped:()=>$(this.searchBarId).blur()}}])}getSearchHistoryView(){return{type:"list",props:{id:this.listId+"-history",hidden:!0,stickyHeader:!0,data:this.searchHistory,separatorInset:$insets(0,13,0,0),actions:[{title:$l10n("DELETE"),handler:(e,t)=>{const i=e.data;this.updateSearchHistory(i[0].rows.reverse())}}]},events:{didSelect:(e,t,i)=>{this.searchAction(i),$(this.searchBarId).text=i}},layout:$layout.fill}}setCallback(e){this.callback=e}setOnBegin(e){this.onBegin=e}setOnDismiss(e){this.onDismiss=e}begin(){this.searchHistoryView.show(),this.onBegin()}dismiss(){$(this.searchBarId).blur(),$(this.searchBarId).text="",this.searchHistoryView.hide(),this.onDismiss()}searchAction(e){try{if(""!==e){const t=this.kernel.storage.search(e);t&&t.length>0?($(this.searchBarId).blur(),this.callback(t)):$ui.toast($l10n("NO_SEARCH_RESULT")),this.pushSearchHistory(e)}}catch(e){throw e}}pushSearchHistory(e){let t=$cache.get("caio.search.history")??[];-1===t.indexOf(e)&&(t.push(e),t.length>20&&(t=t.slice(-20)),$(this.listId+"-history").data=this.searchHistory,$cache.set("caio.search.history",t))}updateSearchHistory(e=[]){$cache.set("caio.search.history",e)}getSearchBarView(){return this.searchBar.controller.setEvent("onReturn",(e=>{""!==e?this.searchAction(e):this.searchHistoryView.show()})),this.searchBar.controller.setEvent("onChange",(e=>{""===e&&this.searchHistoryView.show()})),this.searchBar.setEvent("didBeginEditing",(e=>{""===e.text&&this.begin()})),this.searchBar.setAccessoryView(this.getAccessoryView()),this.searchBar}}})),parcelRequire.register("9LqeL",(function(e,t){var i=parcelRequire("gxpqj"),r=i.View,s=i.UIKit,a=i.Sheet;class n{static symbol={selected:"checkmark.circle.fill",unselected:"circle"};listId="clips-list-editor";reorder={};toolBarHeight=44;#ee=void 0;#te={};constructor(e){this.clipsInstance=e,this.kernel=e.kernel}get editorSelectedIsEmpty(){let e=!0;const t=this.editorSelected;for(const i of Object.keys(t))if(t[i]){e=!1;break}return e}get editorSelectedIsFull(){let e=0,t=0;const i=this.editorSelected;for(const r of Object.keys(i))++t,i[r]&&++e;return t===e}get editorSelected(){return void 0===this.#ee&&(Array(this.clipsInstance.clips.length).fill(0).map(((e,t)=>this.#te[t]=!1)),this.#ee=new Proxy(this.#te,{set:(e,t,i,r)=>{Reflect.set(e,t,i,r),t=Number(t);const s=this.editorSelectedIsEmpty,a=$(this.listId+"-select-button"),o=$(this.listId+"-delete-button");a.title=this.editorSelectedIsFull?$l10n("DESELECT_ALL"):$l10n("SELECT_ALL"),o.hidden=s;const l=$(this.listId);return l.data=this.clipsInstance.clips.map(((t,i)=>{const r=this.lineData(t);return r.checkmark={symbol:e[i]?n.symbol.selected:n.symbol.unselected},r})),l.reorder=s,!0}})),this.#ee}set editorSelected(e){this.#ee=e}selectAll(){const e=this.editorSelectedIsFull;this.clipsInstance.clips.forEach(((t,i)=>{this.editorSelected[i]=!e}))}deleteSelected(){this.kernel.deleteConfirm($l10n("CONFIRM_DELETE_MSG"),(()=>{const e=$(this.listId),t=$(this.clipsInstance.listId);Object.keys(this.editorSelected).reverse().forEach((i=>{if(this.editorSelected[i]){i=Number(i);const r=this.clipsInstance.clips[i];this.kernel.print(`delete selected: [${i}]\n${r.text}`),this.clipsInstance.delete(r.uuid,i),t.delete(i),e.delete(i)}}))}))}getToolBarView(){return s.blurBox({},[s.separatorLine(),{type:"view",views:[{type:"button",props:{id:this.listId+"-select-button",title:$l10n("SELECT_ALL"),titleColor:$color("tint"),bgcolor:$color("clear")},layout:(e,t)=>{e.left.inset(this.clipsInstance.left_right),e.centerY.equalTo(t.super)},events:{tapped:()=>this.selectAll()}},{type:"button",props:{id:this.listId+"-delete-button",symbol:"trash",hidden:!0,tintColor:$color("red"),bgcolor:$color("clear")},layout:(e,t)=>{e.right.inset(this.clipsInstance.left_right),e.centerY.equalTo(t.super)},events:{tapped:()=>this.deleteSelected()}}],layout:(e,t)=>{e.left.right.top.equalTo(t.super),e.bottom.equalTo(t.super.safeAreaBottom)}}],((e,t)=>{e.left.right.bottom.equalTo(t.super),e.top.equalTo(t.super.safeAreaBottom).offset(-this.toolBarHeight)}))}lineData(e){const t=this.clipsInstance.lineData(e);return t.checkmark={symbol:n.symbol.unselected},t}listTemplate(){const e=this.clipsInstance.listTemplate();return e.views[0].layout=(e,t)=>{e.height.right.equalTo(t.super),e.left.inset(30)},e.views.push({type:"image",props:{id:"checkmark",symbol:n.symbol.unselected,contentMode:$contentMode.scaleAspectFit},layout:(e,t)=>{e.centerY.equalTo(t.super),e.left.inset(15),e.size.equalTo($size(25,25))}}),e}getListEditerView(){return{type:"list",props:{id:this.listId,bgcolor:s.primaryViewBackgroundColor,separatorInset:$insets(0,this.clipsInstance.left_right,0,0),indicatorInsets:$insets(0,0,this.toolBarHeight,0),data:this.clipsInstance.clips.map((e=>this.lineData(e))),template:this.listTemplate(),reorder:!0,footer:{height:this.toolBarHeight},crossSections:!1},events:{rowHeight:(e,t)=>{const i=this.clipsInstance.clips[t.row].text;return(this.kernel.storage.isImage(i)?this.imageContentHeight:this.clipsInstance.getTextHeight(i))+2*this.clipsInstance.top_bottom},reorderBegan:e=>{this.reorder.began=!0,this.reorder.from=e.row,this.reorder.to=void 0},reorderMoved:(e,t)=>{this.reorder.to=t.row},reorderFinished:()=>{this.reorder.began=!1,void 0!==this.reorder.to&&this.clipsInstance.move(this.reorder.from,this.reorder.to)},didSelect:(e,t,i)=>{this.editorSelected[t.row]=!this.editorSelected[t.row]}},layout:$layout.fill}}presentSheet(){const e=new a;e.setView(r.createFromViews([this.getListEditerView(),this.getToolBarView()])).addNavBar({title:"",popButton:{title:$l10n("CLOSE")},rightButtons:[{title:$l10n("CLEAR"),color:$color("red"),tapped:async()=>{if(0===(await $ui.alert({title:$l10n("DELETE_DATA"),message:$l10n("DELETE_TABLE").replace("${table}",this.clipsInstance.tableL10n),actions:[{title:$l10n("DELETE"),style:$alertActionType.destructive},{title:$l10n("CANCEL")}]})).index)try{this.kernel.storage.deleteTable(this.clipsInstance.table),e.dismiss(),this.clipsInstance.loadAllClips(),this.clipsInstance.updateList()}catch(e){this.kernel.error(e),$ui.error(e)}}}]}).init().present()}}e.exports=n})),parcelRequire.register("44eiF",(function(e,t){var i=parcelRequire("gxpqj"),r=i.Matrix,s=i.Setting,a=i.NavigationView,n=i.BarButtonItem,o=i.Sheet,l=i.UIKit,c=parcelRequire("f0nX9"),h=parcelRequire("eSp9Z"),d=h.ActionEnv,p=h.ActionData,u=h.Action;e.exports=class{matrixId="actions";matrix;reorder={};constructor(e){this.kernel=e,this.actionPath="scripts/action",this.actionOrderFile="order.json",this.userActionPath=`${this.kernel.fileStorage.basePath}/user_action`,this.typeNameMap={},this.checkUserAction()}importExampleAction(){try{Object.keys(__ACTIONS__).forEach((e=>{const t=`${this.userActionPath}/${e}`;Object.keys(__ACTIONS__[e]).forEach((i=>{$file.exists(`${t}/${i}/main.js`)||($file.mkdir(t),$file.mkdir(`${t}/${i}`),$file.write({data:$data({string:__ACTIONS__[e][i]["main.js"]}),path:`${t}/${i}/main.js`}),$file.write({data:$data({string:__ACTIONS__[e][i]["config.json"]}),path:`${t}/${i}/config.json`}),$file.write({data:$data({string:__ACTIONS__[e][i]["README.md"]}),path:`${t}/${i}/README.md`}))}))}))}catch{$file.list(this.actionPath).forEach((e=>{const t=`${this.actionPath}/${e}`;if($file.isDirectory(t)){const i=`${this.userActionPath}/${e}`;$file.list(t).forEach((e=>{$file.exists(`${i}/${e}/main.js`)||($file.mkdir(i),$file.copy({src:`${t}/${e}`,dst:`${i}/${e}`}))}))}}))}}checkUserAction(){$file.exists(this.userActionPath)&&0!==$file.list(this.userActionPath).length||($file.mkdir(this.userActionPath),this.importExampleAction())}getActionTypes(){const e=["clipboard","editor"];return e.concat($file.list(this.userActionPath).filter((t=>{if($file.isDirectory(`${this.userActionPath}/${t}`)&&e.indexOf(t)<0)return t})))}getActionOrder(e){const t=`${this.userActionPath}/${e}/${this.actionOrderFile}`;return $file.exists(t)?JSON.parse($file.read(t).string):[]}getActionPath(e,t){return`${this.userActionPath}/${e}/${t}`}getAction(e,t,i){const r=this.getActionPath(e,t),s=JSON.parse($file.read(`${r}/config.json`).string);try{const e=$file.read(`${r}/main.js`).string,t=new Function("Action","ActionEnv","ActionData",`${e}\n return MyAction`)(u,d,p);return new t(this.kernel,s,i)}catch(e){$ui.error(e),this.kernel.error(e)}}getActionHandler(e,t){return async i=>{try{const r=this.getAction(e,t,i);return await r.do()}catch(e){$ui.error(e),this.kernel.error(e)}}}getActions(e){const t=[],i=`${this.userActionPath}/${e}`;if(!$file.exists(i))return[];const r=r=>{const s=`${i}/${r}/`;if($file.isDirectory(s)){const i=JSON.parse($file.read(s+"config.json").string);t.push(Object.assign(i,{dir:r,type:e,name:i.name??r,icon:i.icon}))}},s=this.getActionOrder(e);return s.forEach((e=>r(e))),$file.list(i).forEach((e=>{-1===s.indexOf(e)&&r(e)})),t}getTypeName(e){const t=e.toUpperCase(),i=$l10n(t),r=i===t?e:i;return this.typeNameMap[r]=e,r}getTypeDir(e){return this.typeNameMap[e]??e}editActionInfoPageSheet(e,t){const i=this.getActionTypes(),r={};i.forEach(((e,t)=>{r[e]=t})),this.editingActionInfo=e??{type:"clipboard",name:"MyAction",color:"#CC00CC",icon:"icon_062.png",description:""};const a=new s({structure:{},set:(e,t)=>(this.editingActionInfo[e]="type"===e?t[1]:t,!0),get:(e,t=null)=>"type"===e?r[this.editingActionInfo.type]:Object.prototype.hasOwnProperty.call(this.editingActionInfo,e)?this.editingActionInfo[e]:t}),n=a.createInput("name",["pencil.circle","#FF3366"],$l10n("NAME")),l=a.createColor("color",["pencil.tip.crop.circle","#0066CC"],$l10n("COLOR")),c=a.createIcon("icon",["star.circle","#FF9933"],$l10n("ICON"),this.kernel.setting.getColor(this.editingActionInfo.color)),h=a.createMenu("type",["tag.circle","#33CC33"],$l10n("TYPE"),i,!0),d={type:"view",views:[{type:"text",props:{id:"action-text",textColor:$color("#000000","secondaryText"),bgcolor:$color("systemBackground"),text:this.editingActionInfo.description,insets:$insets(10,10,10,10)},layout:$layout.fill,events:{tapped:t=>{$("actionInfoPageSheetList").scrollToOffset($point(0,e?230:280)),setTimeout((()=>t.focus()),200)},didChange:e=>{this.editingActionInfo.description=e.text}}}],layout:$layout.fill},p=[{title:$l10n("INFORMATION"),rows:[n,l,c]},{title:$l10n("DESCRIPTION"),rows:[d]}];e||(p[0].rows=p[0].rows.concat(h));(new o).setView({type:"list",props:{id:"actionInfoPageSheetList",bgcolor:$color("insetGroupedBackground"),style:2,separatorInset:$insets(0,50,0,10),data:p},layout:$layout.fill,events:{rowHeight:(e,t)=>1===t.section?120:50}}).addNavBar({title:"",popButton:{title:$l10n("DONE"),tapped:()=>{this.editingActionInfo.dir||(this.editingActionInfo.dir=$text.MD5(this.editingActionInfo.name)),this.saveActionInfo(this.editingActionInfo),t&&t(this.editingActionInfo)}}}).init().present()}editActionMainJs(e="",t){new c(this.kernel).pageSheet(e,(e=>{this.saveMainJs(t,e)}),t.name,[{symbol:"book.circle",tapped:()=>{const e=$file.read("scripts/action/README.md").string;(new o).setView({type:"markdown",props:{content:e},layout:(e,t)=>{e.size.equalTo(t.super)}}).init().present()}}],"code")}saveActionInfo(e){const t=`${this.userActionPath}/${e.type}/${e.dir}`;$file.exists(t)||$file.mkdir(t),$file.write({data:$data({string:JSON.stringify({icon:e.icon,color:e.color,name:e.name,description:e.description})}),path:`${t}/config.json`})}saveMainJs(e,t){const i=`${this.userActionPath}/${e.type}/${e.dir}`,r=`${i}/main.js`;$file.exists(i)||$file.mkdir(i),$text.MD5(t)!==$text.MD5($file.read(r)?.string??"")&&$file.write({data:$data({string:t}),path:r})}saveOrder(e,t){$file.write({data:$data({string:JSON.stringify(t)}),path:`${this.userActionPath}/${e}/${this.actionOrderFile}`})}move(e,t,i){if(e.section===t.section&&e.row===t.row)return;const r=(i=i.map((e=>(e.rows=e.rows.map((e=>e.info.info)),e))))[e.section],s=i[t.section],a=e=>{const t=[];return i[e].rows.forEach((e=>t.push(e.dir))),t},n=this.getTypeDir(r.title),o=this.getTypeDir(s.title);e.section===t.section?this.saveOrder(n,a(e.section)):(this.saveOrder(n,a(e.section)),this.saveOrder(o,a(t.section)),$file.move({src:`${this.userActionPath}/${n}/${s.rows[t.row].dir}`,dst:`${this.userActionPath}/${o}/${s.rows[t.row].dir}`})),((i=!0,r)=>{const a=this.matrix,n=this.actionToData(Object.assign(s.rows[t.row],{type:r}));i?(a.insert({indexPath:$indexPath(t.section,t.row+1),value:n},!1),a.delete(e,!1)):(a.delete(e,!1),a.insert({indexPath:t,value:n},!1))})(e.row{const i=e.cell(t),r=i.get("info").info;this.editActionInfoPageSheet(r,(e=>{i.get("info").info=e,i.get("color").bgcolor=this.kernel.setting.getColor(e.color),i.get("name").text=e.name,"icon_"===e.icon.slice(0,5)?i.get("icon").icon=$icon(e.icon.slice(5,e.icon.indexOf(".")),$color("#ffffff")):i.get("icon").image=$image(e.icon)}))}},{title:$l10n("EDIT_SCRIPT"),symbol:"square.and.pencil",handler:(e,t,i)=>{const r=i.info.info;if(!r)return;const s=`${this.userActionPath}/${r.type}/${r.dir}/main.js`,a=$file.read(s).string;this.editActionMainJs(a,r)}},{inline:!0,items:[{title:"README",symbol:"book",handler:(e,t)=>{const i=e.cell(t).get("info").info;let r;try{r=__ACTIONS__[i.type][i.dir]["README.md"]}catch{const e=this.getActionPath(i.type,i.dir);r=$file.read(e+"/README.md").string}(new o).setView({type:"markdown",props:{content:r},layout:(e,t)=>{e.size.equalTo(t.super)}}).init().present()}}]},{inline:!0,items:[{title:$l10n("DELETE"),symbol:"trash",destructive:!0,handler:(e,t,i)=>{this.kernel.deleteConfirm($l10n("CONFIRM_DELETE_MSG"),(()=>{this.delete(i.info.info),e.delete(t)}))}}]}]}getNavButtons(){return[{symbol:"plus.circle",menu:{pullDown:!0,asPrimary:!0,items:[{title:$l10n("CREATE_NEW_ACTION"),handler:()=>{this.editActionInfoPageSheet(null,(e=>{this.matrix.insert({indexPath:$indexPath(this.getActionTypes().indexOf(e.type),0),value:this.actionToData(e)});const t=$file.read(`${this.actionPath}/template.js`).string;this.saveMainJs(e,t),this.editActionMainJs(t,e)}))}},{title:$l10n("CREATE_NEW_TYPE"),handler:()=>{$input.text({text:"",placeholder:$l10n("CREATE_NEW_TYPE"),handler:e=>{if(""===(e=e.trim()))return void $ui.toast($l10n("INVALID_VALUE"));const t=`${this.userActionPath}/${e}`;$file.isDirectory(t)?$ui.warning($l10n("TYPE_ALREADY_EXISTS")):($file.mkdir(t),$ui.success($l10n("SUCCESS")))}})}}]}},{symbol:"arrow.up.arrow.down.circle",tapped:(e,t)=>{$ui.popover({sourceView:t,directions:$popoverDirection.up,size:$size(200,300),views:[this.getActionListView(void 0,{reorder:!0,actions:[{title:"delete",handler:(e,t)=>{const i=this.matrix,r=i.object(t,!1).info.info;this.delete(r),i.delete(t,!1)}}]},{reorderBegan:e=>{this.reorder.from=e,this.reorder.to=void 0},reorderMoved:(e,t)=>{this.reorder.to=t},reorderFinished:e=>{void 0!==this.reorder.to&&this.move(this.reorder.from,this.reorder.to,e)}})]})}}]}actionToData(e){return{name:{text:e.name},icon:"icon_"===e.icon.slice(0,5)?{icon:$icon(e.icon.slice(5,e.icon.indexOf(".")),$color("#ffffff"))}:{image:$image(e.icon)},color:{bgcolor:this.kernel.setting.getColor(e.color)},info:{info:e}}}actionsToData(){return this.getActionTypes().map((e=>{const t=[];return this.getActions(e).forEach((e=>{t.push(this.actionToData(e))})),{title:this.getTypeName(e),items:t,rows:t}}))}getActionListView(e,t={},i={}){return e&&(i.didSelect=(t,i,r)=>{const s=r.info.info,a=this.kernel.actionManager.getActionHandler(s.type,s.dir);e(a)}),{type:"list",layout:(e,t)=>{e.top.width.equalTo(t.super.safeArea),e.bottom.inset(0)},events:i,props:Object.assign({reorder:!1,bgcolor:$color("clear"),rowHeight:60,sectionTitleHeight:30,stickyHeader:!0,data:this.actionsToData(),template:{props:{bgcolor:$color("clear")},views:[{type:"image",props:{id:"color",cornerRadius:8,smoothCorners:!0},layout:(e,t)=>{e.centerY.equalTo(t.super),e.left.inset(15),e.size.equalTo($size(30,30))}},{type:"image",props:{id:"icon",tintColor:$color("#ffffff")},layout:(e,t)=>{e.centerY.equalTo(t.super),e.left.inset(20),e.size.equalTo($size(20,20))}},{type:"label",props:{id:"name",lines:1,font:$font(16)},layout:(e,t)=>{e.height.equalTo(30),e.centerY.equalTo(t.super),e.left.equalTo(t.prev.right).offset(15)}},{type:"label",props:{id:"info"}}]}},t)}}getMatrixView({columns:e=2,spacing:t=15,itemHeight:i=100}={}){return this.matrix=r.create({type:"matrix",props:{id:this.matrixId,columns:e,itemHeight:i,spacing:t,bgcolor:l.scrollViewBackgroundColor,menu:{items:this.menuItems()},data:this.actionsToData(),template:{props:{smoothCorners:!0,cornerRadius:10,bgcolor:$color("#ffffff","#242424")},views:[{type:"image",props:{id:"color",cornerRadius:8,smoothCorners:!0},layout:e=>{e.top.left.inset(10),e.size.equalTo($size(30,30))}},{type:"image",props:{id:"icon",tintColor:$color("#ffffff")},layout:e=>{e.top.left.inset(15),e.size.equalTo($size(20,20))}},{type:"button",props:{bgcolor:$color("clear"),tintColor:l.textColor,titleColor:l.textColor,contentEdgeInsets:$insets(0,0,0,0),titleEdgeInsets:$insets(0,0,0,0),imageEdgeInsets:$insets(0,0,0,0)},views:[{type:"image",props:{symbol:"ellipsis.circle"},layout:(e,t)=>{e.center.equalTo(t.super),e.size.equalTo(n.style.iconSize)}}],events:{tapped:e=>{const t=e.next.info;if(!t)return;const i=`${this.userActionPath}/${t.type}/${t.dir}/main.js`,r=$file.read(i).string;this.editActionMainJs(r,t)}},layout:e=>{e.top.right.inset(0),e.size.equalTo(n.style.width)}},{type:"view",props:{id:"info",hidden:!0}},{type:"label",props:{id:"name",font:$font(16)},layout:(e,t)=>{e.bottom.left.inset(10),e.width.equalTo(t.super)}}]}},layout:$layout.fill,events:{didSelect:(e,t,i)=>{const r=i.info.info,s=new p({env:d.action,text:"clipboard"===r.type||"uncategorized"===r.type?$clipboard.text:null});this.getActionHandler(r.type,r.dir)(s)},pulled:e=>{$delay(.5,(()=>{e.endRefreshing(),this.matrix.update(this.actionsToData())}))}}}),this.matrix.definition}getPage(){const e=new a;return e.navigationBarItems.setRightButtons(this.getNavButtons()),e.setView(this.getMatrixView()).navigationBarTitle($l10n("ACTIONS")),e.getPage()}present(){(new o).setView(this.getMatrixView()).addNavBar({title:$l10n("ACTIONS"),popButton:{symbol:"xmark.circle"},rightButtons:this.getNavButtons()}).init().present()}}})),parcelRequire.register("gYDdO",(function(e,t){async function i(e){!function(e,t=[]){t.forEach((t=>{$file.exists(t)&&(e.print(`delete file: ${t}`),$file.delete(t))}))}(e,["scripts/action/clipboard/ClearClipboard","scripts/ui/clipboard.js","scripts/ui/clipboard-data.js","scripts/ui/clipboard-search.js"]),function(e){const t=e.storage.sqlite.query('SELECT count(*), name FROM sqlite_master WHERE type = "table" AND name = "clipboard"');if(null!==t.error)throw new Error(`Code [${t.error.code}] ${t.error.domain} ${t.error.localizedDescription}`);t.result.next();const i=t.result.get(0);t.result.close(),i>0&&(e.print("copy data from old table: clipboard"),e.storage.sqlite.update("INSERT INTO clips SELECT * FROM clipboard"),e.print("drop table: clipboard"),e.storage.sqlite.update("DROP TABLE clipboard"))}(e),await async function(e,t={}){const i="scripts/action",r=`${e.fileStorage.basePath}/user_action`,s=[];for(let e of Object.keys(t))t[e].forEach((t=>{const r=JSON.parse($file.read(`${i}/${e}/${t}/config.json`).string);s.push(r.name)}));if(1!==(await $ui.alert({title:$l10n("compatibility.rebuildUserAction.alert.title"),message:$l10n("compatibility.rebuildUserAction.alert.message")+"\n"+JSON.stringify(s,null,2)+"\n"+$l10n("compatibility.rebuildUserAction.alert.message2"),actions:[{title:$l10n("OK")},{title:$l10n("CANCEL")}]})).index)for(let s of Object.keys(t))t[s].forEach((t=>{$file.exists(`${r}/${s}/${t}`)&&(e.print(`rebuild user action: ${s}/${t}`),$file.copy({src:`${i}/${s}/${t}/main.js`,dst:`${r}/${s}/${t}/main.js`}))}))}(e,{uncategorized:["ExportAllContent","DisplayClipboard"],clipboard:["B23Clean"]}),$cache.get("caio.keyboard.height")&&(e.setting.set("keyboard.previewAndHeight",$cache.get("caio.keyboard.height")),$cache.remove("caio.keyboard.height"))}e.exports=async function(e){if(!e)return;const t=$cache.get("compatibility.version")??0;try{t<1&&(e.print(`compatibility: userVersion [${t}] lower than [1], start action`),await i(e))}catch(t){throw e.error(t),t}$cache.set("compatibility.version",1)}})),parcelRequire.register("9RsVy",(function(e,t){var i=parcelRequire("gxpqj"),r=i.Kernel,s=i.UIKit,a=parcelRequire("2aNLD"),n=parcelRequire("ilpYs");let o;function l(){o.setting.method.exportClipboard=e=>{e.actionStart(),o.storage.export((t=>{t?e.actionDone():e.actionCancel()}))},o.setting.method.importClipboard=e=>{e.actionStart(),$ui.alert({title:$l10n("ALERT_INFO"),message:$l10n("OVERWRITE_ALERT"),actions:[{title:$l10n("OK"),handler:()=>{$drive.open({handler:t=>{void 0!==t?"db"===t.fileName.slice(-2)||"zip"===t.fileName.slice(-3)?o.storage.import(t).then((()=>{e.actionDone(),$delay(.3,(()=>{$addin.restart()}))})).catch((t=>{$ui.error(t),o.print(t),e.actionCancel()})):($ui.warning($l10n("FILE_TYPE_ERROR")),e.actionCancel()):e.actionCancel()}})}},{title:$l10n("CANCEL"),handler:()=>e.actionCancel()}]})},o.setting.method.rebuildDatabase=e=>{e.actionStart();$ui.alert({title:$l10n("REBUILD_DATABASE_ALERT"),actions:[{title:$l10n("REBUILD"),style:$alertActionType.destructive,handler:()=>{(()=>{try{o.storage.rebuild(),e.actionDone(),$delay(.8,(()=>$addin.restart()))}catch(t){e.actionCancel(),$ui.alert(t)}})()}},{title:$l10n("CANCEL"),handler:()=>{e.actionCancel()}}]})},o.setting.method.deleteAllData=e=>{e.actionStart(),$ui.alert({title:$l10n("DELETE_ALL_DATA_ALERT"),actions:[{title:$l10n("DELETE"),style:$alertActionType.destructive,handler:()=>{o.storage.deleteAllData(),e.actionDone(),$delay(.5,(()=>$addin.restart()))}},{title:$l10n("CANCEL"),handler:()=>{e.actionCancel()}}]})}}e.exports=function(e){o=e,o.setting.method.checkUpdate=async e=>{e.actionStart();const t="scripts/libs/easy-jsbox.js";if($file.exists(t))try{const e=await o.checkUpdate();e&&($file.write({data:$data({string:e}),path:t}),$ui.toast("The framework has been updated."))}catch{}$http.get({url:"https://raw.githubusercontent.com/ipuppet/CAIO/master/config.json",handler:t=>{const i=t.data?.info.version;let s;try{s=__INFO__}catch{s=JSON.parse($file.read("config.json").string).info}r.versionCompare(i,s.version)>0?$ui.alert({title:"New Version",message:`New version found: ${i}\nUpdate via Github or click the button to open Erots.`,actions:[{title:$l10n("CANCEL")},{title:"Erots",handler:()=>{$addin.run({name:"Erots",query:{q:"show",objectId:"603e6eaaca0dd64fcef93e2d"}})}}]}):$ui.toast("No need to update"),e.actionDone()}})},o.setting.method.previewWidget=e=>{const{Widget:t}=parcelRequire("8Makm"),i={};try{JSON.parse($file.read("widget-options.json").string).forEach((e=>{i[e.name]=e.value}))}catch(e){return void $ui.error(e)}$ui.menu({items:Object.keys(i),handler:e=>{t.render(i[e])}})},o.setting.method.fileManager=()=>{o.fileManager.push("storage")},l(),o.setting.method.exportAction=e=>{e.actionStart();const t="actions.zip",i="/actions.zip",r=o.fileStorage.filePath(i);$archiver.zip({directory:o.actionManager.userActionPath,dest:r,handler:()=>{$share.sheet({items:[{name:t,data:$data({path:r})}],handler:t=>{t?e.actionDone():e.actionCancel(),o.fileStorage.delete(i)}})}})},o.setting.method.importAction=e=>{e.actionStart(),$drive.open({handler:t=>{if(void 0!==t)if("zip"===t.fileName.slice(-3)){const i=`${o.fileStorage.basePath}/action_import`;$archiver.unzip({file:t,dest:i,handler:()=>{$file.list(i).forEach((e=>{$file.isDirectory(`${i}/${e}`)&&$file.copy({src:`${i}/${e}`,dst:`${o.actionManager.userActionPath}/${e}`})})),$file.delete(i),e.actionDone()}})}else $ui.warning($l10n("FILE_TYPE_ERROR")),e.actionCancel();else e.actionCancel()}})},o.setting.method.importExampleAction=e=>{e.actionStart(),o.actionManager.importExampleAction(),e.actionDone()},o.setting.method.rebuildAction=e=>{e.actionStart(),$ui.alert({title:$l10n("REBUILD_ACTION_DATABASE_ALERT"),actions:[{title:$l10n("REBUILD"),style:$alertActionType.destructive,handler:()=>{$file.delete(o.actionManager.userActionPath),e.actionDone(),$delay(.8,(()=>$addin.restart()))}},{title:$l10n("CANCEL")}]})},function(){const e=parcelRequire("7eNYp"),t=200;o.setting.method.previewKeyboard=()=>{const i=new e(o),r=$text.uuid,s=e=>{$(r).updateLayout((t=>{t.height.equalTo(e)})),i.keyboardHeight=e},a=e=>(e-t)/200;return{views:[{type:"label",layout:(e,t)=>{e.top.inset(20),e.centerX.equalTo(t.super)},events:{ready:e=>e.text=i.keyboardHeight,tapped:e=>{$input.text({type:$kbType.number,text:i.keyboardHeight,handler:i=>{if(/^[0-9]+$/.test(i)){let r=Number(i);r=Math.min(r,400),r=Math.max(r,t),e.text=r,e.next.value=a(r),s(r)}else $ui.toast("Only integers can be entered.")}})}}},{type:"slider",props:{max:1,min:0},layout:(e,t)=>{e.top.equalTo(t.prev.bottom),e.right.inset(20),e.width.equalTo(t.super).offset(-40)},events:{ready:e=>e.value=a(i.keyboardHeight),changed:e=>{const i=Math.floor(200*e.value+t);e.prev.text=i,s(i)}}},{type:"view",props:{id:r},views:[i.getView()],layout:(e,t)=>{e.width.equalTo(t.super),e.height.equalTo(i.keyboardHeight),e.bottom.inset(0)}}],layout:$layout.fill}},o.setting.method.setKeyboardQuickStart=()=>a.sheet()}(),o.setting.method.previewTodayWidget=e=>{e.touchHighlightStart();const t=new(parcelRequire("49je6"))(o).getView();s.push({views:[t],disappeared:()=>e.touchHighlightEnd()})},o.setting.method.setTodayWidgetActions=e=>{n.sheet(o)}}})),parcelRequire.register("2aNLD",(function(e,t){var i=parcelRequire("gxpqj").Sheet;class r{constructor(){this.listId="keyboard-script-list"}static getAddins(){const e=$cache.get("keyboard.addins");return void 0===e?(this.setAddins(),[]):JSON.parse(e)}static setAddins(e=[]){e.map(((t,i)=>{null===t&&e.splice(i,1)})),$cache.set("keyboard.addins",JSON.stringify(e))}getUnsetAddins(){const e=$addin.current.name,t=r.getAddins(),i=[];return $addin.list?.forEach((r=>{const s=r.displayName;-1===t.indexOf(s)&&e!==s&&i.push(s)})),i}add(){const e={type:"list",props:{data:this.getUnsetAddins()},events:{didSelect:(e,t,i)=>{const s=r.getAddins();s.unshift(i),r.setAddins(s),$(this.listId).insert({indexPath:$indexPath(0,0),value:i}),e.delete(t)}},layout:$layout.fill};(new i).setView(e).addNavBar({title:$l10n("ADD")}).init().present()}getNavButtons(){return[{symbol:"plus",tapped:()=>this.add()}]}getListView(){return{type:"list",props:{id:this.listId,reorder:!0,data:r.getAddins(),actions:[{title:"delete",handler:(e,t)=>{r.setAddins(e.data)}}]},events:{reorderFinished:e=>{r.setAddins(e)}},layout:$layout.fill}}static sheet(){const e=new i,t=new r;e.setView(t.getListView()).addNavBar({title:$l10n("QUICK_START_SCRIPTS"),popButton:{title:$l10n("CLOSE")},rightButtons:t.getNavButtons()}),e.init().present()}}e.exports=r})),parcelRequire.register("ilpYs",(function(e,t){var i=parcelRequire("gxpqj").Sheet;class r{constructor(e){this.listId="today-action-list",this.kernel=e}getActions(){let e=$cache.get("today.actions")??[];"string"==typeof e&&(e=JSON.parse(e),this.setActions(e));const t={};this.kernel.actionManager.getActionTypes().forEach((e=>{this.kernel.actionManager.getActions(e).forEach((e=>{t[e.type+e.dir]=e}))}));const i=[];let r=!1;return e.forEach((e=>{const s=t[e.type+e.dir];s?i.push(s):r=!0})),r&&this.setActions(i),i}setActions(e=[]){e.map(((t,i)=>{t||e.splice(i,1)})),$cache.set("today.actions",e)}getAllActions(){let e=[];return this.kernel.actionManager.getActionTypes().forEach((t=>{e=e.concat(this.kernel.actionManager.getActions(t))})),e}getUnsetActions(){const e=this.getActions().map((e=>e.name)),t=[];return this.getAllActions().forEach((i=>{const r=i.name;-1===e.indexOf(r)&&t.push(i)})),t}getListData(e){return e.map((e=>({action:{text:e.name,info:e},icon:"icon_"===e.icon.slice(0,5)?{icon:$icon(e.icon.slice(5,e.icon.indexOf(".")),$color("#ffffff"))}:{image:$image(e.icon)},color:{bgcolor:this.kernel.setting.getColor(e.color)}})))}getListTemplate(){return{views:[{type:"image",props:{id:"color",cornerRadius:8,smoothCorners:!0},layout:e=>{e.top.left.inset(10),e.size.equalTo($size(30,30))}},{type:"image",props:{id:"icon",tintColor:$color("#ffffff")},layout:e=>{e.top.left.inset(15),e.size.equalTo($size(20,20))}},{type:"label",props:{id:"action"},layout:(e,t)=>{e.bottom.top.inset(10),e.left.equalTo(t.prev.prev.right).offset(10),e.right.inset(10)}}]}}add(){const e={type:"list",props:{data:this.getListData(this.getUnsetActions()),template:this.getListTemplate(),rowHeight:50},events:{didSelect:(e,t,i)=>{const r=i.action.info,s=this.getActions();s.unshift(r),this.setActions(s),$(this.listId).insert({indexPath:$indexPath(0,0),value:this.getListData([r])[0]}),e.delete(t)}},layout:$layout.fill};(new i).setView(e).addNavBar({title:$l10n("ADD"),popButton:{title:$l10n("CLOSE")}}).init().present()}getNavButtons(){return[{symbol:"plus",tapped:()=>this.add()}]}getListView(){return{type:"list",props:{id:this.listId,data:this.getListData(this.getActions()),template:this.getListTemplate(),rowHeight:50,reorder:!0,actions:[{title:"delete",handler:(e,t)=>{this.setActions(e.data.map((e=>e.action.info)))}}]},events:{reorderFinished:e=>{const t=[];e.forEach((e=>{t.push(e.action.info)})),this.setActions(t)}},layout:$layout.fill}}static sheet(e){const t=new i,s=new r(e);t.setView(s.getListView()).addNavBar({title:$l10n("ACTIONS"),popButton:{title:$l10n("CLOSE")},rightButtons:s.getNavButtons()}),t.init().present()}}e.exports=r})),parcelRequire.register("7eNYp",(function(e,t){var i=parcelRequire("eSp9Z"),r=i.ActionData,s=i.ActionEnv,a=parcelRequire("gxpqj"),n=a.UIKit,o=a.BarButtonItem,l=parcelRequire("imdB1"),c=parcelRequire("2aNLD");e.exports=class extends l{#ie;deleteTimer=void 0;continuousDeleteTimer=void 0;deleteDelay=this.kernel.setting.get("keyboard.deleteDelay");continuousDeleteDelay=.5;left_right=15;top_bottom=10;containerMargin=5;fontSize=14;navHeight=50;menuItemActionMaxCount=3;constructor(e){super(e),this.listId="keyboard-clips-list",this.keyboardSwitchLockId="keyboard-switch-lock",this.keyboardSwitchLockKey="caio.keyboard.switch.lock",this.backgroundImage=this.kernel.setting.getImage("keyboard.background.image"),this.backgroundColor=this.kernel.setting.getColor(this.kernel.setting.get("keyboard.background.color")),this.backgroundColorDark=this.kernel.setting.getColor(this.kernel.setting.get("keyboard.background.color.dark")),this.keyboardSetting(),"boolean"!=typeof $cache.get(this.keyboardSwitchLockKey)&&$cache.set(this.keyboardSwitchLockKey,!1)}get keyboardHeight(){return this.kernel.setting.get("keyboard.previewAndHeight")}set keyboardHeight(e){this.kernel.setting.set("keyboard.previewAndHeight",e)}getKeyboardSwitchLock(){const e=$cache.get(this.keyboardSwitchLockKey);return"boolean"!=typeof e&&$cache.set(this.keyboardSwitchLockKey,!0),e}switchKeyboardSwitchLock(){const e=$cache.get(this.keyboardSwitchLockKey);$cache.set(this.keyboardSwitchLockKey,!e),$(this.keyboardSwitchLockId).symbol=e?"lock.open":"lock"}listReady(){this.updateList(),this.appListen(),this.kernel.setting.get("clipboard.autoSave")&&$app.env===$env.keyboard&&(this.#ie=$timer.schedule({interval:1,handler:()=>{this.kernel.setting.get("clipboard.autoSave")?this.readClipboard():this.#ie.invalidate()}}))}keyboardSetting(){if($app.env!==$env.keyboard)return;const e=$timer.schedule({interval:0,handler:()=>{$keyboard.height!==this.keyboardHeight?$keyboard.height=this.keyboardHeight:e.invalidate()}});this.kernel.setting.get("keyboard.showJSBoxToolbar")||($keyboard.barHidden=!0)}keyboardTapped(e,t=!0,i=1){return(...r)=>{t&&this.kernel.setting.get("keyboard.tapticEngine")&&$device.taptic(i),e(...r)}}getTopButtons(){const e=[{symbol:"keyboard.chevron.compact.down",tapped:this.keyboardTapped((()=>$keyboard.dismiss()))},{symbol:"square.and.arrow.down.on.square",tapped:this.keyboardTapped((e=>{e.start(),this.readClipboard(!0),e.done()}))},{symbol:"bolt.circle",tapped:this.keyboardTapped(((e,t)=>{const i=$ui.popover({sourceView:t,directions:$popoverDirection.up,size:$size(200,300),views:[this.kernel.actionManager.getActionListView((e=>{i.dismiss(),$delay(.5,(async()=>{const t=new r({env:s.keyboard,textBeforeInput:$keyboard.textBeforeInput,textAfterInput:$keyboard.textAfterInput,text:$keyboard.selectedText??await $keyboard.getAllText()});e(t)}))}))]})}))}];return{type:"view",views:e.map(((e,t)=>(new o).setAlign(n.align.right).setSymbol(e.symbol).setEvent("tapped",e.tapped).definition)),layout:(t,i)=>{const r=new o;t.height.equalTo(i.super),t.right.inset(this.containerMargin-r.edges),t.width.equalTo(r.width*e.length+r.edges)}}}getTopBarView(){return{type:"view",views:[{type:"view",layout:$layout.fill,views:[{type:"label",props:{text:$l10n("CAIO"),font:$font("bold",20)},events:{tapped:()=>this.kernel.openInJsbox(),ready:e=>{$cache.get("tips.keyboard.title")||($cache.set("tips.keyboard.title",!0),$ui.popover({sourceView:e,size:$size(200,60),directions:$popoverDirection.up,views:[{type:"label",props:{lines:0,text:$l10n("CLICK_TO_OPEN_JSBOX"),align:$align.center},layout:$layout.fillSafeArea}]}))}},layout:(e,t)=>{e.centerY.equalTo(t.super),e.left.equalTo(t.super).offset(this.containerMargin)}}].concat(this.tabView(),this.getTopButtons())}],layout:(e,t)=>{e.top.width.equalTo(t.super),e.height.equalTo(this.navHeight)}}}getButtonView(e,t){const i=$size(38,38),r=this.containerMargin;return n.blurBox({info:{align:t},smoothCorners:!0,cornerRadius:5},[{type:"button",props:Object.assign({symbol:e.symbol,title:e.title,id:e.id??$text.uuid,font:$font(16),bgcolor:this.backgroundImage?$color($rgba(172,176,184,.3),$rgba(71,71,73,.3)):$color("#ACB0B8","#474749"),tintColor:n.textColor,titleColor:n.textColor,info:{align:t}},e.menu?{menu:e.menu}:{}),events:Object.assign({},e.tapped?{tapped:e.tapped}:{},e.events),layout:$layout.fill}],((s,a)=>{if(e.title){const t=$text.sizeThatFits({text:e.title,width:n.windowSize.width,font:$font(16)}),a=Math.ceil(t.width)+2*r;s.size.equalTo($size(a,i.height))}else s.size.equalTo(i);s.centerY.equalTo(a.super),a.prev&&a.prev.info.align===t?t===n.align.right?s.right.equalTo(a.prev.left).offset(-r):s.left.equalTo(a.prev.right).offset(r):t===n.align.right?s.right.inset(r):s.left.inset(r)}))}getBottomBarView(){const e=[],t=[];return $device.hasFaceID&&!$device.isIpadPro||e.push({symbol:"globe",tapped:this.keyboardTapped((()=>$keyboard.next())),menu:{pullDown:!0,items:[{title:$l10n("SWITCH_KEYBOARD"),handler:this.keyboardTapped((()=>$keyboard.next()))},{title:$l10n("OPEN_IN_JSBOX"),handler:()=>this.kernel.openInJsbox()}]}}),this.kernel.setting.get("keyboard.switchAfterInsert")&&e.push({symbol:this.getKeyboardSwitchLock()?"lock":"lock.open",id:this.keyboardSwitchLockId,tapped:this.keyboardTapped((()=>this.switchKeyboardSwitchLock()))}),e.push({symbol:"paperplane",menu:{pullDown:!0,asPrimary:!0,items:c.getAddins().reverse().map((e=>({title:e,handler:this.keyboardTapped((()=>$addin.run(e)))})))}}),t.push({title:$l10n("SEND"),tapped:this.keyboardTapped((()=>$keyboard.send()))},{symbol:"delete.left",events:{touchesBegan:this.keyboardTapped((()=>{$keyboard.delete(),this.continuousDeleteTimer=$delay(this.continuousDeleteDelay,(()=>{this.deleteTimer=$timer.schedule({interval:this.deleteDelay,handler:this.keyboardTapped((()=>$keyboard.delete()),this.kernel.setting.get("keyboard.tapticEngineForDelete"),0)})}))})),touchesEnded:()=>{this.deleteTimer?.invalidate(),this.continuousDeleteTimer?.cancel(),this.deleteTimer=void 0,this.continuousDeleteTimer=void 0}}}),{type:"view",views:[...e.map((e=>this.getButtonView(e,n.align.left))),...t.map((e=>this.getButtonView(e,n.align.right)))],layout:(e,t)=>{e.bottom.left.right.equalTo(t.super.safeArea),e.top.equalTo(t.prev.bottom)}}}menuItems(){const e=super.menuItems();return[e[0],e[2]]}getListView(){const e=super.getListView();e.layout=(e,t)=>{e.top.equalTo(this.navHeight),e.width.equalTo(t.super),e.bottom.equalTo(t.super.safeAreaBottom).offset(-this.navHeight)};const t=e.views[0];t.events.didSelect=(e,t)=>{const i=this.clips[t.row],r=this.kernel.storage.keyToPath(i.text);r&&this.kernel.fileStorage.exists(r.original)?$quicklook.open({image:this.kernel.fileStorage.readSync(r.original)?.image}):($keyboard.insert(i.text),this.kernel.setting.get("keyboard.switchAfterInsert")&&!this.getKeyboardSwitchLock()&&$keyboard.next())},t.props.separatorInset=$insets(0,this.left_right,0,this.left_right);const i=n.blurBox({style:$blurStyle.ultraThinMaterial,smoothCorners:!0,cornerRadius:2*this.containerMargin},[t],((e,t)=>{e.bottom.top.equalTo(t.super),e.left.right.inset(this.containerMargin)}));return e.views[0]=i,e}getView(){return{type:"view",props:{id:"keyboard.main",bgcolor:$color(this.backgroundColor,this.backgroundColorDark)},views:[{type:"image",props:{image:this.backgroundImage,hidden:null===this.backgroundImage},layout:$layout.fill},this.getTopBarView(),this.getListView(),this.getBottomBarView()],layout:$layout.fill}}}})),parcelRequire.register("49je6",(function(e,t){var i=parcelRequire("eSp9Z"),r=i.ActionData,s=i.ActionEnv,a=parcelRequire("gxpqj"),n=a.View,o=a.UIKit,l=a.BarButtonItem,c=a.NavigationBarItems,h=a.NavigationBar,d=parcelRequire("imdB1"),p=parcelRequire("ilpYs");e.exports=class extends d{left_right=8;top_bottom=10;fontSize=14;navHeight=38;taptic=1;tagFontSize=10;tagContainerHeight=12;matrixItemHeight=50;tabItems=[$l10n("PIN"),$l10n("CLIPS"),$l10n("ACTIONS")];inLauncher=$app.env===$env.today&&-1===$app.widgetIndex;launcherNavHeight=44;constructor(e){super(e),this.actionsId="today-list-actions",this.listContainerId="today-list-container",this.readClipboardButtonId="today-nav-readClipboard",this.listId="today-list",this.navigationBarItems=new c,this.bottomBar=new h,this.bottomBar.navigationBarItems=this.navigationBarItems,this.todayActions=new p(this.kernel),this.setClipboarPageSize($widget.mode),this.listPageNow=[0,0],this.listSection=Math.min(this.tabIndex,1),this.setSingleLine()}get isActionPage(){return 2===this.tabIndex}set tabIndex(e){$cache.set("caio.today.tab.index",e)}get tabIndex(){return $cache.get("caio.today.tab.index")??0}listReady(){$widget.modeChanged=e=>{this.setClipboarPageSize(e),this.updateList()},this.setClipboarPageSize($widget.mode),this.loadAllClips(),this.updateList(),this.appListen(),$delay(.5,(()=>this.readClipboard()))}readClipboard(e=!1){return!this.isActionPage&&$app.env===$env.today&&(super.readClipboard(e),!0)}setClipboarPageSize(e){if(0===e)this.listPageSize=1;else{const e=(($app.env===$env.app?o.windowSize.height:$widget.height)-2*this.navHeight-(this.inLauncher?this.launcherNavHeight:0))/(this.singleLineHeight+2*this.top_bottom),t=Math.floor(e);this.listPageSize=t,e-t>=.6&&this.listPageSize++}}buttonTapped(e,t=!0){return(...i)=>{t&&this.kernel.setting.get("keyboard.tapticEngine")&&$device.taptic(this.taptic),e(...i)}}navButtons(){return[{symbol:"square.and.arrow.down.on.square",props:{id:this.readClipboardButtonId,hidden:this.isActionPage},tapped:this.buttonTapped((e=>{e.start(),this.readClipboard(!0)?e.done():e.cancel()}))}].map((e=>{const t=new l;return t.setAlign(o.align.right).setSymbol(e.symbol).setEvent("tapped",e.tapped).setProps(e.props??{}),t.definition}))}switchTab(e){this.tabIndex=e,2===e?($(this.listContainerId).hidden=!0,$(this.actionsId).hidden=!1,$(this.readClipboardButtonId).hidden=!0):(this.listSection=e,$(this.actionsId).hidden=!0,$(this.listContainerId).hidden=!1,$(this.readClipboardButtonId).hidden=!1,this.updateList())}getNavBarView(){return{type:"view",views:[{type:"view",layout:$layout.fill,views:[this.tabView(),{type:"label"},...this.navButtons()]}],layout:(e,t)=>{e.top.width.equalTo(t.super),e.height.equalTo(this.navHeight)}}}getBottomBarView(){this.navigationBarItems.setLeftButtons([{symbol:"chevron.backward.circle",tapped:this.buttonTapped((()=>{this.clipboardPrevPage()}))}]).setRightButtons([{symbol:"chevron.forward.circle",tapped:this.buttonTapped((()=>{this.clipboardNextPage()}))}]),this.bottomBar.setTitle(this.listPageNow[this.listSection]+1).setLargeTitleDisplayMode(h.largeTitleDisplayModeNever);const e=this.bottomBar.getNavigationBarView();return e.layout=(e,t)=>{e.bottom.left.right.equalTo(t.super.safeArea),e.top.equalTo(t.prev.bottom)},e}updateList(){const e=this.listPageNow[this.listSection]*this.listPageSize,t=e+this.listPageSize;$(this.listId).data=this.allClips[this.listSection].slice(e,t).map((e=>this.lineData(e))),$(this.bottomBar.id+"-small-title").text=this.listPageNow[this.listSection]+1}clipboardPrevPage(){this.listPageNow[this.listSection]>0&&(this.listPageNow[this.listSection]--,this.updateList())}clipboardNextPage(){const e=Math.ceil(this.allClips[this.listSection].length/this.listPageSize);this.listPageNow[this.listSection]this.listReady(),rowHeight:(e,t)=>{const i=e.object(t).tag.text?this.tagContainerHeight:this.top_bottom;return this.singleLineHeight+this.top_bottom+i},didSelect:this.buttonTapped(((e,t)=>{const i=this.clips[t.row],r=this.kernel.storage.keyToPath(i.text);r&&this.kernel.fileStorage.exists(r.original)?$clipboard.image=this.kernel.fileStorage.readSync(r.original).image:(this.setClipboardText(i.text),this.setCopied(i.uuid,t.row)),$ui.toast($l10n("COPIED"))}))},layout:(e,t)=>{e.top.width.equalTo(t.super),e.bottom.equalTo(t.super).offset(-this.navHeight)}},this.getBottomBarView()],layout:(e,t)=>{e.top.equalTo(this.navHeight),e.bottom.left.right.equalTo(t.super.safeArea)}}}getActionView(){let e=this.todayActions.getActions();0===e.length&&(e=this.todayActions.getAllActions());const t={type:"matrix",props:{id:this.matrixId,bgcolor:$color("clear"),columns:2,itemHeight:this.matrixItemHeight,spacing:this.left_right,data:e.map((e=>this.kernel.actionManager.actionToData(e))),template:{props:{smoothCorners:!0,cornerRadius:10,bgcolor:$color($rgba(255,255,255,.3),$rgba(0,0,0,.3))},views:[{type:"image",props:{id:"color",cornerRadius:this.left_right,smoothCorners:!0},layout:e=>{const t=this.matrixItemHeight-20;e.top.left.inset((this.matrixItemHeight-t)/2),e.size.equalTo($size(t,t))}},{type:"image",props:{id:"icon",tintColor:$color("#ffffff")},layout:(e,t)=>{e.edges.equalTo(t.prev).insets(5)}},{type:"label",props:{id:"name",font:$font(14)},layout:(e,t)=>{e.bottom.top.inset(10),e.left.equalTo(t.prev.prev.right).offset(10),e.right.inset(10)}},{type:"view",props:{id:"info",hidden:!0}}]}},layout:$layout.fill,events:{didSelect:(e,t,i)=>{const a=i.info.info,n=new r({env:s.today,text:"clipboard"===a.type||"uncategorized"===a.type?$clipboard.text:null});this.kernel.actionManager.getActionHandler(a.type,a.dir)(n)}}};return{type:"view",props:{id:this.actionsId,hidden:2!==this.tabIndex},views:[t],layout:(e,t)=>{e.top.equalTo(this.navHeight),e.bottom.left.right.equalTo(t.super.safeArea)}}}getView(){return n.create({props:{titleColor:o.textColor,barColor:o.primaryViewBackgroundColor},views:[{type:"view",views:[this.getNavBarView(),this.getListView(),this.getActionView()],layout:$layout.fill}],events:{appeared:async()=>{if($app.env!==$env.today)return;const e=$timer.schedule({interval:0,handler:()=>{$ui.animate({duration:.3,animation:()=>{$ui.vc.ocValue().$view().$setBackgroundColor($color("clear"))},completion:()=>{e.invalidate()}})}})}}})}}})),$app.strings={en:{ALERT_INFO:"Alert",NONE:"Nothing",DONE:"Done",CLOSE:"Close",FAILED_TO_LOAD_VIEW:"Faild to load view",VIEW_NOT_PROVIDED:"The view is not provided",UNCATEGORIZED:"Uncategorized",SHARE:"Share",CLICK_TO_OPEN_JSBOX:"Click the title to open the main app.",CLIPS:"Clips",CLIPBOARD:"Clipboard",UNIVERSAL_CLIPBOARD:"Universal Clipboard",UNIVERSAL_CLIPBOARD_TIPS:"Universal Clipboard allows you to copy something on your iPhone, and paste it on your Mac–or vice-versa–using iCloud.",CLIPS_STRUCTURE_ERROR:"Clips data structure is abnormal",CLIPBOARD_NO_CHANGE:"Clipboard no change",ADD:"Add",TAG:"Tag",ADD_TAG:"Add Tag",EDIT:"Edit",SEARCH:"Search",SEARCH_HISTORY:"Search History",SEARCH_RESULT:"Search Result",NO_SEARCH_RESULT:"No item found.",PIN:"Pin",COPY:"Copy",COPIED:"Copied",SORT:"Sort",ACTIONS:"Actions",MORE_ACTIONS:"More Actions",PREVIEW:"Preview",MAX_ITEM_LENGTH:"Line Limit",TEXT_MAX_LENGTH:"Display Character Length",AUTO_SAVE:"Auto Save",AUTO_SYNC:"Auto Sync",SYNC_NOW:"Sync Now",UNZIP_FAILED:"Unzip file failed",SYNC_ALERT_INFO:"If it has not been synced locally, the iCloud data will be pulled directly. \\nDo you want to continue?",DELETE_ICLOUD_DATA:"Delete iCloud Data",REBUILD:"Rebuild",REBUILD_DATABASE:"Rebuild Database",REBUILD_DATABASE_ALERT:"Rebuilding the database will lose the order information, do you want to confirm the rebuild?",DELETE_ALL_DATA:"Delete All Data",DELETE_ALL_DATA_ALERT:"Are you sure you want to delete all your data?",DELETE_DATA:"Delete Data",DELETE_TABLE:"Delete all data from ${table}?",SELECT_ALL:"Select All",DESELECT_ALL:"Deselect All",EDITOR:"Editor",CREATE_NEW:"Create New",CREATE_NEW_ACTION:"New Action",CREATE_NEW_TYPE:"New Category",TYPE_ALREADY_EXISTS:"This category already exists",EDIT_DETAILS:"Edit Details",EDIT_SCRIPT:"Edit Script",INFORMATION:"Information",NAME:"Name",ICON:"Icon",TYPE:"Category",DESCRIPTION:"Description",CODE:"Code",TEXT_INSETS:"Text bottom margin",SHOW_LINE_NUMBER:"Show line number",LIGHT_MODE_THEME:"Light Mode Theme",DARK_MODE_THEME:"Dark Mode Theme",SAVE:"Save",SAVE_SUCCESS:"Save success",SAVE_ERROR:"Save failed",DELETE:"Delete",CONFIRM_DELETE_TITLE:"Delete Confirmation",CONFIRM_DELETE_MSG:"Are you sure you want to delete?",DELETE_SUCCESS:"Delete success",DELETE_ERROR:"Delete failed",IMPORT_EXAMPLE_ACTIONS:"Import example actions",REBUILD_ACTION_DATABASE:"Rebuild Action Database",REBUILD_ACTION_DATABASE_ALERT:"Are you sure you want to rebuild?",EXPORT:"Export",IMPORT:"Import",FILE_TYPE_ERROR:"File type does not match",OVERWRITE_ALERT:"This operation will overwrite the current data. Do you want to continue?",KEYBOARD:"Keyboard",KEYBOARD_HEIGHT:"Keyboard Height",BACKGROUND_COLOR:"Background Color",BACKGROUND_COLOR_DARK:"Dark Background Color",BACKGROUND_IMAGE:"Background Image",DELETE_DELAY:"Delete Delay",SWITCH_AFTER_INSERT:"Switch After Insert",JSBOX_TOOLBAR:"JSBox Toolbar",QUICK_START_SCRIPTS:"Quick Start Scripts",SEND:"Send",OPEN_IN_JSBOX:"Open in JSBox",SWITCH_KEYBOARD:"Switch Keyboard",TAPTIC_ENGINE:"Taptic Engine",TAPTIC_ENGINE_FOR_DELETE:"Taptic Engine For Delete",CHECK_UPDATE:"Check Update",UPDATE:"Update",WIDGET:"Widget",RECENT:"Recent",CLICK_ACTION:"Click Action",TODAY_WIDGET:"Today Widget",PREV_PAGE:"Prev",NEXT_PAGE:"Next",DISPLAY_MODE:"Display Mode",CLASSIC:"Classic",MODERN:"Modern",FILE_MANAGEMENT:"File Management","compatibility.rebuildUserAction.alert.title":"We need to rebuild some of the action!","compatibility.rebuildUserAction.alert.message":"If you tap the OK button, the following actions will be rebuilt:","compatibility.rebuildUserAction.alert.message2":"Only the action logic will be changed, and the name and icon will remain as it is."},"zh-Hans":{ALERT_INFO:"提示",NONE:"什么都没有",DONE:"完成",CLOSE:"关闭",FAILED_TO_LOAD_VIEW:"加载视图失败",VIEW_NOT_PROVIDED:"未提供该视图",UNCATEGORIZED:"未分类",SHARE:"分享",CLICK_TO_OPEN_JSBOX:"点击标题打开主应用。",CLIPS:"剪切板",CLIPBOARD:"剪切板",UNIVERSAL_CLIPBOARD:"通用剪贴板",UNIVERSAL_CLIPBOARD_TIPS:"用剪贴板允许您在iPhone上复制某些内容,然后使用iCloud将其粘贴到Mac上(反之亦然)。",CLIPS_STRUCTURE_ERROR:"剪切板数据结构异常",CLIPBOARD_NO_CHANGE:"剪切板无变化",ADD:"添加",TAG:"标签",ADD_TAG:"添加标签",EDIT:"编辑",SEARCH:"搜索",SEARCH_HISTORY:"搜索历史",SEARCH_RESULT:"搜索结果",NO_SEARCH_RESULT:"搜索无结果",PIN:"置顶",COPY:"复制",COPIED:"已复制",SORT:"排序",ACTIONS:"动作",MORE_ACTIONS:"更多动作",PREVIEW:"预览",MAX_ITEM_LENGTH:"行数限制",TEXT_MAX_LENGTH:"显示字符长度",AUTO_SAVE:"自动保存",AUTO_SYNC:"自动同步",SYNC_NOW:"立即同步",UNZIP_FAILED:"解压文件失败",SYNC_ALERT_INFO:"若未在本机进行过同步则会直接拉取 iCloud 数据。\\n是否继续?",DELETE_ICLOUD_DATA:"删除 iCloud 数据",REBUILD:"重建",REBUILD_DATABASE:"重建数据库",REBUILD_DATABASE_ALERT:"重建数据库将会丢失顺序信息,是否确认重建?",DELETE_ALL_DATA:"删除所有数据",DELETE_ALL_DATA_ALERT:"确定要删除所有数据吗?",DELETE_DATA:"删除数据",DELETE_TABLE:"删除${table}的所有数据?",SELECT_ALL:"全选",DESELECT_ALL:"取消全选",EDITOR:"编辑器",CREATE_NEW:"新建",CREATE_NEW_ACTION:"新建动作",CREATE_NEW_TYPE:"新建分类",TYPE_ALREADY_EXISTS:"该类别已经存在",EDIT_DETAILS:"编辑信息",EDIT_SCRIPT:"编辑脚本",INFORMATION:"信息",NAME:"名称",ICON:"图标",TYPE:"分类",DESCRIPTION:"描述",CODE:"代码",TEXT_INSETS:"文本下边距",SHOW_LINE_NUMBER:"显示行号",LIGHT_MODE_THEME:"浅色模式主题",DARK_MODE_THEME:"深色模式主题",SAVE:"保存",SAVE_SUCCESS:"保存成功",SAVE_ERROR:"保存失败",DELETE:"删除",CONFIRM_DELETE_TITLE:"删除前确认",CONFIRM_DELETE_MSG:"确认要删除吗?",DELETE_SUCCESS:"删除成功",DELETE_ERROR:"删除失败",IMPORT_EXAMPLE_ACTIONS:"导入示例动作",REBUILD_ACTION_DATABASE:"重建动作库",REBUILD_ACTION_DATABASE_ALERT:"您确认要重建?",EXPORT:"导出",IMPORT:"导入",FILE_TYPE_ERROR:"文件类型不符",OVERWRITE_ALERT:"该操作将会覆盖当前数据,是否继续?",KEYBOARD:"键盘",KEYBOARD_HEIGHT:"键盘高度",BACKGROUND_COLOR:"背景色",BACKGROUND_COLOR_DARK:"深色模式背景色",BACKGROUND_IMAGE:"背景图片",DELETE_DELAY:"删除延时",SWITCH_AFTER_INSERT:"输入后切换",JSBOX_TOOLBAR:"JSBox 工具栏",QUICK_START_SCRIPTS:"快速启动脚本",SEND:"发送",OPEN_IN_JSBOX:"在 JSBox 中打开",SWITCH_KEYBOARD:"切换键盘",TAPTIC_ENGINE:"触感反馈",TAPTIC_ENGINE_FOR_DELETE:"删除按钮触感反馈",CHECK_UPDATE:"检查更新",UPDATE:"更新",WIDGET:"小组件",RECENT:"最近内容",CLICK_ACTION:"点击事件",TODAY_WIDGET:"通知中心小组件",PREV_PAGE:"上一页",NEXT_PAGE:"下一页",DISPLAY_MODE:"显示模式",CLASSIC:"经典",MODERN:"现代",FILE_MANAGEMENT:"文件管理","compatibility.rebuildUserAction.alert.title":"我们需要重建部分动作!","compatibility.rebuildUserAction.alert.message":"如果您点击 好,以下动作将会被重建:","compatibility.rebuildUserAction.alert.message2":"只有动作逻辑会被更改,名称和图标将维持现状。"}},$app.theme="auto",$app.minSDKVer="2.19.0",$app.minOSVer="14.0.0",$app.idleTimerDisabled=!1,$app.keyboardToolbarEnabled=!0,$app.rotateDisabled=!1,__INFO__={name:"CAIO",version:"1.8.0",author:"ipuppet",module:!1},__README__={"README.md":"# CAIO\r\n\r\n> Clipboard all in one.\r\n> \r\n> A Clipboard tool based on JSBox.\r\n\r\nSupport for home widget and notification center widgets.\r\n\r\n## Build Taio Action\r\n\r\nBuild script depend on [Parcel](https://parceljs.org/).\r\n\r\n```shell\r\nnpm i -g parcel\r\nnpm run build\r\n```\r\n\r\nYou can also use the packaged files directly [dist/CAIO-en.json](./dist/CAIO-en.json).\r\n\r\n## Actions\r\n\r\n> For details on how to write, see `scripts/action/README.md` or the book button in the upper right corner of the `Action` edit page in the app.\r\n\r\n### `Action` data difference in different environments\r\n\r\n- The data processed by the `Action` button at the top of the home page is the currently copied content.\r\n- The data processed by the `Action` menu that pops up by long-pressing the list is the selected content.\r\n- The data processed by the `Action` button in the editor is whatever is being edited.\r\n\r\n\r\n## Today Widget\r\n\r\n> Click to copy, long press to trigger the action.\r\n\r\nPlease try to avoid using the Today Widget when JSBox is running CAIO.","README_CN.md":"# CAIO\r\n\r\n> Clipboard all in one.\r\n> \r\n> A Clipboard tool based on JSBox.\r\n\r\n支持桌面小组件和通知中心小组件\r\n\r\n## 构建 Taio 动作\r\n\r\n构建脚本依赖 [Parcel](https://parceljs.org/)\r\n\r\n```shell\r\nnpm i -g parcel\r\nnpm run build\r\n```\r\n\r\n您也可以直接使用已打包好的文件 [dist/CAIO-zh-Hans.json](./dist/CAIO-zh-Hans.json)\r\n\r\n## Actions\r\n\r\n> 编写方式详见 `scripts/action/README.md` 或应用内 `Action` 编辑页面右上角图书按钮。\r\n\r\n### 不同环境中 `Action` 数据区别\r\n\r\n- 首页顶部 `Action` 按钮处理的数据为当前复制的内容\r\n- 长按列表弹出的 `Action` 菜单处理的数据为被选中的内容\r\n- 编辑器中顶部 `Action` 按钮(闪电图形按钮)处理的数据为正在编辑的所有内容\r\n\r\n\r\n## Today Widget\r\n\r\n> 点击复制,长按触发动作。\r\n\r\n请尽量避免在 JSBox 运行 CAIO 时使用 Today Widget"},__SETTING__=[{items:[{icon:["doc.on.clipboard","#FFCC66"],type:"child",title:"CLIPS",key:"clipboard",children:[{items:[{icon:["link","#FF6633"],title:"UNIVERSAL_CLIPBOARD",type:"switch",key:"clipboard.universal",value:!0},{icon:["cursorarrow.rays","#FF6633"],title:"Tips",type:"script",key:"clipboard.tips.universal",value:"$ui.alert({title:$l10n('UNIVERSAL_CLIPBOARD'),message:$l10n('UNIVERSAL_CLIPBOARD_TIPS')})"}]},{items:[{icon:["text.alignleft","#FFCC66"],title:"MAX_ITEM_LENGTH",type:"number",key:"clipboard.maxItemLength",value:100},{icon:["square.and.arrow.down.on.square","#FF6633"],title:"AUTO_SAVE",type:"switch",key:"clipboard.autoSave",value:!0}]},{items:[{icon:["square.and.arrow.up"],title:"EXPORT",type:"script",key:"clipboard.export",value:"this.method.exportClipboard"},{icon:["square.and.arrow.down","#FFCC33"],title:"IMPORT",type:"script",key:"clipboard.import",value:"this.method.importClipboard"}]},{items:[{icon:["arrow.2.circlepath","red"],title:"REBUILD_DATABASE",type:"script",key:"clipboard.rebuildDatabase",value:"this.method.rebuildDatabase"},{icon:["trash","red"],title:"DELETE_ALL_DATA",type:"script",key:"clipboard.deleteAllData",value:"this.method.deleteAllData"}]}]},{icon:["bolt.circle","#FF6633"],type:"child",title:"ACTIONS",key:"action",children:[{items:[{icon:["bolt.circle","#FF6633"],title:"IMPORT_EXAMPLE_ACTIONS",type:"script",key:"action.importExampleAction",value:"this.method.importExampleAction"}]},{items:[{icon:["square.and.arrow.up"],title:"EXPORT",type:"script",key:"action.export",value:"this.method.exportAction"},{icon:["square.and.arrow.down","#FFCC33"],title:"IMPORT",type:"script",key:"action.import",value:"this.method.importAction"}]},{items:[{icon:["arrow.2.circlepath","red"],title:"REBUILD_ACTION_DATABASE",type:"script",key:"action.rebuildAction",value:"this.method.rebuildAction"}]}]},{icon:["pencil.circle","#CC0099"],type:"child",title:"EDITOR",key:"editor",children:[{title:"CLIPS",items:[{icon:["wand.and.stars","#FF6633"],title:"TEXT_INSETS",type:"number",key:"editor.text.insets",value:300}]},{title:"CODE",items:[{icon:["list.number","#6699CC"],title:"SHOW_LINE_NUMBER",type:"switch",key:"editor.code.lineNumbers",value:!1},{icon:["wand.and.stars","#FF6633"],title:"LIGHT_MODE_THEME",type:"input",key:"editor.code.lightTheme",value:"atom-one-light"},{icon:["wand.and.stars","#FF6633"],title:"DARK_MODE_THEME",type:"input",key:"editor.code.darkTheme",value:"atom-one-dark"}]}]},{icon:["keyboard","#a2a5a6"],type:"child",title:"KEYBOARD",key:"keyboard",children:[{items:[{icon:["rectangle.3.offgrid.fill"],title:"PREVIEW",type:"push",key:"keyboard.previewAndHeight",view:"this.method.previewKeyboard",value:267}]},{items:[{icon:["sun.min","#A569BD"],title:"BACKGROUND_COLOR",type:"color",key:"keyboard.background.color",value:"#D1D3D9"},{icon:["sun.min","#A569BD"],title:"BACKGROUND_COLOR_DARK",type:"color",key:"keyboard.background.color.dark",value:"#313131"},{icon:["photo","#FFCC66"],title:"BACKGROUND_IMAGE",type:"image",key:"keyboard.background.image"}]},{items:[{icon:["globe","#1899c4"],title:"SWITCH_AFTER_INSERT",type:"switch",key:"keyboard.switchAfterInsert",value:!1},{icon:["cursor.rays","#FF8C00"],title:"TAPTIC_ENGINE",type:"switch",key:"keyboard.tapticEngine",value:!0},{icon:["option","#157EFB"],title:"JSBOX_TOOLBAR",type:"switch",key:"keyboard.showJSBoxToolbar",value:!1},{icon:["paperplane"],title:"QUICK_START_SCRIPTS",type:"script",key:"keyboard.setKeyboardQuickStart",value:"this.method.setKeyboardQuickStart"}]},{items:[{icon:["cursor.rays","#FF8C00"],title:"TAPTIC_ENGINE_FOR_DELETE",type:"switch",key:"keyboard.tapticEngineForDelete",value:!0},{icon:["rays","#FFCC33"],title:"DELETE_DELAY",type:"number",key:"keyboard.deleteDelay",value:.05}]}]},{icon:["rectangle.3.offgrid.fill","#1899c4"],type:"child",title:"WIDGET",key:"widget",children:[{items:[{icon:["rectangle.3.offgrid.fill"],title:"PREVIEW",type:"script",key:"previewWidget",value:"this.method.previewWidget"}]},{title:"2x2",items:[{icon:["link"],title:"CLICK_ACTION",type:"menu",key:"widget.2x2.widgetURL",items:["ADD","ACTIONS","CLIPS"],value:2}]}]},{icon:["filemenu.and.selection","#ebcc34"],type:"child",title:"TODAY_WIDGET",key:"todayWidget",children:[{items:[{icon:["rectangle.3.offgrid.fill"],title:"PREVIEW",type:"script",key:"todayWidget.preview",value:"this.method.previewTodayWidget"}]},{items:[{icon:["bolt.circle"],title:"ACTIONS",type:"script",key:"todayWidget.setTodayWidgetActions",value:"this.method.setTodayWidgetActions"}]}]}]},{items:[{icon:["rectangle.topthird.inset.filled","#A569BD"],title:"DISPLAY_MODE",type:"tab",key:"mainUIDisplayMode",items:["CLASSIC","MODERN"],value:0},{icon:["folder.fill","#FF9900"],title:"FILE_MANAGEMENT",type:"script",key:"fileManager",value:"this.method.fileManager"}]},{items:[{icon:["/assets/icon/github.com.jpeg","white"],title:"Github",type:"info",key:"github",value:["ipuppet/CAIO","https://github.com/ipuppet/CAIO"]},{icon:["/assets/icon/telegram.png","white"],title:"Telegram",type:"info",key:"telegram",value:["JSBoxTG","https://t.me/JSBoxTG"]},{icon:["person.fill","#FF9900"],title:"AUTHOR",type:"info",key:"author",value:["ipuppet","https://blog.ultagic.com"]},{icon:["arrow.2.circlepath"],title:"CHECK_UPDATE",type:"script",key:"checkUpdate",value:"this.method.checkUpdate"},{icon:["book.fill","#A569BD"],title:"README",type:"script",key:"readme",value:"this.method.readme"}]}],__ACTIONS__={clipboard:{B23Clean:{"config.json":'{\r\n "icon": "trash",\r\n "color": "#FF0000",\r\n "name": "b23 清除追踪",\r\n "description": "清除 b23.tv 分享链接中的追踪参数,转换为 BV 视频链接。"\r\n}',"main.js":'/**\r\n * @typedef {import("../../action").Action} Action\r\n */\r\nclass MyAction extends Action {\r\n l10n() {\r\n return {\r\n "zh-Hans": {\r\n "b23clean.converting": "正在转换...",\r\n "b23clean.noUrl": "未检测到链接",\r\n "b23clean.noBiliUrl": "未检测到 bilibili 链接",\r\n "b23clean.success": "已转换为 BV 视频链接",\r\n "b23clean.noChange": "无变化",\r\n "b23clean.multipleLinks": "多条链接仅在编辑模式下可用。"\r\n },\r\n en: {\r\n "b23clean.converting": "Converting...",\r\n "b23clean.noUrl": "No link detected",\r\n "b23clean.noBiliUrl": "bilibili link not detected",\r\n "b23clean.success": "Converted to BV video link",\r\n "b23clean.noChange": "No change",\r\n "b23clean.multipleLinks": "Multiple links are only available in edit mode."\r\n }\r\n }\r\n }\r\n\r\n async cleanUrl(b23url) {\r\n if (b23url.indexOf("bilibili.com") === -1 && b23url.indexOf("b23.tv") === -1) {\r\n throw new Error($l10n("b23clean.noBiliUrl"))\r\n }\r\n\r\n let url = b23url\r\n if (b23url.indexOf("b23.tv") >= 0) {\r\n const resp = await $http.get(b23url)\r\n url = resp.response.url\r\n }\r\n\r\n const queryStart = url.indexOf("?")\r\n if (queryStart > -1) {\r\n url = url.substring(0, queryStart - 1)\r\n }\r\n\r\n return url\r\n }\r\n\r\n /**\r\n * 系统会调用 do() 方法\r\n */\r\n async do() {\r\n $ui.toast($l10n("b23clean.converting"), 1000)\r\n\r\n try {\r\n const b23url = this.getUrls()\r\n if (b23url.length === 0) {\r\n throw new Error($l10n("b23clean.noUrl"))\r\n }\r\n\r\n if (b23url.length === 1) {\r\n let url = await this.cleanUrl(b23url[0])\r\n $ui.clearToast()\r\n $ui.alert({\r\n title: $l10n("b23clean.success"),\r\n message: url,\r\n actions: [\r\n { title: $l10n("OK") },\r\n {\r\n title: $l10n("COPY"),\r\n handler: () => {\r\n $clipboard.text = url\r\n $ui.success($l10n("COPIED"))\r\n }\r\n }\r\n ]\r\n })\r\n } else {\r\n if (this.env !== ActionEnv.editor) {\r\n $ui.toast($l10n("b23clean.multipleLinks"))\r\n return\r\n }\r\n let flag = false\r\n for (let i = 0; i < b23url.length; i++) {\r\n try {\r\n const url = b23url[i].trim()\r\n const replacedUrl = await this.cleanUrl(url)\r\n flag = true\r\n\r\n if (url !== replacedUrl) {\r\n const newText = this.text.replace(url, replacedUrl)\r\n this.setContent(newText)\r\n }\r\n } catch {}\r\n }\r\n if (!flag) {\r\n throw new Error($l10n("b23clean.noBiliUrl"))\r\n } else {\r\n $ui.toast($l10n("b23clean.noChange"))\r\n }\r\n }\r\n } catch (error) {\r\n $ui.clearToast()\r\n $delay(0.5, () => $ui.error(error))\r\n }\r\n }\r\n}\r\n',"README.md":"## B23Clean\r\n\r\n清除 b23.tv 分享链接中的追踪参数,转换为 BV 视频链接。"},CleanClipboard:{"config.json":'{\r\n "icon": "trash",\r\n "color": "#FF0000",\r\n "name": "清除剪切板",\r\n "description": "清除剪切板内容"\r\n}',"main.js":'/**\r\n * @typedef {import("../../action").Action} Action\r\n */\r\nclass MyAction extends Action {\r\n l10n() {\r\n return {\r\n "zh-Hans": {\r\n "clipboard.clean.success": "剪切板已清空"\r\n },\r\n en: {\r\n "clipboard.clean.success": "Clipboard is cleaned"\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * 系统会调用 do() 方法\r\n */\r\n do() {\r\n $clipboard.clear()\r\n $ui.success($l10n("clipboard.clean.success"))\r\n }\r\n}\r\n',"README.md":"## CleanClipboard"},DownloadFromUrl:{"config.json":'{\r\n "icon": "square.and.arrow.down",\r\n "color": "#FF0099",\r\n "name": "从链接下载",\r\n "description": "从链接下载内容,如 js 文件内容等"\r\n}',"main.js":'class MyAction extends Action {\r\n async downloadContent(url) {\r\n const response = await $http.get({\r\n url,\r\n showsProgress: true\r\n })\r\n if (response.error) {\r\n $ui.alert(response.error.localizedDescription)\r\n } else {\r\n return response\r\n }\r\n }\r\n\r\n async do() {\r\n const url = this.getUrls()\r\n let response = undefined\r\n if (url.length > 1) {\r\n $ui.menu({\r\n items: url,\r\n handler: async (title, index) => {\r\n response = await this.downloadContent(url[index])\r\n }\r\n })\r\n } else if (url.length === 1) {\r\n response = await this.downloadContent(url[0])\r\n } else {\r\n $ui.warning("未检测到链接")\r\n return\r\n }\r\n $share.sheet([\r\n {\r\n name: response.response.suggestedFilename,\r\n data: response.data\r\n }\r\n ])\r\n return response\r\n }\r\n}\r\n',"README.md":"## DownloadFromUrl\r\n\r\n从链接下载内容,如 js 文件内容等"},GetFromWin:{"config.json":'{\r\n "icon": "square.and.arrow.down",\r\n "color": "#33CC33",\r\n "name": "读取 clipsync",\r\n "description": "通 clipsync 读取 PC 剪切板。"\r\n}',"main.js":'/**\r\n * @typedef {import("../../action").Action} Action\r\n */\r\nclass MyAction extends Action {\r\n async getIp(refresh = false) {\r\n let address = $cache.get("caio.action.clipsync.address")\r\n if (refresh || !address) {\r\n address = await $input.text({\r\n placeholder: "Address",\r\n text: $cache.get("caio.action.clipsync.address")\r\n })\r\n }\r\n\r\n $cache.set("caio.action.clipsync.address", address)\r\n\r\n if (!address.startsWith("http")) {\r\n address = "http://" + address\r\n }\r\n\r\n return address\r\n }\r\n\r\n async do() {\r\n let address = await this.getIp()\r\n\r\n $ui.toast("Loading...", 5)\r\n try {\r\n const resp = await this.request(address + "/api/clip", "GET")\r\n if (resp.data.status) {\r\n $ui.success("success")\r\n $clipboard.text = resp.data.data\r\n }\r\n } catch (error) {\r\n $ui.clearToast()\r\n $ui.alert({\r\n title: "Error",\r\n message: String(error),\r\n actions: [\r\n { title: "OK" },\r\n {\r\n title: "Reset Adress",\r\n handler: () => this.getIp(true)\r\n }\r\n ]\r\n })\r\n }\r\n }\r\n}\r\n',"README.md":"## GetFromWin\r\n\r\n通 clipsync 读取 PC 剪切板。\r\n\r\n服务端:[clipsync](https://github.com/ipuppet/clipsync)\r\n"},OpenUrl:{"config.json":'{\r\n "icon": "link",\r\n "color": "#FF0099",\r\n "name": "打开链接",\r\n "description": "提取文本中的链接并打开"\r\n}',"main.js":'class MyAction extends Action {\r\n l10n() {\r\n return {\r\n "zh-Hans": {\r\n "openLink.nourl": "未检测到链接"\r\n },\r\n en: {\r\n "openLink.nourl": "No link detected"\r\n }\r\n }\r\n }\r\n\r\n openUrl(url) {\r\n $app.openURL(url.trim())\r\n }\r\n\r\n do() {\r\n const url = this.getUrls()\r\n if (url.length > 1) {\r\n $ui.menu({\r\n items: url,\r\n handler: (title, index) => {\r\n this.openUrl(url[index])\r\n }\r\n })\r\n } else if (url.length === 1) {\r\n this.openUrl(url[0])\r\n } else {\r\n $ui.warning($l10n("openLink.nourl"))\r\n }\r\n }\r\n}\r\n',"README.md":"## OpenUrl\r\n\r\n提取文本中的URL并打开"},SendToWin:{"config.json":'{\r\n "icon": "square.and.arrow.up",\r\n "color": "#33CC33",\r\n "name": "推送 clipsync",\r\n "description": "通 clipsync 推送剪切板至 PC。"\r\n}',"main.js":'/**\r\n * @typedef {import("../../action").Action} Action\r\n */\r\nclass MyAction extends Action {\r\n async getIp(refresh = false) {\r\n let address = $cache.get("caio.action.clipsync.address")\r\n if (refresh || !address) {\r\n address = await $input.text({\r\n placeholder: "Address",\r\n text: $cache.get("caio.action.clipsync.address")\r\n })\r\n }\r\n\r\n $cache.set("caio.action.clipsync.address", address)\r\n\r\n if (!address.startsWith("http")) {\r\n address = "http://" + address\r\n }\r\n\r\n return address\r\n }\r\n\r\n async do() {\r\n let address = await this.getIp()\r\n\r\n $ui.toast("Loading...", 5)\r\n try {\r\n const resp = await this.request(address + "/api/clip", "POST", {\r\n data: $clipboard.text\r\n })\r\n if (resp.data.status) {\r\n $ui.success("success")\r\n }\r\n } catch (error) {\r\n $ui.clearToast()\r\n $ui.alert({\r\n title: "Error",\r\n message: String(error),\r\n actions: [\r\n { title: "OK" },\r\n {\r\n title: "Reset Adress",\r\n handler: () => this.getIp(true)\r\n }\r\n ]\r\n })\r\n }\r\n }\r\n}\r\n',"README.md":"## SendToWin\r\n\r\n通 clipsync 推送剪切板至 PC。\r\n\r\n服务端:[clipsync](https://github.com/ipuppet/clipsync)\r\n"},Tokenize:{"config.json":'{\r\n "icon": "pencil.and.ellipsis.rectangle",\r\n "color": "#0099FF",\r\n "name": "分词复制",\r\n "description": "将文本分词处理后复制"\r\n}',"main.js":'class MyAction extends Action {\r\n getView() {\r\n const color = {\r\n background: {\r\n normal: $color("#E7F2FF", "#E7F2FF"),\r\n highlight: $color("##074FF", "#BBDAFF")\r\n },\r\n text: {\r\n normal: $color("##074FF", "##074FF"),\r\n highlight: $color("#FFFFFF", "#ADADAD")\r\n }\r\n }\r\n const fontSize = 16\r\n const edges = 10\r\n return {\r\n type: "matrix",\r\n layout: $layout.fill,\r\n props: {\r\n spacing: edges,\r\n data: this.results.map(item => ({ label: { text: item } })),\r\n template: {\r\n views: [{\r\n type: "label",\r\n props: {\r\n id: "label",\r\n align: $align.center,\r\n cornerRadius: edges,\r\n bgcolor: color.background.normal,\r\n font: $font(fontSize),\r\n textColor: color.text.normal\r\n },\r\n layout: $layout.fill\r\n }]\r\n }\r\n },\r\n events: {\r\n highlighted: () => { },\r\n itemSize: (sender, indexPath) => {\r\n const width = fontSize * this.results[indexPath.item].length + 1\r\n if (this.maxtrixItemHeight === undefined)\r\n this.maxtrixItemHeight = fontSize + edges * 2\r\n return $size(width + edges * 2, this.maxtrixItemHeight)\r\n },\r\n didSelect: (sender, indexPath) => {\r\n const index = this.selected.indexOf(indexPath.item)\r\n const label = sender.cell(indexPath).get("label")\r\n if (index === -1) {\r\n this.selected.push(indexPath.item)\r\n label.bgcolor = color.background.highlight\r\n label.textColor = color.text.highlight\r\n } else {\r\n this.selected.splice(index, 1)\r\n label.bgcolor = color.background.normal\r\n label.textColor = color.text.normal\r\n }\r\n }\r\n }\r\n }\r\n }\r\n /**\r\n * 系统会调用 do() 方法\r\n */\r\n do() {\r\n this.selected = []\r\n this.results = []\r\n $text.tokenize({\r\n text: this.text,\r\n handler: results => {\r\n this.results = results\r\n this.pageSheet({\r\n view: this.getView(),\r\n done: () => {\r\n const result = []\r\n this.selected.sort().forEach(i => {\r\n result.push(this.results[i])\r\n })\r\n if (result.length > 0) {\r\n const text = result.join("")\r\n $clipboard.text = text\r\n $ui.alert({\r\n title: "完成",\r\n message: `已复制内容:${text}`\r\n })\r\n }\r\n }\r\n })\r\n }\r\n })\r\n }\r\n}\r\n',"README.md":"## Tokenize\r\n\r\n> 将文本分词处理后复制"}},editor:{PreviewMarkdown:{"config.json":'{\r\n "icon": "book",\r\n "color": "#9900CC",\r\n "name": "预览Markdown",\r\n "description": "预览Markdown"\r\n}',"main.js":'class MyAction extends Action {\r\n do() {\r\n this.pageSheet({\r\n view: {\r\n type: "markdown",\r\n props: { content: this.text },\r\n layout: $layout.fill\r\n }\r\n })\r\n }\r\n}\r\n',"README.md":"## PreviewMarkdown\r\n\r\n> 预览Markdown"},SelectedText:{"config.json":'{\r\n "icon": "crop",\r\n "color": "#6699CC",\r\n "name": "选中的文本",\r\n "description": "这是个测试 Action, 将在控制台输出当前选中的文本"\r\n}',"main.js":"class MyAction extends Action {\r\n do() {\r\n if (this.selectedRange.length > 0) {\r\n const selectedText = this.text\r\n $ui.alert(selectedText)\r\n }\r\n }\r\n}\r\n","README.md":"## SelectedText\r\n\r\n> 显示选中的文本"}},uncategorized:{DeleteClips:{"config.json":'{\r\n "icon": "trash",\r\n "color": "#FF0000",\r\n "name": "删除所有剪切板",\r\n "description": "删除所有保存的剪切板(不包括置顶)"\r\n}',"main.js":'/**\r\n * @typedef {import("../../action").Action} Action\r\n */\r\n\r\nclass MyAction extends Action {\r\n async do() {\r\n try {\r\n const action = await this.clearAllClips()\r\n if (action) {\r\n $ui.success($l10n("DONE"))\r\n }\r\n } catch (error) {\r\n $ui.error(error)\r\n }\r\n }\r\n}\r\n',"README.md":"## DeleteClips"},DisplayClipboard:{"config.json":'{\r\n "icon": "option",\r\n "color": "#FF6633",\r\n "name": "显示剪切板",\r\n "description": "显示剪切板内容"\r\n}',"main.js":'/**\r\n * @typedef {import("../../action").Action} Action\r\n */\r\n\r\nclass MyAction extends Action {\r\n do() {\r\n this.pageSheet({\r\n view: {\r\n type: "label",\r\n props: {\r\n lines: 0,\r\n text: $clipboard.text,\r\n align: $align.center\r\n },\r\n layout: $layout.fill\r\n }\r\n })\r\n }\r\n}\r\n',"README.md":"## DisplayClipboard"},ExportAllContent:{"config.json":'{\r\n "icon": "square.and.arrow.up",\r\n "color": "#FF3300",\r\n "name": "导出数据",\r\n "description": "导出所有保存的数据"\r\n}',"main.js":'class MyAction extends Action {\r\n do() {\r\n const data = this.getAllClips()\r\n if (data.clips.length > 0 || data.pin.length > 0) {\r\n $share.sheet(JSON.stringify(data, null, 2))\r\n } else {\r\n $ui.alert("无数据")\r\n }\r\n }\r\n}\r\n',"README.md":"## ExportAllContent\r\n\r\n导出所有保存的数据"},Replace:{"config.json":'{\r\n "icon": "square.and.arrow.up",\r\n "color": "#FF3300",\r\n "name": "查找替换",\r\n "description": "查找替换"\r\n}',"main.js":'function HtmlTemplate(html) {\r\n return `\r\n\r\n\r\n \r\n\r\n\r\n${html}\r\n\r\n\r\n`\r\n}\r\n\r\nclass MyAction extends Action {\r\n do() {\r\n $ui.menu({\r\n items: ["忽略大小写", "大小写敏感", "正则表达式"],\r\n handler: async (title, idx) => {\r\n const patternText = await $input.text({\r\n placeholder: "查找内容"\r\n })\r\n const replaceString = await $input.text({\r\n placeholder: "替换内容"\r\n })\r\n let pattern = undefined\r\n if (idx === 0) {\r\n pattern = new RegExp(`(${patternText})+`, "gi")\r\n } else if (idx === 1) {\r\n pattern = new RegExp(`(${patternText})+`, "g")\r\n } else if (idx === 2) {\r\n pattern = new RegExp(patternText, "g")\r\n }\r\n\r\n const matchResultPreview = this.text.replace(pattern, `${replaceString}`)\r\n const matchResult = this.text.replace(pattern, replaceString)\r\n this.pageSheet({\r\n title: "替换预览",\r\n doneText: "替换",\r\n view: {\r\n type: "web",\r\n props: {\r\n html: HtmlTemplate(matchResultPreview)\r\n },\r\n layout: $layout.fill\r\n },\r\n done: () => {\r\n this.setContent(matchResult)\r\n }\r\n })\r\n }\r\n })\r\n // this.setContent("Hello world!")\r\n }\r\n}\r\n',"README.md":"## Replace\r\n\r\n查找替换"}}};var $8Makm=parcelRequire("8Makm");$8Makm.run()})(); \ No newline at end of file +(()=>{var $parcel$global="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},$parcel$modules={},$parcel$inits={},parcelRequire=$parcel$global.parcelRequire94c2;null==parcelRequire&&(parcelRequire=function(e){if(e in $parcel$modules)return $parcel$modules[e].exports;if(e in $parcel$inits){var t=$parcel$inits[e];delete $parcel$inits[e];var i={id:e,exports:{}};return $parcel$modules[e]=i,t.call(i.exports,i,i.exports),i.exports}var r=new Error("Cannot find module '"+e+"'");throw r.code="MODULE_NOT_FOUND",r},parcelRequire.register=function(e,t){$parcel$inits[e]=t},$parcel$global.parcelRequire94c2=parcelRequire),parcelRequire.register("8Makm",(function(e,t){var i=parcelRequire("gxpqj"),r=i.UIKit,s=i.ViewController,a=i.TabBarController,n=i.Kernel,o=i.FileStorage,l=i.Setting,c=i.FileManager,h=parcelRequire("jEwwi"),d=parcelRequire("imdB1"),p=parcelRequire("44eiF"),u=parcelRequire("gYDdO"),g=parcelRequire("9RsVy");const $=new o;class f extends n{constructor(){let e;super(),this.query=$context.query,this.fileStorage=$;try{e=__SETTING__}catch{}this.setting=new l({fileStorage:this.fileStorage,structure:e}),this.setting.loadConfig(),this.storage=new h(this),this.initComponents(),g(this)}addOpenInJsboxButton(){this.useJsboxNav(),this.setNavButtons([{image:$image("assets/icon.png"),handler:()=>this.openInJsbox()}])}initComponents(){this.clips=new d(this),this.actionManager=new p(this),this.fileManager=new c}deleteConfirm(e,t){$ui.alert({title:$l10n("CONFIRM_DELETE_TITLE"),message:e,actions:[{title:$l10n("DELETE"),style:$alertActionType.destructive,handler:()=>{t()}},{title:$l10n("CANCEL")}]})}}class y{static kernel=$app.env!==$env.widget?new f:void 0;static renderMainUI(){const e={clips:{icon:"doc.on.clipboard",title:$l10n("CLIPS")},actions:{icon:"command",title:$l10n("ACTIONS")},setting:{icon:"gear",title:$l10n("SETTING")}};if(this.kernel.setting.setEvent("onSet",(e=>{"mainUIDisplayMode"===e&&$delay(.3,(()=>$addin.restart()))})),0===this.kernel.setting.get("mainUIDisplayMode"))this.kernel.useJsboxNav(),this.kernel.setting.useJsboxNav(),this.kernel.setNavButtons([{symbol:e.setting.icon,title:e.setting.title,handler:()=>{r.push({title:e.setting.title,views:[this.kernel.setting.getListView()]})}},{symbol:e.actions.icon,title:e.actions.title,handler:()=>{this.kernel.actionManager.present()}}]),this.kernel.UIRender(this.kernel.clips.getNavigationView().getPage());else{this.kernel.fileManager.setViewController(new s),this.kernel.tabBarController=new a;const t=this.kernel.clips.getNavigationView();this.kernel.tabBarController.setPages({clips:t.getPage(),actions:this.kernel.actionManager.getPage(),setting:this.kernel.setting.getPage()}).setCells({clips:e.clips,actions:e.actions,setting:e.setting}),this.kernel.UIRender(this.kernel.tabBarController.generateView().definition)}}static renderKeyboardUI(){this.kernel.addOpenInJsboxButton();const e=new(parcelRequire("7eNYp"))(this.kernel);this.kernel.UIRender(e.getView())}static renderTodayUI(){this.kernel.addOpenInJsboxButton();const e=new(parcelRequire("49je6"))(this.kernel);this.kernel.UIRender(e.getView())}static renderUnsupported(){$intents.finish("不支持在此环境中运行"),$ui.render({views:[{type:"label",props:{text:"不支持在此环境中运行",align:$align.center},layout:$layout.fill}]})}}class b{static widgetInstance(e,...t){if($file.exists(`/scripts/widget/${e}.js`)){const{Widget:i}=require(`./widget/${e}.js`);return new i(...t)}return!1}static renderError(){$widget.setTimeline({render:()=>({type:"text",props:{text:"Invalid argument"}})})}static renderClipboard(){const e=new l;e.loadConfig().setReadonly();b.widgetInstance("Clipboard",e,new h({fileStorage:$})).render()}static render(e=$widget.inputValue){"Clipboard"===(e=e??"Clipboard")?b.renderClipboard():b.renderError()}}e.exports={Widget:b,run:()=>{u(y.kernel),$app.env===$env.app||$app.env===$env.action?y.renderMainUI():$app.env===$env.keyboard?y.renderKeyboardUI():$app.env===$env.widget?b.render():$app.env===$env.today?y.renderTodayUI():y.renderUnsupported()}}})),parcelRequire.register("gxpqj",(function(module,exports){var $parcel$global="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==$parcel$global?$parcel$global:{},$parcel$modules={},$parcel$inits={},parcelRequire=$parcel$global.parcelRequire94c2;null==parcelRequire&&(parcelRequire=function(e){if(e in $parcel$modules)return $parcel$modules[e].exports;if(e in $parcel$inits){var t=$parcel$inits[e];delete $parcel$inits[e];var i={id:e,exports:{}};return $parcel$modules[e]=i,t.call(i.exports,i,i.exports),i.exports}var r=new Error("Cannot find module '"+e+"'");throw r.code="MODULE_NOT_FOUND",r},parcelRequire.register=function(e,t){$parcel$inits[e]=t},$parcel$global.parcelRequire94c2=parcelRequire),parcelRequire.register("45Ip7",(function(e,t){class i{static#e=$objc("UIApplication").$sharedApplication();static#t=$objc("UINotificationFeedbackGenerator").$new();static feedbackSuccess(){i.#t.$notificationOccurred(0)}static feedbackError(){i.#t.$notificationOccurred(2)}static align={left:0,right:1,top:2,bottom:3};static textColor=$color("primaryText");static linkColor=$color("systemLink");static primaryViewBackgroundColor=$color("primarySurface");static scrollViewBackgroundColor=$color("insetGroupedBackground");static scrollViewList=["list","matrix"];static isLargeScreen=$device.isIpad||$device.isIpadPro;static get windowSize(){return $objc("UIWindow").$keyWindow().jsValue().size}static NavigationBarNormalHeight=$objc("UINavigationController").invoke("alloc.init").$navigationBar().jsValue().frame.height;static NavigationBarLargeTitleHeight=$objc("UITabBarController").invoke("alloc.init").$tabBar().jsValue().frame.height+i.NavigationBarNormalHeight;static get isSplitScreenMode(){return i.isLargeScreen&&$device.info.screen.width!==i.windowSize.width}static get topSafeAreaInsets(){return i.#e?.$keyWindow()?.$safeAreaInsets()?.top??0}static get bottomSafeAreaInsets(){return i.#e?.$keyWindow()?.$safeAreaInsets()?.bottom??0}static get statusBarOrientation(){return i.#e.$statusBarOrientation()}static get consoleBarHeight(){if($app.isDebugging){let e=i.#e.$statusBarFrame().height+26;return $device.isIphoneX&&(e+=30),e}return 0}static get isHorizontal(){return 3===i.statusBarOrientation||4===i.statusBarOrientation}static loading(){const e=$ui.create(i.blurBox({cornerRadius:15},[{type:"spinner",props:{loading:!0,style:0},layout:(e,t)=>{e.size.equalTo(t.prev),e.center.equalTo(t.super)}}]));return{start:()=>{$ui.controller.view.insertAtIndex(e,0),e.layout(((e,t)=>{e.center.equalTo(t.super);const r=Math.min(.6*Math.min(i.windowSize.width,i.windowSize.height),260);e.size.equalTo($size(r,r))})),e.moveToFront()},end:()=>{e.remove()}}}static defaultBackgroundColor(e){return i.scrollViewList.indexOf(e)>-1?i.scrollViewBackgroundColor:i.primaryViewBackgroundColor}static separatorLine(e={},t=i.align.bottom){return{type:"canvas",props:e,layout:(e,r)=>{void 0===r.prev?e.top.equalTo(r.super):t===i.align.bottom?e.top.equalTo(r.prev.bottom):e.top.equalTo(r.prev.top),e.height.equalTo(1/$device.info.screen.scale),e.left.right.inset(0)},events:{draw:(t,i)=>{i.strokeColor=e.bgcolor??$color("separatorColor"),i.setLineWidth(1),i.moveToPoint(0,0),i.addLineToPoint(t.frame.width,0),i.strokePath()}}}}static blurBox(e={},t=[],i=$layout.fill){return{type:"blur",props:Object.assign({style:$blurStyle.thinMaterial},e),views:t,layout:i}}static getContentSize(e,t="A",r=i.windowSize.width,s){const a={text:t,width:r,font:e};return void 0!==s&&(a.lineSpacing=s),$text.sizeThatFits(a)}static push({views:e,statusBarStyle:t=0,title:i="",navButtons:r=[{title:""}],bgcolor:s=e[0]?.props?.bgcolor??"primarySurface",disappeared:a}={}){$ui.push({props:{statusBarStyle:t,navButtons:r,title:i,bgcolor:"string"==typeof s?$color(s):s},events:{disappeared:()=>{void 0!==a&&a()}},views:[{type:"view",views:e,layout:(e,t)=>{e.top.equalTo(t.super.safeArea),e.bottom.equalTo(t.super),e.left.right.equalTo(t.super.safeArea)}}]})}}e.exports={UIKit:i}})),parcelRequire.register("7D8Kb",(function(module,exports){var $fYz8N=parcelRequire("fYz8N"),$58e2f5443faff7c0$require$Controller=$fYz8N.Controller,$8aDdQ=parcelRequire("8aDdQ"),$58e2f5443faff7c0$require$FileStorageFileNotFoundError=$8aDdQ.FileStorageFileNotFoundError,$58e2f5443faff7c0$require$FileStorage=$8aDdQ.FileStorage,$cgaQ6=parcelRequire("cgaQ6"),$58e2f5443faff7c0$require$Kernel=$cgaQ6.Kernel,$45Ip7=parcelRequire("45Ip7"),$58e2f5443faff7c0$require$UIKit=$45Ip7.UIKit,$aXWmO=parcelRequire("aXWmO"),$58e2f5443faff7c0$require$Sheet=$aXWmO.Sheet,$12xzj=parcelRequire("12xzj"),$58e2f5443faff7c0$require$NavigationView=$12xzj.NavigationView,$dcStC=parcelRequire("dcStC"),$58e2f5443faff7c0$require$NavigationBar=$dcStC.NavigationBar,$gMc1q=parcelRequire("gMc1q"),$58e2f5443faff7c0$require$ViewController=$gMc1q.ViewController;class SettingLoadConfigError extends Error{constructor(){super("Call loadConfig() first."),this.name="SettingLoadConfigError"}}class SettingReadonlyError extends Error{constructor(){super("Attempted to assign to readonly property."),this.name="SettingReadonlyError"}}class Setting extends $58e2f5443faff7c0$require$Controller{name;setting={};userData;fileStorage;imagePath;viewController=new $58e2f5443faff7c0$require$ViewController;method={readme:()=>{const e=(()=>{const e=$device.info?.language?.startsWith("zh")?"README_CN.md":"README.md";try{return __README__[e]??__README__["README.md"]}catch{return $file.read(e)?.string??$file.read("README.md")?.string}})();(new $58e2f5443faff7c0$require$Sheet).setView({type:"markdown",props:{content:e},layout:(e,t)=>{e.size.equalTo(t.super)}}).init().present()}};rowHeight=50;edgeOffset=10;iconSize=30;#i={};#r=!1;#s=!1;#a;constructor(e={}){super(),"function"==typeof e.set&&"function"==typeof e.get?(this.set=e.set,this.get=e.get,this.userData=e.userData):(this.fileStorage=e.fileStorage??new $58e2f5443faff7c0$require$FileStorage,this.dataFile=e.dataFile??"setting.json"),e.structure?this.setStructure(e.structure):this.setStructurePath(e.structurePath??"setting.json"),this.isUseJsboxNav=e.isUseJsboxNav??!1,this.imagePath=(e.name??"default")+".image/",this.setName(e.name??$text.uuid),this.loadL10n()}useJsboxNav(){return this.isUseJsboxNav=!0,this}#n(){if(!this.#s)throw new SettingLoadConfigError}loadConfig(){const e=["script","info"],t=this.userData??this.fileStorage.readAsJSON(this.dataFile,{});return this.setting=function i(r){const s={};for(let a of r)for(let r of a.items)if("child"===r.type){const e=i(r.children);Object.assign(s,e)}else-1===e.indexOf(r.type)?s[r.key]=r.key in t?t[r.key]:r.value:s[r.key]=r.value;return s}(this.structure),this.#s=!0,this}hasSectionTitle(e){return this.#n(),!!e[0]?.title}loadL10n(){$58e2f5443faff7c0$require$Kernel.l10n("zh-Hans",{OK:"好",DONE:"完成",CANCEL:"取消",CLEAR:"清除",BACK:"返回",ERROR:"发生错误",SUCCESS:"成功",LOADING:"加载中",INVALID_VALUE:"非法参数",CONFIRM_CHANGES:"数据已变化,确认修改?",SETTING:"设置",GENERAL:"一般",ADVANCED:"高级",TIPS:"小贴士",COLOR:"颜色",COPY:"复制",COPIED:"复制成功",JSBOX_ICON:"JSBox 内置图标",SF_SYMBOLS:"SF Symbols",IMAGE_BASE64:"图片 / base64",PREVIEW:"预览",SELECT_IMAGE:"选择图片",CLEAR_IMAGE:"清除图片",NO_IMAGE:"无图片",ABOUT:"关于",VERSION:"Version",AUTHOR:"作者",AT_BOTTOM:"已经到底啦~"},!1),$58e2f5443faff7c0$require$Kernel.l10n("en",{OK:"OK",DONE:"Done",CANCEL:"Cancel",CLEAR:"Clear",BACK:"Back",ERROR:"Error",SUCCESS:"Success",LOADING:"Loading",INVALID_VALUE:"Invalid value",CONFIRM_CHANGES:"The data has changed, confirm the modification?",SETTING:"Setting",GENERAL:"General",ADVANCED:"Advanced",TIPS:"Tips",COLOR:"Color",COPY:"Copy",COPIED:"Copide",JSBOX_ICON:"JSBox in app icon",SF_SYMBOLS:"SF Symbols",IMAGE_BASE64:"Image / base64",PREVIEW:"Preview",SELECT_IMAGE:"Select Image",CLEAR_IMAGE:"Clear Image",NO_IMAGE:"No Image",ABOUT:"About",VERSION:"Version",AUTHOR:"Author",AT_BOTTOM:"It's the end~"},!1)}setUserData(e){this.userData=e}setStructure(e){return this.structure=e,this}setStructurePath(e){return this.structure||this.setStructure($58e2f5443faff7c0$require$FileStorage.readFromRootAsJSON(e)),this}setName(e){return this.name=e,this}setFooter(e){return this.#a=e,this}set footer(e){this.#a=e}get footer(){if(void 0===this.#a){let e=$58e2f5443faff7c0$require$FileStorage.readFromRootAsJSON("config.json",{}).info??{};if(!e.version||!e.author)try{e=__INFO__}catch{}this.#a={},e.version&&e.author&&(this.#a={type:"view",props:{height:70},views:[{type:"label",props:{font:$font(14),text:`${$l10n("VERSION")} ${e.version} ♥ ${e.author}`,textColor:$color({light:"#C0C0C0",dark:"#545454"}),align:$align.center},layout:e=>{e.left.right.inset(0),e.top.inset(10)}}]})}return this.#a}setReadonly(){return this.#r=!0,this}set(e,t){if(this.#r)throw new SettingReadonlyError;return this.#n(),this.setting[e]=t,this.fileStorage.write(this.dataFile,$data({string:JSON.stringify(this.setting)})),this.callEvent("onSet",e,t),!0}get(e,t=null){return this.#n(),Object.prototype.hasOwnProperty.call(this.setting,e)?this.setting[e]:t}getColor(e){return"string"==typeof e?$color(e):$rgba(e.red,e.green,e.blue,e.alpha)}getImagePath(e,t=!1){let i=$text.MD5(e)+".jpg";return t&&(i="compress."+i),this.imagePath+i}getImage(e,t=!1){try{return this.fileStorage.readSync(this.getImagePath(e,t)).image}catch(e){if(e instanceof $58e2f5443faff7c0$require$FileStorageFileNotFoundError)return null;throw e}}getId(e){return`setting-${this.name}-${e}`}#o(e){$(e).bgcolor=$color("systemFill")}#l(e,t=.3){0===t?$(e).bgcolor=$color("clear"):$ui.animate({duration:t,animation:()=>{$(e).bgcolor=$color("clear")}})}#c(e,t,i=!1,r=0){if(t=Object.assign(t,{touchesBegan:()=>{this.#o(e),this.#i[e]=$delay(1,(()=>this.#l(e,0)))},touchesMoved:()=>{this.#i[e]?.cancel(),this.#l(e,0)}}),i){const i=t.tapped;t.tapped=()=>{this.#o(e),setTimeout((()=>this.#l(e)),1e3*r),"function"==typeof i&&i()}}return t}createLineLabel(e,t){return t[1]||(t[1]="#00CC00"),"object"!=typeof t[1]&&(t[1]=[t[1],t[1]]),"object"!=typeof t[0]&&(t[0]=[t[0],t[0]]),{type:"view",views:[{type:"view",props:{bgcolor:$color(t[1][0],t[1][1]),cornerRadius:5,smoothCorners:!0},views:[{type:"image",props:{tintColor:$color("white"),image:$image(t[0][0],t[0][1])},layout:(e,t)=>{e.center.equalTo(t.super),e.size.equalTo(20)}}],layout:(e,t)=>{e.centerY.equalTo(t.super),e.size.equalTo(this.iconSize),e.left.inset(this.edgeOffset)}},{type:"label",props:{text:e,lines:1,textColor:this.textColor,align:$align.left},layout:(e,t)=>{e.centerY.equalTo(t.super),e.height.equalTo(t.super),e.left.equalTo(t.prev.right).offset(this.edgeOffset),e.width.greaterThanOrEqualTo(10)}}],layout:(e,t)=>{e.height.centerY.equalTo(t.super),e.left.inset(0)}}}createInfo(e,t,i){const r=Array.isArray(i),s=r?i[0]:i,a=r?i[1]:i;return{type:"view",props:{selectable:!0},views:[this.createLineLabel(t,e),{type:"label",props:{text:s,align:$align.right,textColor:$color("darkGray")},layout:(e,t)=>{e.centerY.equalTo(t.prev),e.right.inset(this.edgeOffset),e.width.equalTo(180)}},{type:"view",events:{tapped:()=>{$ui.alert({title:t,message:a,actions:[{title:$l10n("COPY"),handler:()=>{$clipboard.text=a,$ui.toast($l10n("COPIED"))}},{title:$l10n("OK")}]})}},layout:(e,t)=>{e.right.inset(0),e.size.equalTo(t.super)}}],layout:$layout.fill}}createSwitch(e,t,i){return{type:"view",props:{id:this.getId(e),selectable:!0},views:[this.createLineLabel(i,t),{type:"switch",props:{on:this.get(e),onColor:$color("#00CC00")},events:{changed:t=>{try{this.set(e,t.on)}catch(e){throw t.on=!t.on,e}}},layout:(e,t)=>{e.centerY.equalTo(t.prev),e.right.inset(this.edgeOffset)}}],layout:$layout.fill}}createString(e,t,i){return{type:"view",props:{id:this.getId(e),selectable:!0},views:[this.createLineLabel(i,t),{type:"button",props:{symbol:"square.and.pencil",bgcolor:$color("clear"),tintColor:$color("primaryText")},events:{tapped:t=>{const i=$ui.popover({sourceView:t,sourceRect:t.bounds,directions:$popoverDirection.down,size:$size(320,150),views:[{type:"text",props:{id:`${this.name}-string-${e}`,align:$align.left,text:this.get(e)},layout:e=>{e.left.right.inset(10),e.top.inset(20),e.height.equalTo(90)}},{type:"button",props:{symbol:"checkmark",bgcolor:$color("clear"),titleEdgeInsets:10,contentEdgeInsets:0},layout:e=>{e.right.inset(10),e.bottom.inset(25),e.size.equalTo(30)},events:{tapped:()=>{this.set(e,$(`${this.name}-string-${e}`).text),i.dismiss()}}}]})}},layout:(e,t)=>{e.centerY.equalTo(t.prev),e.right.inset(0),e.size.equalTo(50)}}],layout:$layout.fill}}createStepper(e,t,i,r,s){const a=this.getId(e),n=`${a}-label`;return{type:"view",props:{id:a,selectable:!0},views:[this.createLineLabel(i,t),{type:"label",props:{id:n,text:this.get(e),textColor:this.textColor,align:$align.left},layout:(e,t)=>{e.height.equalTo(t.super),e.right.inset(120)}},{type:"stepper",props:{min:r,max:s,value:this.get(e)},events:{changed:t=>{$(n).text=t.value;try{this.set(e,t.value)}catch(t){throw $(n).text=this.get(e),t}}},layout:(e,t)=>{e.centerY.equalTo(t.prev),e.right.inset(this.edgeOffset)}}],layout:$layout.fill}}createScript(key,icon,title,script){const id=this.getId(key),buttonId=`${id}-button`,actionStart=()=>{$(buttonId).alpha=0,$(`${buttonId}-spinner`).alpha=1,this.#o(id)},actionCancel=()=>{$(buttonId).alpha=1,$(`${buttonId}-spinner`).alpha=0,this.#l(id)},actionDone=(e=!0,t=$l10n("ERROR"))=>{$(`${buttonId}-spinner`).alpha=0,this.#l(id);const i=$(buttonId);if(!e)return $ui.toast(t),void(i.alpha=1);i.symbol="checkmark",$ui.animate({duration:.6,animation:()=>{i.alpha=1},completion:()=>{setTimeout((()=>{$ui.animate({duration:.4,animation:()=>{i.alpha=0},completion:()=>{i.symbol="chevron.right",$ui.animate({duration:.4,animation:()=>{i.alpha=1},completion:()=>{i.alpha=1}})}})}),600)}})};return{type:"view",props:{id:id},views:[this.createLineLabel(title,icon),{type:"view",views:[{type:"image",props:{id:buttonId,symbol:"chevron.right",tintColor:$color("secondaryText")},layout:(e,t)=>{e.centerY.equalTo(t.super),e.right.inset(0),e.size.equalTo(15)}},{type:"spinner",props:{id:`${buttonId}-spinner`,loading:!0,alpha:0},layout:(e,t)=>{e.size.equalTo(t.prev),e.left.top.equalTo(t.prev)}}],layout:(e,t)=>{e.right.inset(this.edgeOffset),e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],events:this.#c(id,{tapped:()=>{const animate={actionStart:actionStart,actionCancel:actionCancel,actionDone:actionDone,touchHighlightStart:()=>this.#o(id),touchHighlightEnd:()=>this.#l(id)};"function"==typeof script?script(animate):script.startsWith("this")?eval(`(()=>{return ${script}(animate)})()`):eval(script)}}),layout:$layout.fill}}createTab(key,icon,title,items,values){"string"==typeof items?items=eval(`(()=>{return ${items}()})()`):"function"==typeof items&&(items=items()),"string"==typeof values?values=eval(`(()=>{return ${values}()})()`):"function"==typeof values&&(values=values());const id=this.getId(key),isCustomizeValues=items?.length>0&&values?.length===items?.length;return{type:"view",props:{id:id,selectable:!0},views:[this.createLineLabel(title,icon),{type:"tab",props:{items:items??[],index:isCustomizeValues?values.indexOf(this.get(key)):this.get(key),dynamicWidth:!0},layout:(e,t)=>{e.right.inset(this.edgeOffset),e.centerY.equalTo(t.prev)},events:{changed:e=>{isCustomizeValues?this.set(key,values[e.index]):this.set(key,e.index)}}}],layout:$layout.fill}}createMenu(key,icon,title,items,values){const id=this.getId(key),labelId=`${id}-label`,getItems=()=>{let res;return res="string"==typeof items?eval(`(()=>{return ${items}()})()`):"function"==typeof items?items():items??[],res},getValues=()=>{let res;return res="string"==typeof values?eval(`(()=>{return ${values}()})()`):"function"==typeof values?values():values,res},tmpItems=getItems(),tmpValues=getValues(),isCustomizeValues=tmpItems?.length>0&&tmpValues?.length===tmpItems?.length;return{type:"view",props:{id:id,selectable:!0},views:[this.createLineLabel(title,icon),{type:"view",views:[{type:"label",props:{text:isCustomizeValues?tmpItems[tmpValues.indexOf(this.get(key))]:tmpItems[this.get(key)],color:$color("secondaryText"),id:labelId},layout:(e,t)=>{e.right.inset(0),e.height.equalTo(t.super)}}],layout:(e,t)=>{e.right.inset(this.edgeOffset),e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],events:{tapped:()=>{const e=getItems(),t=getValues();$ui.menu({items:e,handler:(e,i)=>{isCustomizeValues?this.set(key,t[i]):this.set(key,i),$(labelId).text=$l10n(e)}})}},layout:$layout.fill}}createColor(e,t,i){const r=this.getId(e),s=`${r}-color`;return{type:"view",props:{id:r,selectable:!0},views:[this.createLineLabel(i,t),{type:"view",views:[{type:"view",props:{id:s,bgcolor:this.getColor(this.get(e)),circular:!0,borderWidth:1,borderColor:$color("#e3e3e3")},layout:(e,t)=>{e.centerY.equalTo(t.super),e.right.inset(this.edgeOffset),e.size.equalTo(20)}},{type:"view",events:{tapped:async()=>{const t=await $picker.color({color:this.getColor(this.get(e))});this.set(e,t.components),$(s).bgcolor=$rgba(t.components.red,t.components.green,t.components.blue,t.components.alpha)}},layout:(e,t)=>{e.right.inset(0),e.height.width.equalTo(t.super.height)}}],layout:(e,t)=>{e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],layout:$layout.fill}}createDate(e,t,i,r=2){const s=this.getId(e),a=e=>{let t="";switch("number"==typeof e&&(e=new Date(e)),r){case 0:t=e.toLocaleTimeString();break;case 1:t=e.toLocaleDateString();break;case 2:t=e.toLocaleString()}return t};return{type:"view",props:{id:s,selectable:!0},views:[this.createLineLabel(i,t),{type:"view",views:[{type:"label",props:{id:`${s}-label`,color:$color("secondaryText"),text:this.get(e)?a(this.get(e)):"None"},layout:(e,t)=>{e.right.inset(0),e.height.equalTo(t.super)}}],events:{tapped:async()=>{const t=this.get(e),i=await $picker.date({props:{mode:r,date:t||Date.now()}});this.set(e,i.getTime()),$(`${s}-label`).text=a(i)}},layout:(e,t)=>{e.right.inset(this.edgeOffset),e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],layout:$layout.fill}}createNumber(e,t,i){return this.createInput(e,t,i,!1,$kbType.decimal,(t=>""!==t&&/^[0-9]+.?[0-9]*$/.test(t)?this.set(e,Number(t)):($ui.toast($l10n("INVALID_VALUE")),!1)))}createInput(e,t,i,r=!1,s=$kbType.default,a){void 0===a&&(a=t=>this.set(e,t));const n=this.getId(e),o=n+"-input";return{type:"view",props:{id:n,selectable:!0},views:[this.createLineLabel(i,t),{type:"input",props:{id:o,type:s,align:$align.right,bgcolor:$color("clear"),textColor:$color("secondaryText"),text:this.get(e),font:$font(16),secure:r,accessoryView:$58e2f5443faff7c0$require$UIKit.blurBox({height:44},[$58e2f5443faff7c0$require$UIKit.separatorLine({},$58e2f5443faff7c0$require$UIKit.align.top),{type:"button",props:{title:$l10n("DONE"),bgcolor:$color("clear"),titleColor:$color("primaryText")},layout:(e,t)=>{e.right.inset(this.edgeOffset),e.centerY.equalTo(t.super)},events:{tapped:()=>{$(o).blur()}}},{type:"button",props:{title:$l10n("CANCEL"),bgcolor:$color("clear"),titleColor:$color("primaryText")},layout:(e,t)=>{e.left.inset(this.edgeOffset),e.centerY.equalTo(t.super)},events:{tapped:()=>{const t=$(o),i=this.get(e,"");t.text!==i&&(t.text=i),t.blur()}}}])},layout:(t,i)=>{t.left.equalTo(i.prev.get("label").right).offset(this.edgeOffset),t.right.inset(this.edgeOffset);const r=$58e2f5443faff7c0$require$UIKit.getContentSize($font(16),this.get(e)).width;t.width.greaterThanOrEqualTo(r+30),t.height.equalTo(i.super)},events:{didBeginEditing:e=>{e.secure=!1,$app.autoKeyboardEnabled||($app.autoKeyboardEnabled=!0)},returned:e=>{e.blur()},didEndEditing:async t=>{const i=this.get(e,"");a(t.text)||(t.text=i),r&&(t.secure=r)}}}],layout:$layout.fill}}createIcon(e,t,i,r="#000000"){const s=this.getId(e),a=`${s}-image`;return{type:"view",props:{id:s,selectable:!0},views:[this.createLineLabel(i,t),{type:"view",views:[{type:"image",props:{cornerRadius:8,bgcolor:"string"==typeof r?$color(r):r,smoothCorners:!0},layout:(e,t)=>{e.right.inset(this.edgeOffset),e.centerY.equalTo(t.super),e.size.equalTo($size(30,30))}},{type:"image",props:{id:a,image:$image(this.get(e)),icon:$icon(this.get(e).slice(5,this.get(e).indexOf(".")),$color("#ffffff")),tintColor:$color("#ffffff")},layout:(e,t)=>{e.right.equalTo(t.prev).offset(-5),e.centerY.equalTo(t.super),e.size.equalTo($size(20,20))}}],events:{tapped:()=>{$ui.menu({items:[$l10n("JSBOX_ICON"),$l10n("SF_SYMBOLS"),$l10n("IMAGE_BASE64")],handler:async(t,i)=>{if(0===i){const t=await $ui.selectIcon();this.set(e,t),$(a).icon=$icon(t.slice(5,t.indexOf(".")),$color("#ffffff"))}else 1!==i&&2!==i||$input.text({text:"",placeholder:t,handler:t=>{""!==t?(this.set(e,t),1===i?$(a).symbol=t:$(a).image=$image(t)):$ui.toast($l10n("INVALID_VALUE"))}})}})}},layout:(e,t)=>{e.right.inset(0),e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],layout:$layout.fill}}createPush(key,icon,title,view,tapped){const id=this.getId(key);return{type:"view",layout:$layout.fill,props:{id:id,selectable:!0},views:[this.createLineLabel(title,icon),{type:"image",props:{symbol:"chevron.right",tintColor:$color("secondaryText")},layout:(e,t)=>{e.centerY.equalTo(t.super),e.right.inset(this.edgeOffset),e.size.equalTo(15)}}],events:{tapped:()=>{const push=view=>{if("string"==typeof view&&view.startsWith("this.method")?view=eval(`(()=>{return ${view}()})()`):"function"==typeof view&&(view=view()),this.isUseJsboxNav)$58e2f5443faff7c0$require$UIKit.push({title:title,props:view.props??{},views:[view]});else{const e=new $58e2f5443faff7c0$require$NavigationView;e.setView(view).navigationBarTitle(title),e.navigationBarItems.addPopButton(),e.navigationBar.setLargeTitleDisplayMode($58e2f5443faff7c0$require$NavigationBar.largeTitleDisplayModeNever),this.hasSectionTitle(view)&&e.navigationBar.setContentViewHeightOffset(-10),this.viewController.push(e)}};"function"==typeof tapped?tapped(push):push(view)}}}}createChild(e,t,i,r){return this.createPush(e,t,i,void 0,(e=>{this.events?.onChildPush?this.callEvent("onChildPush",this.getListView(r,{}),i):e(this.getListView(r,{}))}))}createImage(e,t,i){const r=this.getId(e),s=`${r}-image`,a=$image("questionmark.square.dashed");return{type:"view",props:{id:r,selectable:!0},views:[this.createLineLabel(i,t),{type:"view",views:[{type:"image",props:{id:s,image:this.getImage(e,!0)??a},layout:(e,t)=>{e.right.inset(this.edgeOffset),e.centerY.equalTo(t.super),e.size.equalTo($size(30,30))}}],events:{tapped:()=>{this.#o(r),$ui.menu({items:[$l10n("PREVIEW"),$l10n("SELECT_IMAGE"),$l10n("CLEAR_IMAGE")],handler:(t,i)=>{if(0===i){const t=this.getImage(e);t?$quicklook.open({image:t}):$ui.toast($l10n("NO_IMAGE"))}else 1===i?$photo.pick({format:"data"}).then((t=>{if($ui.toast($l10n("LOADING")),!t.status||!t.data)return void("canceled"!==t?.error?.description&&$ui.toast($l10n("ERROR")));const i=$58e2f5443faff7c0$require$Kernel.compressImage(t.data.image);this.fileStorage.write(this.getImagePath(e,!0),i.jpg(.8)),this.fileStorage.write(this.getImagePath(e),t.data),$(s).image=i,$ui.success($l10n("SUCCESS"))})):2===i&&(this.fileStorage.delete(this.getImagePath(e,!0)),this.fileStorage.delete(this.getImagePath(e)),$(s).image=a,$ui.success($l10n("SUCCESS")))},finished:()=>{this.#l(r)}})}},layout:(e,t)=>{e.right.inset(0),e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],layout:$layout.fill}}#h(e){const t=[];for(let i of e){const e=[];for(let t of i.items){const i=this.get(t.key);let r=null;switch(t.icon||(t.icon=["square.grid.2x2.fill","#00CC00"]),"object"==typeof t.items&&(t.items=t.items.map((e=>$l10n(e)))),t.title=$l10n(t.title),t.type){case"switch":r=this.createSwitch(t.key,t.icon,t.title);break;case"stepper":r=this.createStepper(t.key,t.icon,t.title,t.min??1,t.max??12);break;case"string":r=this.createString(t.key,t.icon,t.title);break;case"info":r=this.createInfo(t.icon,t.title,i);break;case"script":r=this.createScript(t.key,t.icon,t.title,i);break;case"tab":r=this.createTab(t.key,t.icon,t.title,t.items,t.values);break;case"menu":r=this.createMenu(t.key,t.icon,t.title,t.items,t.values);break;case"color":r=this.createColor(t.key,t.icon,t.title);break;case"date":r=this.createDate(t.key,t.icon,t.title,t.mode);break;case"number":r=this.createNumber(t.key,t.icon,t.title);break;case"input":r=this.createInput(t.key,t.icon,t.title,t.secure);break;case"icon":r=this.createIcon(t.key,t.icon,t.title,t.bgcolor);break;case"push":r=this.createPush(t.key,t.icon,t.title,t.view);break;case"child":r=this.createChild(t.key,t.icon,t.title,t.children);break;case"image":r=this.createImage(t.key,t.icon,t.title);break;default:continue}e.push(r)}t.push({title:$l10n(i.title??""),rows:e})}return t}getListView(e,t=this.footer){return{type:"list",props:{id:this.name,style:2,separatorInset:$insets(0,this.iconSize+2*this.edgeOffset,0,this.edgeOffset),bgcolor:$58e2f5443faff7c0$require$UIKit.scrollViewBackgroundColor,footer:t,data:this.#h(e??this.structure)},layout:$layout.fill,events:{rowHeight:(e,t)=>(e.object(t)?.props?.info??{}).rowHeight??this.rowHeight}}}getNavigationView(){const e=new $58e2f5443faff7c0$require$NavigationView;return e.setView(this.getListView(this.structure)).navigationBarTitle($l10n("SETTING")),this.hasSectionTitle(this.structure)&&e.navigationBar.setContentViewHeightOffset(-10),e}getPage(){return this.getNavigationView().getPage()}}module.exports={Setting:Setting}})),parcelRequire.register("fYz8N",(function(e,t){e.exports={Controller:class{events={};setEvents(e){return Object.keys(e).forEach((t=>this.setEvent(t,e[t]))),this}setEvent(e,t){return this.events[e]=t,this}callEvent(e,...t){"function"==typeof this.events[e]&&this.events[e](...t)}}}})),parcelRequire.register("8aDdQ",(function(e,t){class i extends Error{constructor(e){super(`Parameter [${e}] is required.`),this.name="FileStorageParameterError"}}class r extends Error{constructor(e){super(`File not found: ${e}`),this.name="FileStorageFileNotFoundError"}}class s{basePath;constructor({basePath:e="storage"}={}){this.basePath=e,this.#d(this.basePath)}#d(e){$file.isDirectory(e)||$file.mkdir(e)}filePath(e="",t=!0){e.startsWith("/")&&(e=e.substring(1));let i="";if(!(e=`${this.basePath}/${e}`).endsWith("/")){const t=e.lastIndexOf("/");e.lastIndexOf(".")>t&&(i=e.substring(t+1),e=e.substring(0,t+1))}return t&&this.#d(e),e+i}exists(e=""){return e=this.filePath(e,!1),!!$file.exists(e)}write(e="",t){return new Promise(((i,r)=>{try{const s=this.writeSync(e,t);s?i(s):r(s)}catch(e){r(e)}}))}writeSync(e="",t){if(!t)throw new i("data");return $file.write({data:t,path:this.filePath(e)})}read(e=""){return new Promise(((t,i)=>{try{const r=this.readSync(e);r?t(r):i()}catch(e){i(e)}}))}readSync(e=""){if(e=this.filePath(e),!$file.exists(e))throw new r(e);return $file.isDirectory(e)?$file.list(e):$file.read(e)}readAsJSON(e="",t=null){try{const t=this.readSync(e)?.string;return JSON.parse(t)}catch(e){return t}}static readFromRoot(e=""){return new Promise(((t,i)=>{try{const r=s.readFromRootSync(e);r?t(r):i()}catch(e){i(e)}}))}static readFromRootSync(e=""){if(!e)throw new i("path");if(!$file.exists(e))throw new r(e);return $file.isDirectory(e)?$file.list(e):$file.read(e)}static readFromRootAsJSON(e="",t=null){try{const t=s.readFromRootSync(e)?.string;return JSON.parse(t)}catch(e){return t}}delete(e=""){return $file.delete(this.filePath(e,!1))}copy(e,t){e=this.filePath(e),t=this.filePath(t),$file.copy({src:e,dst:t})}move(e,t){e=this.filePath(e),t=this.filePath(t),$file.move({src:e,dst:t})}}e.exports={FileStorageParameterError:i,FileStorageFileNotFoundError:r,FileStorage:s}})),parcelRequire.register("cgaQ6",(function(e,t){var i=parcelRequire("czAIJ").VERSION;class r{startTime=Date.now();isUseJsboxNav=!1;title=$addin?.current?.name;constructor(){$app.isDebugging&&this.debug()}static isTaio=$app.info.bundleID.includes("taio");static l10n(e,t,i=!0){if("string"==typeof t){const e={};t.split(";").forEach((t=>{if(""!==(t=t.trim())){const i=t.split("=");e[i[0].trim().slice(1,-1)]=i[1].trim().slice(1,-1)}})),t=e}const r=$app.strings;r[e]=i?Object.assign($app.strings[e],t):Object.assign(t,$app.strings[e]),$app.strings=r}static compressImage(e,t=921600){const i=$imagekit.info(e);if(i.height*i.width>t){const r=t/(i.height*i.width);e=$imagekit.scaleBy(e,r)}return e}static objectEqual(e,t){let i=Object.getOwnPropertyNames(e),s=Object.getOwnPropertyNames(t);if(i.length!==s.length)return!1;for(let s=0;se?i[e]:0,s=isNaN(Number(t))?t.charCodeAt():Number(t),n=r.length>e?r[e]:0,o=isNaN(Number(n))?n.charCodeAt():Number(n);if(so){a=1;break}}return a}static deleteConfirm(e,t){$ui.alert({title:$l10n("DELETE_CONFIRM_TITLE"),message:e,actions:[{title:$l10n("DELETE"),style:$alertActionType.destructive,handler:()=>{t()}},{title:$l10n("CANCEL")}]})}static bytesToSize(e){if(0===e)return"0 B";const t=Math.floor(Math.log(e)/Math.log(1024));return(e/Math.pow(1024,t)).toPrecision(3)+" "+["B","KB","MB","GB","TB","PB","EB","ZB","YB"][t]}debug(e,t){this.debugMode=!0,$app.idleTimerDisabled=!0,"function"==typeof e&&(this.debugPrint=e),"function"==typeof t&&(this.debugError=t),this.print("You are running EasyJsBox in debug mode.")}print(e){this.debugMode&&("function"==typeof this.debugPrint?this.debugPrint(e):console.log(e))}error(e){this.debugMode&&("function"==typeof this.debugError?this.debugError(e):console.error(e))}useJsboxNav(){return this.isUseJsboxNav=!0,this}setTitle(e){this.isUseJsboxNav&&($ui.title=e),this.title=e}setNavButtons(e){this.navButtons=e}openInJsbox(){$app.openURL(`jsbox://run?name=${this.title}`)}UIRender(e){try{e.props=Object.assign({title:this.title,navBarHidden:!this.isUseJsboxNav,navButtons:this.navButtons??[],statusBarStyle:0},e.props),e.events||(e.events={});const t=e.events.layoutSubviews,{UIKit:i}=parcelRequire("45Ip7");e.events.layoutSubviews=()=>{$app.notify({name:"interfaceOrientationEvent",object:{statusBarOrientation:i.statusBarOrientation,isHorizontal:i.isHorizontal}}),"function"==typeof t&&t()},$ui.render(e)}catch(e){this.print(e)}}async checkUpdate(){const e=await $http.get("https://raw.githubusercontent.com/ipuppet/EasyJsBox/dev/src/version.js");if(e.error)throw e.error;const t=srcRes.data.match(/.*VERSION.?\"([0-9\.]+)\"/)[1];if(this.print(`easy-jsbox latest version: ${t}`),r.versionCompare(t,i)>0){const e=await $http.get("https://raw.githubusercontent.com/ipuppet/EasyJsBox/dev/dist/easy-jsbox.js");if(e.error)throw e.error;return e.data}return!1}}r.l10n("zh-Hans",{DELETE_CONFIRM_TITLE:"删除前确认"},!1),r.l10n("en",{DELETE_CONFIRM_TITLE:"Delete Confirmation"},!1),e.exports={Kernel:r}})),parcelRequire.register("czAIJ",(function(e,t){e.exports={VERSION:"1.3.3"}})),parcelRequire.register("aXWmO",(function(e,t){var i=parcelRequire("6Xrbz").ValidationError,r=parcelRequire("liCrE").View,s=parcelRequire("45Ip7").UIKit,a=parcelRequire("12xzj").NavigationView,n=parcelRequire("dcStC").NavigationBar,o=parcelRequire("gAYmG").BarButtonItem;class l extends Error{constructor(){super("Please call setView(view) first."),this.name="SheetAddNavBarError"}}class c extends i{constructor(e,t){super(e,t),this.name="SheetViewTypeError"}}class h extends r{#p=()=>{};#u=()=>{};style=h.UIModalPresentationStyle.PageSheet;#g=!1;static UIModalPresentationStyle={Automatic:-2,FullScreen:0,PageSheet:1,FormSheet:2,CurrentContext:3,Custom:4,OverFullScreen:5,OverCurrentContext:6,Popover:7,BlurOverFullScreen:8};navigationView;init(){const{width:e,height:t}=$device.info.screen,i=$objc("UIView").invoke("initWithFrame",$rect(0,0,e,t)),r=$objc("UIViewController").invoke("alloc.init"),a=r.$view();return a.$setBackgroundColor(s.primaryViewBackgroundColor),a.$addSubview(i),r.$setModalPresentationStyle(this.style),r.$setModalInPresentation(this.#g),this.#p=()=>{a.jsValue().add(this.navigationView?.getPage().definition??this.view),$ui.vc.ocValue().invoke("presentViewController:animated:completion:",r,!0,void 0)},this.#u=()=>r.invoke("dismissViewControllerAnimated:completion:",!0,void 0),this}preventDismiss(){return this.#g=!0,this}setStyle(e){return this.style=e,this}setView(e={}){if("object"!=typeof e)throw new c("view","object");return this.view=e,this}addNavBar({title:e="",popButton:t={title:$l10n("DONE")},rightButtons:i=[]}={}){if(void 0===this.view)throw new l;this.navigationView=new a;const r=new o;r.setEvents(Object.assign({tapped:()=>{this.dismiss(),"function"==typeof t.tapped&&t.tapped()}},t.events)).setAlign(s.align.left).setSymbol(t.symbol).setTitle(t.title).setColor(t.color).setMenu(t.menu);const c=r.definition.views[0];return c.layout=(e,t)=>{e.left.equalTo(t.super.safeArea).offset(15),e.centerY.equalTo(t.super.safeArea)},this.navigationView.navigationBar.setLargeTitleDisplayMode(n.largeTitleDisplayModeNever).pageSheetMode(),this.navigationView.navigationBarItems.addPopButton("",c).setRightButtons(i),this.navigationView.setView(this.view).navigationBarTitle(e),this.view.props?.bgcolor&&this.navigationView?.getPage().setProp("bgcolor",this.view.props?.bgcolor),this}present(){this.#p()}dismiss(){this.#u()}}e.exports={Sheet:h}})),parcelRequire.register("6Xrbz",(function(e,t){class i extends Error{constructor(e,t){super(`The type of the parameter '${e}' must be '${t}'`),this.name="ValidationError"}}e.exports={ValidationError:i}})),parcelRequire.register("liCrE",(function(e,t){var i=parcelRequire("45Ip7").UIKit;class r{id=$text.uuid;type;props;views;events;layout;#$=void 0;#f=null;constructor({type:e="view",props:t={},views:i=[],events:r={},layout:s=$layout.fill}={}){this.type=e,this.props=t,this.views=i,this.events=r,this.layout=s,this.props.id?this.id=this.props.id:this.props.id=this.id}static create(e){return new this(e)}static createFromViews(e){return new this({views:e})}get scrollableView(){return this.scrollable?this.#f:null}set scrollableView(e){this.#f=e}get scrollable(){if(void 0===this.#$)if(this.#$=!1,i.scrollViewList.indexOf(this.type)>-1)this.scrollableView=this,this.#$=!0;else if(this.views.length>0){const e=t=>{if(!this.#$&&t?.length>0)for(let s=0;s-1)return typeof t[s]!==r&&(t[s]=r.create(t[s])),this.scrollableView=t[s],void(this.#$=!0);e(t[s].views)}};e(this.views)}return this.#$}set scrollable(e){throw new Error("[scrollable] is readonly prop.")}setProps(e){return Object.keys(e).forEach((t=>this.setProp(t,e[t]))),this}setProp(e,t){return"id"===e&&(this.id=t),this.props[e]=t,this}setViews(e){return this.views=e,this.#$=void 0,this}setEvents(e){return Object.keys(e).forEach((t=>this.setEvent(t,e[t]))),this}setEvent(e,t){return this.events[e]=t,this}eventMiddleware(e,t){const i=this.events[e];return this.events[e]=(...e)=>{"function"==typeof i&&t(i,...e)},this}assignEvent(e,t){const i=this.events[e];return this.events[e]=(...e)=>{"function"==typeof i&&i(...e),t(...e)},this}setLayout(e){return this.layout=e,this}getView(){return this}get definition(){return this.getView()}}e.exports={View:r,PageView:class extends r{constructor(e={}){super(e),this.activeStatus=!0}show(){$(this.props.id).hidden=!1,this.activeStatus=!0}hide(){$(this.props.id).hidden=!0,this.activeStatus=!1}setHorizontalSafeArea(e){return this.horizontalSafeArea=e,this}#y(e,t){e.top.bottom.equalTo(t.super),this.horizontalSafeArea?e.left.right.equalTo(t.super.safeArea):e.left.right.equalTo(t.super)}getView(){return this.layout=this.#y,this.props.clipsToBounds=!0,this.props.hidden=!this.activeStatus,super.getView()}}}})),parcelRequire.register("12xzj",(function(e,t){var i=parcelRequire("fYz8N").Controller,r=parcelRequire("liCrE"),s=r.View,a=r.PageView,n=parcelRequire("6Xrbz").ValidationError,o=parcelRequire("cgaQ6").Kernel,l=parcelRequire("45Ip7").UIKit,c=parcelRequire("dcStC"),h=c.NavigationBar,d=c.NavigationBarController,p=parcelRequire("gAYmG").NavigationBarItems;class u extends n{constructor(e,t){super(e,t),this.name="NavigationViewTypeError"}}e.exports={NavigationView:class extends i{page;navigationController=new d;navigationBar=new h;navigationBarItems=new p;constructor(){super(),this.navigationBar.navigationBarItems=this.navigationBarItems,this.navigationController.navigationBar=this.navigationBar}navigationBarTitle(e){return this.navigationBar.setTitle(e),this}setView(e){if("object"!=typeof e)throw new u("view","object");return this.view=s.create(e),this}#b(){if(!(this.view instanceof s))throw new u("view","View");const e=this.view.scrollableView,t=$app.isDebugging||o.isTaio?0:l.topSafeAreaInsets,i=this.navigationBar.largeTitleDisplayMode===h.largeTitleDisplayModeNever?this.navigationBar.navigationBarNormalHeight:this.navigationBar.navigationBarLargeTitleHeight;let r=this.navigationBar.contentViewHeightOffset+i;if(this.navigationBarItems.titleView&&(r+=this.navigationBarItems.titleView.topOffset,r+=this.navigationBarItems.titleView.height,r+=this.navigationBarItems.titleView.bottomOffset),!this.view.scrollable||!1===e.props.associateWithNavigationBar)return void(this.view.layout=(e,i)=>{e.left.right.equalTo(i.super.safeArea),e.bottom.equalTo(i.super);let s=r-this.navigationBar.contentViewHeightOffset;l.isHorizontal&&!l.isLargeScreen||!this.navigationBar.topSafeArea||(s+=t),e.top.equalTo(s)});e.props.stickyHeader&&(r-=i,r+=this.navigationBar.largeTitleFontHeight),e.props.header?e.props.header={type:"view",props:{height:r+(e.props.header?.props?.height??0)},views:[{type:"view",props:{clipsToBounds:!0},views:[e.props.header],layout:(e,t)=>{e.top.equalTo(r),e.bottom.width.equalTo(t.super)}}]}:e.props.header={props:{height:r}},e.props.footer=Object.assign({props:{}},e.props.footer??{}),e.props.footer.props.height=(this.navigationBarItems.fixedFooterView?.height??0)+(e.props.footer.props?.height??0);const a=this.navigationBarItems.isPinTitleView?this.navigationBarItems.titleView.height+this.navigationBarItems.titleView.bottomOffset+this.navigationBar.contentViewHeightOffset:0;if(e.props.indicatorInsets){const t=e.props.indicatorInsets;e.props.indicatorInsets=$insets(t.top+this.navigationBar.navigationBarNormalHeight+a,t.left,t.bottom+(this.navigationBarItems.fixedFooterView?.height??0),t.right)}else e.props.indicatorInsets=$insets(this.navigationBar.navigationBarNormalHeight+a,0,this.navigationBarItems.fixedFooterView?.height??0,0);e.layout=(t,i)=>{e.props.stickyHeader?t.top.equalTo(i.super.safeArea).offset(this.navigationBar.navigationBarNormalHeight):t.top.equalTo(i.super),t.left.right.equalTo(i.super.safeArea),t.bottom.equalTo(i.super)},e.assignEvent("didScroll",(i=>{let r=i.contentOffset.y;l.isHorizontal&&!l.isLargeScreen||!this.navigationBar.topSafeArea||e.props.stickyHeader||(r+=t),this.navigationController.didScroll(r)})).assignEvent("didEndDragging",((i,r)=>{let s=i.contentOffset.y,a=0;l.isHorizontal&&!l.isLargeScreen||!this.navigationBar.topSafeArea||e.props.stickyHeader||(s+=t,a=t),this.navigationController.didEndDragging(s,r,((...e)=>i.scrollToOffset(...e)),a)})).assignEvent("didEndDecelerating",((...t)=>{t[0].tracking||e.events?.didEndDragging(...t)}))}#m(){if(this.navigationBar.prefersLargeTitles){this.#b();let e={};if(this.navigationBarItems.titleView){const t=this.navigationBar.largeTitleDisplayMode===h.largeTitleDisplayModeNever?1:0;e=s.create({views:[this.navigationBar.backgroundColor?{type:"view",props:{alpha:t,bgcolor:this.navigationBar.backgroundColor,id:this.navigationBar.id+"-title-view-background"},layout:$layout.fill}:l.blurBox({alpha:t,id:this.navigationBar.id+"-title-view-background"}),l.separatorLine({id:this.navigationBar.id+"-title-view-underline",alpha:t}),this.navigationBarItems.titleView.definition],layout:(e,t)=>{e.top.equalTo(t.prev.bottom),e.width.equalTo(t.super),e.height.equalTo(this.navigationBarItems.titleView.topOffset+this.navigationBarItems.titleView.height+this.navigationBarItems.titleView.bottomOffset)}})}this.page=a.createFromViews([this.view,this.navigationBar.getLargeTitleView(),e,this.navigationBar.getNavigationBarView(),this.navigationBarItems.fixedFooterView?.definition??{}])}else this.page=a.createFromViews([this.view]);this.view.props?.bgcolor?this.page.setProp("bgcolor",this.view.props.bgcolor):this.page.setProp("bgcolor",l.defaultBackgroundColor(this.view.type))}getPage(){return this.page||this.#m(),this.page}}}})),parcelRequire.register("dcStC",(function(e,t){var i=parcelRequire("liCrE").View,r=parcelRequire("fYz8N").Controller,s=parcelRequire("45Ip7").UIKit;parcelRequire("gAYmG").BarButtonItem;class a extends i{static largeTitleDisplayModeAutomatic=0;static largeTitleDisplayModeAlways=1;static largeTitleDisplayModeNever=2;static pageSheetNavigationBarHeight=56;navigationBarItems;title="";prefersLargeTitles=!0;largeTitleDisplayMode=a.largeTitleDisplayModeAutomatic;largeTitleFontSize=34;largeTitleFontFamily="bold";largeTitleFontHeight=$text.sizeThatFits({text:"A",width:100,font:$font(this.largeTitleFontFamily,this.largeTitleFontSize)}).height;navigationBarTitleFontSize=17;topSafeArea=!0;contentViewHeightOffset=10;navigationBarNormalHeight=s.NavigationBarNormalHeight;navigationBarLargeTitleHeight=s.NavigationBarLargeTitleHeight;pageSheetMode(){return this.navigationBarLargeTitleHeight-=this.navigationBarNormalHeight,this.navigationBarNormalHeight=a.pageSheetNavigationBarHeight,this.navigationBarLargeTitleHeight+=this.navigationBarNormalHeight,this.topSafeArea=!1,this}setTopSafeArea(){return this.topSafeArea=!0,this}removeTopSafeArea(){return this.topSafeArea=!1,this}setLargeTitleDisplayMode(e){return this.largeTitleDisplayMode=e,this}setBackgroundColor(e){return this.backgroundColor=e,this}setTitle(e){return this.title=e,this}setPrefersLargeTitles(e){return this.prefersLargeTitles=e,this}setContentViewHeightOffset(e){return this.contentViewHeightOffset=e,this}getLargeTitleView(){return this.prefersLargeTitles&&this.largeTitleDisplayMode!==a.largeTitleDisplayModeNever?{type:"label",props:{id:this.id+"-large-title",text:this.title,textColor:s.textColor,align:$align.left,font:$font(this.largeTitleFontFamily,this.largeTitleFontSize),line:1},layout:(e,t)=>{e.left.equalTo(t.super.safeArea).offset(15),e.height.equalTo(this.largeTitleFontHeight),e.top.equalTo(t.super.safeAreaTop).offset(this.navigationBarNormalHeight)}}:{props:{id:this.id+"-large-title"},layout:(e,t)=>{e.left.top.right.inset(0),e.bottom.equalTo(t.super.safeAreaTop).offset(this.navigationBarNormalHeight)}}}getNavigationBarView(){const e=(e,t)=>{let i=0;const r=[];return e.forEach((e=>{i+=e.width,r.push(e.definition)})),i+=e[0]?.edges??0,e.length>0?{type:"view",views:r,layout:(e,r)=>{e.top.equalTo(r.super.safeAreaTop),e.bottom.equalTo(r.super.safeAreaTop).offset(this.navigationBarNormalHeight),t===s.align.left?e.left.equalTo(r.super.safeArea):e.right.equalTo(r.super.safeArea),e.width.equalTo(i)}}:{}},t=e(this.navigationBarItems.rightButtons,s.align.right),i=this.navigationBarItems.popButtonView??e(this.navigationBarItems.leftButtons,s.align.left),r=this.prefersLargeTitles,n=!this.prefersLargeTitles||this.largeTitleDisplayMode===a.largeTitleDisplayModeNever;return{type:"view",props:{id:this.id+"-navigation",bgcolor:$color("clear")},layout:(e,t)=>{e.left.top.right.inset(0),e.bottom.equalTo(t.super.safeAreaTop).offset(this.navigationBarNormalHeight)},views:[this.backgroundColor?{type:"view",props:{hidden:r,bgcolor:this.backgroundColor,id:this.id+"-background"},layout:$layout.fill}:s.blurBox({hidden:r,id:this.id+"-background"}),s.separatorLine({id:this.id+"-underline",alpha:r?0:1}),{type:"view",props:{alpha:0,bgcolor:$color("clear"),id:this.id+"-large-title-mask"},events:{ready:e=>{e.bgcolor=$(this.id+"-large-title")?.prev.bgcolor}},layout:$layout.fill},{type:"label",props:{id:this.id+"-small-title",alpha:n?1:0,text:this.title,font:$font(this.largeTitleFontFamily,this.navigationBarTitleFontSize),align:$align.center,bgcolor:$color("clear"),textColor:s.textColor},layout:(e,t)=>{e.left.right.inset(0),e.height.equalTo(20),e.centerY.equalTo(t.super.safeArea)}}].concat(t,i)}}}class n extends r{static largeTitleViewSmallMode=0;static largeTitleViewLargeMode=1;navigationBar;updateSelector(){this.selector={navigation:$(this.navigationBar.id+"-navigation"),largeTitleView:$(this.navigationBar.id+"-large-title"),smallTitleView:$(this.navigationBar.id+"-small-title"),underlineView:this.navigationBar.navigationBarItems.isPinTitleView?$(this.navigationBar.id+"-title-view-underline"):$(this.navigationBar.id+"-underline"),largeTitleMaskView:$(this.navigationBar.id+"-large-title-mask"),backgroundView:$(this.navigationBar.id+"-background"),titleViewBackgroundView:$(this.navigationBar.id+"-title-view-background")}}toNormal(e=!0){this.updateSelector(),this.selector.backgroundView.hidden=!1,$ui.animate({duration:.2,animation:()=>{this.selector.underlineView.alpha=1,this.selector.smallTitleView.alpha=1,this.selector.largeTitleView.alpha=0}}),e&&this.navigationBar.navigationBarItems&&(this.navigationBar.largeTitleDisplayMode=a.largeTitleDisplayModeNever)}toLargeTitle(e=!0){this.updateSelector(),this.selector.backgroundView.hidden=!0,$ui.animate({duration:.2,animation:()=>{this.selector.underlineView.alpha=0,this.selector.smallTitleView.alpha=0,this.selector.largeTitleView.alpha=1}}),e&&this.navigationBar.navigationBarItems&&(this.navigationBar.largeTitleDisplayMode=a.largeTitleDisplayModeAlways)}#v(e){const t=e===n.largeTitleViewSmallMode;this.selector.largeTitleView.alpha=t?0:1,$ui.animate({duration:.2,animation:()=>{this.selector.smallTitleView.alpha=t?1:0}})}#w(e){if(this.selector.largeTitleView.updateLayout(((t,i)=>{this.navigationBar.navigationBarNormalHeight-e>0?t.top.equalTo(i.super.safeAreaTop).offset(this.navigationBar.navigationBarNormalHeight-e):t.top.equalTo(i.super.safeAreaTop).offset(0)})),e>0)e>=this.navigationBar.navigationBarNormalHeight?this.#v(n.largeTitleViewSmallMode):this.#v(n.largeTitleViewLargeMode);else{this.#v(n.largeTitleViewLargeMode);let t=this.navigationBar.largeTitleFontSize-.04*e;t>40&&(t=40),this.selector.largeTitleView.font=$font(this.navigationBar.largeTitleFontFamily,t)}}#T(e){const t=this.navigationBar.largeTitleDisplayMode===a.largeTitleDisplayModeNever?5:this.navigationBar.navigationBarNormalHeight,i=void 0!==this.selector.titleViewBackgroundView;if(e>t){this.selector.backgroundView.hidden=!1;const r=()=>{i&&this.navigationBar.navigationBarItems.isPinTitleView&&(this.selector.titleViewBackgroundView.alpha=1),this.selector.largeTitleMaskView.alpha=0,this.selector.underlineView.alpha=1};(e-t)/3>=1?r():$ui.animate({duration:.2,animation:()=>{r()}})}else this.selector.largeTitleMaskView.alpha=e>0?1:0,this.selector.underlineView.alpha=0,i&&(this.selector.titleViewBackgroundView.alpha=0),this.selector.backgroundView.hidden=!0}didScroll(e){if(!this.navigationBar.prefersLargeTitles)return;const t=this.navigationBar.largeTitleDisplayMode;t!==a.largeTitleDisplayModeAlways&&(this.updateSelector(),t===a.largeTitleDisplayModeAutomatic?(!this.navigationBar.navigationBarItems?.isPinTitleView&&(this.navigationBar.navigationBarItems?.titleView?.controller.didScroll(e),e>0)&&(e-=this.navigationBar.navigationBarItems?.titleView?.height??0)<0&&(e=0),this.#w(e),this.#T(e)):t===a.largeTitleDisplayModeNever&&this.#T(e))}didEndDragging(e,t,i,r){if(!this.navigationBar.prefersLargeTitles)return;const s=this.navigationBar.largeTitleDisplayMode;if(s!==a.largeTitleDisplayModeAlways&&(this.updateSelector(),s===a.largeTitleDisplayModeAutomatic)){let s=0;this.navigationBar.navigationBarItems?.isPinTitleView||(this.navigationBar.navigationBarItems?.titleView?.controller.didEndDragging(e,t,i,r),s=this.navigationBar.navigationBarItems?.titleView?.height??0,e-=s),e>=0&&e<=this.navigationBar.largeTitleFontHeight&&i($point(0,e>=this.navigationBar.largeTitleFontHeight/2?this.navigationBar.navigationBarNormalHeight+s-r:s-r))}}}e.exports={NavigationBar:a,NavigationBarController:n}})),parcelRequire.register("gAYmG",(function(e,t){var i=parcelRequire("liCrE").View,r=parcelRequire("45Ip7").UIKit;class s extends i{static#E;edges=15;iconSize=$size(23,23);fontSize=16;color=r.textColor;title;symbol;align=r.align.right;get width(){if(this.title){const e=$text.sizeThatFits({text:this.title,width:r.windowSize.width,font:$font(this.fontSize)});return Math.ceil(e.width)+this.edges}return this.iconSize.width+this.edges}static get style(){return void 0===this.#E&&(this.#E=new s),this.#E}setEdges(e){return this.edges=e,this}setFontSize(e){return this.fontSize=e,this}setColor(e=r.textColor){return this.color=e,this}setTitle(e){return this.title=e,this}setSymbol(e){return this.symbol=e,this}setMenu(e){return this.menu=e,this}setAlign(e){return this.align=e,this}setLoading(e){e?($(this.id).hidden=!0,$("spinner-"+this.id).hidden=!1):($(this.id).hidden=!1,$("spinner-"+this.id).hidden=!0)}#A(){const e=$(`icon-button-${this.id}`),t=$(`icon-checkmark-${this.id}`);e.alpha=0,$(this.id).hidden=!1,$("spinner-"+this.id).hidden=!0,$ui.animate({duration:.6,animation:()=>{t.alpha=1},completion:()=>{$delay(.3,(()=>$ui.animate({duration:.6,animation:()=>{t.alpha=0},completion:()=>{$ui.animate({duration:.4,animation:()=>{e.alpha=1},completion:()=>{e.alpha=1}})}})))}})}getView(){const e=this.events.tapped;return this.events.tapped=t=>{e&&e({start:()=>this.setLoading(!0),done:()=>this.#A(),cancel:()=>this.setLoading(!1)},t)},{type:"view",props:{info:{align:this.align}},views:[{type:"button",props:Object.assign({id:this.id,bgcolor:$color("clear"),font:$font(this.fontSize),titleColor:this.color,contentEdgeInsets:$insets(0,0,0,0),titleEdgeInsets:$insets(0,0,0,0),imageEdgeInsets:$insets(0,0,0,0)},this.menu?{menu:this.menu}:{},this.title?{title:this.title}:{},this.props),views:[{type:"image",props:Object.assign({id:`icon-button-${this.id}`,hidden:void 0===this.symbol,tintColor:this.color},void 0===this.symbol?{}:"string"==typeof this.symbol?{symbol:this.symbol}:{data:this.symbol.png}),layout:(e,t)=>{e.center.equalTo(t.super),e.size.equalTo(this.iconSize)}},{type:"image",props:{id:`icon-checkmark-${this.id}`,alpha:0,tintColor:this.color,symbol:"checkmark"},layout:(e,t)=>{e.center.equalTo(t.super),e.size.equalTo(this.iconSize)}}],events:this.events,layout:$layout.fill},{type:"spinner",props:{id:"spinner-"+this.id,loading:!0,hidden:!0},layout:$layout.fill}],layout:(e,t)=>{if(e.size.equalTo($size(this.width,r.NavigationBarNormalHeight)),e.centerY.equalTo(t.super),t.prev&&t.prev?.info?.align===this.align)this.align===r.align.right?e.right.equalTo(t.prev.left):e.left.equalTo(t.prev.right);else{const t=this.edges/2;this.align===r.align.right?e.right.inset(t):e.left.inset(t)}}}}static creat({id:e,symbol:t,title:i,tapped:a,menu:n,events:o,color:l,align:c=r.align.right}={}){const h=new s;return h.setEvents(Object.assign({tapped:a},o)).setAlign(c).setSymbol(t).setTitle(i).setColor(l).setMenu(n),e&&h.setProp("id",e),h}}e.exports={BarTitleView:class extends i{controller={};setController(e){return this.controller=e,this}},BarButtonItem:s,NavigationBarItems:class{rightButtons=[];leftButtons=[];#S={};hasbutton=!1;isPinTitleView=!1;setTitleView(e){return this.titleView=e,this}pinTitleView(){return this.isPinTitleView=!0,this}setFixedFooterView(e){return this.fixedFooterView=e,this}setRightButtons(e){return e.forEach((e=>this.addRightButton(e))),this.hasbutton||(this.hasbutton=!0),this}setLeftButtons(e){return e.forEach((e=>this.addLeftButton(e))),this.hasbutton||(this.hasbutton=!0),this}addRightButton({id:e,symbol:t,title:i,tapped:a,menu:n,events:o,color:l}={}){const c=s.creat({id:e,symbol:t,title:i,tapped:a,menu:n,events:o,color:l,align:r.align.right});return this.rightButtons.push(c),this.#S[e??c.id]=c,this.hasbutton||(this.hasbutton=!0),this}addLeftButton({id:e,symbol:t,title:i,tapped:a,menu:n,events:o,color:l}={}){const c=s.creat({id:e,symbol:t,title:i,tapped:a,menu:n,events:o,color:l,align:r.align.left});return this.leftButtons.push(c),this.#S[e??c.id]=c,this.hasbutton||(this.hasbutton=!0),this}getButton(e){return this.#S[e]}addPopButton(e,t,i){return e||(e=$l10n("BACK")),this.popButtonView=t??{type:"button",props:{bgcolor:$color("clear"),symbol:"chevron.left",tintColor:r.linkColor,title:` ${e}`,titleColor:r.linkColor,font:$font("bold",16)},layout:(e,t)=>{e.left.equalTo(t.super.safeArea).offset(s.style.edges),e.centerY.equalTo(t.super.safeArea)},events:{tapped:()=>{$ui.pop(),"function"==typeof i&&i()}}},this}removePopButton(){return this.popButtonView=void 0,this}}}})),parcelRequire.register("gMc1q",(function(e,t){var i=parcelRequire("fYz8N").Controller;e.exports={ViewController:class extends i{#C=[];#I(e){e.callEvent("onPop"),this.callEvent("onPop",e),this.#C.pop()}push(e){const t=this.#C[this.#C.length-1];e.navigationBarItems.addPopButton(t?.navigationBar.title),this.#C.push(e),$ui.push({props:{statusBarStyle:0,navBarHidden:!0},events:{dealloc:()=>{this.#I(e)}},views:[e.getPage().definition],layout:$layout.fill})}}}})),String.prototype.trim=function(e,t){return e?"l"===t?this.replace(new RegExp("^\\"+e+"+","g"),""):"r"===t?this.replace(new RegExp("\\"+e+"+$","g"),""):this.replace(new RegExp("^\\"+e+"+|\\"+e+"+$","g"),""):this.replace(/^\s+|\s+$/g,"")};var $czAIJ=parcelRequire("czAIJ"),$bb0fea222fc5aea5$require$VERSION=$czAIJ.VERSION,$fYz8N=parcelRequire("fYz8N"),$bb0fea222fc5aea5$require$Controller=$fYz8N.Controller,$272f042430a952c6$exports={},$45Ip7=parcelRequire("45Ip7"),$272f042430a952c6$require$UIKit=$45Ip7.UIKit,$aXWmO=parcelRequire("aXWmO"),$272f042430a952c6$require$Sheet=$aXWmO.Sheet,$cgaQ6=parcelRequire("cgaQ6"),$272f042430a952c6$require$Kernel=$cgaQ6.Kernel,$12xzj=parcelRequire("12xzj"),$272f042430a952c6$require$NavigationView=$12xzj.NavigationView,$dcStC=parcelRequire("dcStC"),$272f042430a952c6$require$NavigationBar=$dcStC.NavigationBar;class $272f042430a952c6$var$FileManager{viewController;constructor(){this.listId="file-manager-list",this.edges=10,this.iconSize=25,this.loadL10n()}loadL10n(){$272f042430a952c6$require$Kernel.l10n("zh-Hans",{FILE_MANAGER_DELETE_CONFIRM_MSG:"确认要删除吗",DELETE:"删除",CANCEL:"取消",CLOSE:"关闭",SHARE:"分享",SAVE:"保存",SAVE_SUCCESS:"保存成功"},!1),$272f042430a952c6$require$Kernel.l10n("en",{FILE_MANAGER_DELETE_CONFIRM_MSG:"Are you sure you want to delete",DELETE:"Delete",CANCEL:"Cancel",CLOSE:"Close",SHARE:"Share",SAVE:"Save",SAVE_SUCCESS:"Save Success"},!1)}setViewController(e){this.viewController=e}get menu(){return{items:[{title:$l10n("SHARE"),symbol:"square.and.arrow.up",handler:async(e,t)=>{const i=e.object(t).info.info;$share.sheet([$file.absolutePath(i.path)])}}]}}delete(e){$file.delete(e.path)}edit(e){const t=$file.read(e.path);if(t.image)$quicklook.open({image:t.image});else{const i=new $272f042430a952c6$require$Sheet,r=$text.uuid;i.setView({type:"code",layout:$layout.fill,props:{id:r,lineNumbers:!0,theme:$device.isDarkMode?"atom-one-dark":"atom-one-light",text:t.string,insets:$insets(15,15,15,15)}}).addNavBar({title:e.file,popButton:{title:$l10n("CLOSE")},rightButtons:[{title:$l10n("SAVE"),tapped:()=>{$file.write({data:$data({string:$(r).text}),path:e.path}),$ui.success($l10n("SAVE_SUCCESS"))}}]}),i.init().present()}}getFiles(e=""){return $file.list(e).map((t=>{const i=e+"/"+t,r=$file.isDirectory(i);return{info:{info:{path:i,file:t,isDirectory:r}},icon:{symbol:r?"folder.fill":"doc"},name:{text:t},size:{text:r?"":"--"}}})).sort(((e,t)=>e.info.info.isDirectory!==t.info.info.isDirectory?e.info.info.isDirectory?-1:1:e.info.info.isDirectory===t.info.info.isDirectory?e.info.info.file.localeCompare(t.info.info.file):void 0))}async loadFileSize(e){return e.map(((t,i)=>{const r=t.info.info;if(!r.isDirectory)try{e[i].size.text=$272f042430a952c6$require$Kernel.bytesToSize($file.read(r.path).info.size)}catch(t){e[i].size.text=t}})),e}get listTemplate(){return{props:{bgcolor:$color("clear")},views:[{props:{id:"info"}},{type:"image",props:{id:"icon"},layout:(e,t)=>{e.centerY.equalTo(t.super),e.left.inset(this.edges),e.size.equalTo(this.iconSize)}},{type:"label",props:{id:"name",lines:1},layout:(e,t)=>{e.centerY.equalTo(t.super),e.left.equalTo(t.prev.right).offset(this.edges)}},{type:"label",props:{id:"size",color:$color("secondaryText"),lines:1},layout:(e,t)=>{e.centerY.equalTo(t.super),e.right.inset(this.edges)}}]}}#x(e,t){if(this.viewController){const i=new $272f042430a952c6$require$NavigationView;i.setView(t).navigationBarTitle(e),i.navigationBar.setLargeTitleDisplayMode($272f042430a952c6$require$NavigationBar.largeTitleDisplayModeNever),this.viewController.push(i)}else $272f042430a952c6$require$UIKit.push({title:e,views:[t]})}getListView(e=""){return{type:"list",props:{id:this.listId,menu:this.menu,info:{basePath:e},bgcolor:$272f042430a952c6$require$UIKit.primaryViewBackgroundColor,separatorInset:$insets(0,this.edges,0,0),data:[],template:this.listTemplate,actions:[{title:" "+$l10n("DELETE")+" ",color:$color("red"),handler:(e,t)=>{const i=e.object(t).info.info;$272f042430a952c6$require$Kernel.deleteConfirm($l10n("FILE_MANAGER_DELETE_CONFIRM_MSG")+' "'+i.file+'" ?',(()=>{this.delete(i),e.delete(t)}))}}]},layout:$layout.fill,events:{ready:()=>{const t=this.getFiles(e);$(this.listId).data=t,this.loadFileSize(t).then((e=>{$(this.listId).data=e}))},pulled:async e=>{const t=this.getFiles($(this.listId).info.basePath);$(this.listId).data=t,$(this.listId).data=await this.loadFileSize(t),$delay(.5,(()=>{e.endRefreshing()}))},didSelect:(e,t,i)=>{const r=i.info.info;r.isDirectory?this.#x(r.file,this.getListView(r.path)):this.edit(r)}}}}push(e=""){const t=e.substring(e.lastIndexOf("/"));this.#x(t,this.getListView(e))}}$272f042430a952c6$exports={FileManager:$272f042430a952c6$var$FileManager};var $bb0fea222fc5aea5$require$FileManager=$272f042430a952c6$exports.FileManager,$8aDdQ=parcelRequire("8aDdQ"),$bb0fea222fc5aea5$require$FileStorageParameterError=$8aDdQ.FileStorageParameterError,$bb0fea222fc5aea5$require$FileStorageFileNotFoundError=$8aDdQ.FileStorageFileNotFoundError,$bb0fea222fc5aea5$require$FileStorage=$8aDdQ.FileStorage,$4c192cc93140b629$exports={},$liCrE=parcelRequire("liCrE"),$4c192cc93140b629$require$View=$liCrE.View,$45Ip7=parcelRequire("45Ip7"),$4c192cc93140b629$require$UIKit=$45Ip7.UIKit;class $4c192cc93140b629$var$FixedFooterView extends $4c192cc93140b629$require$View{height=60;getView(){return this.type="view",this.setProp("bgcolor",$4c192cc93140b629$require$UIKit.primaryViewBackgroundColor),this.layout=(e,t)=>{e.left.right.bottom.equalTo(t.super),e.top.equalTo(t.super.safeAreaBottom).offset(-this.height)},this.views=[$4c192cc93140b629$require$View.create({props:this.props,views:this.views,layout:(e,t)=>{e.left.right.top.equalTo(t.super),e.height.equalTo(this.height)}})],this}}$4c192cc93140b629$exports={FixedFooterView:$4c192cc93140b629$var$FixedFooterView};var $bb0fea222fc5aea5$require$FixedFooterView=$4c192cc93140b629$exports.FixedFooterView,$cgaQ6=parcelRequire("cgaQ6"),$bb0fea222fc5aea5$require$Kernel=$cgaQ6.Kernel,$50aa538fe0dbd3b0$exports={},$liCrE=parcelRequire("liCrE"),$50aa538fe0dbd3b0$require$View=$liCrE.View;class $50aa538fe0dbd3b0$var$Matrix extends $50aa538fe0dbd3b0$require$View{titleStyle={font:$font("bold",21),height:30};#k;#B;templateIdByIndex(e){return void 0===this.props.template.views[e]?.props?.id&&(void 0===this.props.template.views[e].props&&(this.props.template.views[e].props={}),this.props.template.views[e].props.id=$text.uuid),this.props.template.views[e].props.id}get templateHiddenStatus(){if(!this.#B){this.#B={};for(let e=0;e(e.items=e.items.map((e=>(Object.keys(e).forEach((t=>{e[t].hidden=this.templateHiddenStatus[t]??!1})),Object.keys(this.templateHiddenStatus).forEach((t=>{e[t]||(e[t]={}),e[t].hidden=this.templateHiddenStatus[t]})),e.__templateProps={hidden:!1},e.__title={hidden:!0},e))),e.title&&e.items.unshift(this.#q(e.title)),e)))}rebuildTemplate(){let e={};void 0!==this.props.template.props&&(e=Object.assign(this.props.template.props,{id:"__templateProps",hidden:!1})),this.props.template.props={};const t=[{type:"view",props:e,layout:$layout.fill},{type:"label",props:{id:"__title",hidden:!0,font:this.titleStyle.font},layout:(e,t)=>{e.top.inset(-this.titleStyle.height/4*3),e.height.equalTo(this.titleStyle.height),e.width.equalTo(t.super.safeArea)}}].concat(this.props.template.views);this.props.template.views=t}insert(e,t=!0){return e.indexPath=this.indexPath(e.indexPath,t),$(this.id).insert(e)}delete(e,t=!0){return e=this.indexPath(e,t),$(this.id).delete(e)}object(e,t=!0){return e=this.indexPath(e,t),$(this.id).object(e)}cell(e,t=!0){return e=this.indexPath(e,t),$(this.id).cell(e)}indexPath(e,t){let i=t?0:1;return"number"==typeof e&&(e=$indexPath(0,e)),$indexPath(e.section,e.row+i)}update(e){this.props.data=this.rebuildData(e),$(this.id).data=this.props.data}getView(){return this.props.data=this.rebuildData(this.props.data),this.rebuildTemplate(),this.setEvent("itemSize",((e,t)=>{const i=e.object(t)?.__title?.info;if(i?.title)return $size(Math.max($device.info.screen.width,$device.info.screen.height),0);const r=this.props.columns??2,s=this.props.spacing??15,a=this.props.itemWidth??this.props.itemSize?.width??(e.super.frame.width-s*(r+1))/r,n=this.props.itemHeight??this.props.itemSize?.height??100;return $size(a,n)})),this}}$50aa538fe0dbd3b0$exports={Matrix:$50aa538fe0dbd3b0$var$Matrix};var $bb0fea222fc5aea5$require$Matrix=$50aa538fe0dbd3b0$exports.Matrix,$619319e3f3656d3f$exports={};class $619319e3f3656d3f$var$Request{static method={get:"GET",post:"POST",delete:"DELETE",patch:"PATCH",head:"HEAD"};cacheContainerKey=$addin?.current?.name+".request.cache";#R=!1;#L=!1;cacheLife=2592e6;isLogRequest=!1;timeout=5;logger;constructor(e){"function"==typeof e&&(this.logger=e)}get cache(){return $cache.get(this.cacheContainerKey)??{}}#O(e){this.isLogRequest&&"function"==typeof logger&&this.logger(e)}logRequest(e){return this.isLogRequest=!0,"function"==typeof e&&(this.logger=e),this}getCacheKey(e){return $text.MD5(e)}getCache(e,t=null){return this.cache[e]??t}setCache(e,t){if(!t)return;const i=this.cache;i[e]=t,$cache.set(this.cacheContainerKey,i)}removeCache(e){let t=this.cache;delete t[e],$cache.set(this.cacheContainerKey,t)}clearCache(){$cache.remove(this.cacheContainerKey)}useCache(){return this.#R=!0,this}ignoreCacheExp(){this.#L=!0}async request(e,t,i={},r={},s=this.cacheLife){let a;const n=this.#R&&t===$619319e3f3656d3f$var$Request.method.get;if(n){a=this.getCacheKey(e);const t=this.getCache(a);if(t&&(this.#L||t.exp>Date.now()))return this.#O("get data from cache: "+e),t.data}try{this.#O(`sending request [${t}]: ${e}`);const o=await $http.request({header:r,url:e,method:t,body:i,timeout:this.timeout});if(o.error)throw o.error;if(o?.response?.statusCode>=400){let e=o.data;throw"object"==typeof e&&(e=JSON.stringify(e)),new Error("http error: ["+o.response.statusCode+"] "+e)}return n&&this.setCache(a,{exp:Date.now()+s,data:o}),o}catch(e){throw e.code&&(e=new Error("network error: ["+e.code+"] "+e.localizedDescription)),e}}}$619319e3f3656d3f$exports={Request:$619319e3f3656d3f$var$Request};var $bb0fea222fc5aea5$require$Request=$619319e3f3656d3f$exports.Request,$7D8Kb=parcelRequire("7D8Kb"),$bb0fea222fc5aea5$require$Setting=$7D8Kb.Setting,$aXWmO=parcelRequire("aXWmO"),$bb0fea222fc5aea5$require$Sheet=$aXWmO.Sheet,$7dfcabb1e936a92c$exports={},$liCrE=parcelRequire("liCrE"),$7dfcabb1e936a92c$require$View=$liCrE.View,$7dfcabb1e936a92c$require$PageView=$liCrE.PageView,$fYz8N=parcelRequire("fYz8N"),$7dfcabb1e936a92c$require$Controller=$fYz8N.Controller,$45Ip7=parcelRequire("45Ip7"),$7dfcabb1e936a92c$require$UIKit=$45Ip7.UIKit;class $7dfcabb1e936a92c$var$TabBarCellView extends $7dfcabb1e936a92c$require$View{constructor(e={}){super(e),this.setIcon(e.icon),this.setTitle(e.title),void 0!==e.activeStatus&&(this.activeStatus=e.activeStatus)}setIcon(e){return this.icon=e instanceof Array?e:[e,e],this}setTitle(e){return this.title=e,this}active(){$(`${this.props.id}-icon`).image=$image(this.icon[1]),$(`${this.props.id}-icon`).tintColor=$color("systemLink"),$(`${this.props.id}-title`).textColor=$color("systemLink"),this.activeStatus=!0}inactive(){$(`${this.props.id}-icon`).image=$image(this.icon[0]),$(`${this.props.id}-icon`).tintColor=$color("lightGray"),$(`${this.props.id}-title`).textColor=$color("lightGray"),this.activeStatus=!1}getView(){return this.views=[{type:"image",props:{id:`${this.props.id}-icon`,image:$image(this.activeStatus?this.icon[1]:this.icon[0]),bgcolor:$color("clear"),tintColor:$color(this.activeStatus?"systemLink":"lightGray")},layout:(e,t)=>{e.centerX.equalTo(t.super);const i=$7dfcabb1e936a92c$var$TabBarController.tabBarHeight/2;e.size.equalTo(i),e.top.inset(($7dfcabb1e936a92c$var$TabBarController.tabBarHeight-i-13)/2)}},{type:"label",props:{id:`${this.props.id}-title`,text:this.title,font:$font(10),textColor:$color(this.activeStatus?"systemLink":"lightGray")},layout:(e,t)=>{e.centerX.equalTo(t.prev),e.top.equalTo(t.prev.bottom).offset(3)}}],this}}class $7dfcabb1e936a92c$var$TabBarHeaderView extends $7dfcabb1e936a92c$require$View{height=60;getView(){return this.type="view",this.setProp("bgcolor",this.props.bgcolor??$7dfcabb1e936a92c$require$UIKit.primaryViewBackgroundColor),this.layout=(e,t)=>{e.left.right.bottom.equalTo(t.super),e.top.equalTo(t.super.safeAreaBottom).offset(-this.height-$7dfcabb1e936a92c$var$TabBarController.tabBarHeight)},this.views=[$7dfcabb1e936a92c$require$View.create({props:this.props,views:this.views,layout:(e,t)=>{e.left.right.top.equalTo(t.super),e.height.equalTo(this.height)}})],this}}class $7dfcabb1e936a92c$var$TabBarController extends $7dfcabb1e936a92c$require$Controller{static tabBarHeight=50;#D={};#N={};#V;#_;#P=$text.uuid;#M=$text.uuid;bottomSafeAreaInsets=$app.isDebugging?0:$7dfcabb1e936a92c$require$UIKit.bottomSafeAreaInsets;get selected(){return this.#_}set selected(e){this.switchPageTo(e)}get contentOffset(){return $7dfcabb1e936a92c$var$TabBarController.tabBarHeight+(this.#V?.height??0)}setPages(e={}){return Object.keys(e).forEach((t=>this.setPage(t,e[t]))),this}setPage(e,t){return void 0===this.#_&&(this.#_=e),this.#D[e]=t instanceof $7dfcabb1e936a92c$require$PageView?t:$7dfcabb1e936a92c$require$PageView.create(t),this.#_!==e&&(this.#D[e].activeStatus=!1),this}switchPageTo(e){if(this.#D[e]){if(this.#_===e)return;$ui.animate({duration:.4,animation:()=>{this.#N[e].active()}}),this.#N[this.#_].inactive(),this.#D[this.#_].hide(),this.#D[e].show(),this.callEvent("onChange",this.#_,e),this.#_=e,this.initBackground()}}hideBackground(e=!0){$(this.#M).hidden=!0,$ui.animate({duration:e?.2:1e-4,animation:()=>{$(this.#P).alpha=0}})}showBackground(e=!0){$(this.#M).hidden=!1,$ui.animate({duration:e?.2:1e-4,animation:()=>{$(this.#P).alpha=1}})}initBackground(){const e=this.#D[this.selected];e.scrollable&&$delay(0,(()=>{const t=$(e.id).get(e.scrollableView.id),i=t.contentOffset.y;t.contentSize.height+this.bottomSafeAreaInsets-t.frame.height-i<=0?this.hideBackground(!1):this.showBackground(!1)}))}setCells(e={}){return Object.keys(e).forEach((t=>this.setCell(t,e[t]))),this}setCell(e,t){return void 0===this.#_&&(this.#_=e),t instanceof $7dfcabb1e936a92c$var$TabBarCellView||(t=new $7dfcabb1e936a92c$var$TabBarCellView({props:{info:{key:e}},icon:t.icon,title:t.title,activeStatus:this.#_===e})),this.#N[e]=t,this}setHeader(e){return this.#V=e,this}#F(){const e=[];return Object.values(this.#N).forEach((t=>{t.setEvent("tapped",(e=>{const t=e.info.key;this.switchPageTo(t)})),e.push(t.getView())})),e}#H(){return Object.values(this.#D).map((e=>{if(e.scrollable){const t=e.scrollableView;if(t.props.indicatorInsets){const e=t.props.indicatorInsets;t.props.indicatorInsets=$insets(e.top,e.left,e.bottom+this.contentOffset,e.right)}else t.props.indicatorInsets=$insets(0,0,this.contentOffset,0);t.props.footer=Object.assign({props:{}},t.props.footer??{}),t.props.footer.props.height?t.props.footer.props.height+=this.contentOffset:t.props.footer.props.height=this.contentOffset,"function"==typeof t.assignEvent&&t.assignEvent("didScroll",(e=>{const t=e.contentOffset.y;e.contentSize.height+this.bottomSafeAreaInsets-e.frame.height-t<=1?this.hideBackground():this.showBackground()}))}return e.definition}))}generateView(){const e={type:"view",layout:(e,t)=>{e.centerX.equalTo(t.super),e.width.equalTo(t.super),e.top.equalTo(t.super.safeAreaBottom).offset(-$7dfcabb1e936a92c$var$TabBarController.tabBarHeight),e.bottom.equalTo(t.super)},views:[$7dfcabb1e936a92c$require$UIKit.blurBox({id:this.#P}),{type:"stack",layout:$layout.fillSafeArea,props:{axis:$stackViewAxis.horizontal,distribution:$stackViewDistribution.fillEqually,spacing:0,stack:{views:this.#F()}}},$7dfcabb1e936a92c$require$UIKit.separatorLine({id:this.#M},$7dfcabb1e936a92c$require$UIKit.align.top)],events:{ready:()=>this.initBackground()}};return $7dfcabb1e936a92c$require$View.createFromViews(this.#H().concat(this.#V?.definition??[],e))}}$7dfcabb1e936a92c$exports={TabBarCellView:$7dfcabb1e936a92c$var$TabBarCellView,TabBarHeaderView:$7dfcabb1e936a92c$var$TabBarHeaderView,TabBarController:$7dfcabb1e936a92c$var$TabBarController};var $bb0fea222fc5aea5$require$TabBarCellView=$7dfcabb1e936a92c$exports.TabBarCellView,$bb0fea222fc5aea5$require$TabBarHeaderView=$7dfcabb1e936a92c$exports.TabBarHeaderView,$bb0fea222fc5aea5$require$TabBarController=$7dfcabb1e936a92c$exports.TabBarController,$3839e9f9bae78bdd$exports={};class $3839e9f9bae78bdd$var$Tasks{#U={};addTask(e,t=0){const i=$text.uuid;return this.#U[i]=$delay(t,(async()=>{await e(),delete this.#U[i]})),i}cancelTask(e){this.#U[e].cancel()}clearTasks(){Object.values(this.#U).forEach((e=>e.cancel()))}}$3839e9f9bae78bdd$exports={Tasks:$3839e9f9bae78bdd$var$Tasks};var $bb0fea222fc5aea5$require$Tasks=$3839e9f9bae78bdd$exports.Tasks,$895b2d75ea56b5f0$exports={},$45Ip7=parcelRequire("45Ip7"),$895b2d75ea56b5f0$require$UIKit=$45Ip7.UIKit;class $895b2d75ea56b5f0$var$Toast{static type={info:void 0,success:"checkmark",warning:"exclamationmark.triangle",error:"xmark.circle"};static edges=40;static iconSize=100;static labelTopMargin=10;width=Math.min(.6*$895b2d75ea56b5f0$require$UIKit.windowSize.width,260);labelWidth=this.width-2*$895b2d75ea56b5f0$var$Toast.edges;id=$text.uuid;#z="";type=$895b2d75ea56b5f0$var$Toast.type.info;labelLines=2;font=$font("default",26);constructor(e,t=$895b2d75ea56b5f0$var$Toast.type.info,i=2,r=$font("default",26)){this.type=t,this.message=e,this.labelLines=i,this.font=r}get message(){return this.#z}set message(e){this.#z=e,this.fontHeight=$895b2d75ea56b5f0$require$UIKit.getContentSize(this.font,this.message,this.labelWidth,this.labelLines).height,this.height=(this.hasIcon?$895b2d75ea56b5f0$var$Toast.labelTopMargin+$895b2d75ea56b5f0$var$Toast.iconSize:0)+this.fontHeight+2*$895b2d75ea56b5f0$var$Toast.edges}get hasIcon(){return void 0!==this.type}get blurBox(){const e=$895b2d75ea56b5f0$require$UIKit.blurBox({id:this.id,cornerRadius:15,alpha:0},[{type:"image",props:{symbol:this.type,hidden:!this.hasIcon,tintColor:$color("lightGray")},layout:(e,t)=>{e.top.inset($895b2d75ea56b5f0$var$Toast.edges),e.size.equalTo($895b2d75ea56b5f0$var$Toast.iconSize),e.centerX.equalTo(t.super)}},{type:"label",props:{font:this.font,text:this.message,align:$align.center,lines:this.labelLines,color:$color("lightGray")},layout:(e,t)=>{e.bottom.equalTo(t.supper).offset(-$895b2d75ea56b5f0$var$Toast.edges),e.width.equalTo(this.labelWidth),e.height.equalTo(this.fontHeight),e.centerX.equalTo(t.super)}}]);return e.events={tapped:()=>{this.remove()}},e}show(){$ui.controller.view.insertAtIndex($ui.create(this.blurBox),0);const e=$(this.id);e.layout(((e,t)=>{e.center.equalTo(t.super),e.size.equalTo($size(this.width,this.height))})),e.moveToFront(),$ui.animate({duration:.2,animation:()=>{e.alpha=1}})}remove(){const e=$(this.id);e&&$ui.animate({duration:.2,animation:()=>{e.alpha=0},completion:()=>{e.remove()}})}static toast({message:e,type:t=$895b2d75ea56b5f0$var$Toast.type.info,displayTime:i=2,labelLines:r=2,font:s=$font("default",26)}){const a=new $895b2d75ea56b5f0$var$Toast(e,t,r,s);a.show(),$delay(i,(()=>{a.remove()}))}static info(e,t={}){$895b2d75ea56b5f0$var$Toast.toast(Object.assign({message:e,type:$895b2d75ea56b5f0$var$Toast.type.info},t))}static success(e,t={}){$895b2d75ea56b5f0$var$Toast.toast(Object.assign({message:e,type:$895b2d75ea56b5f0$var$Toast.type.success},t))}static warning(e,t={}){$895b2d75ea56b5f0$var$Toast.toast(Object.assign({message:e,type:$895b2d75ea56b5f0$var$Toast.type.warning},t))}static error(e,t={}){$895b2d75ea56b5f0$var$Toast.toast(Object.assign({message:e,type:$895b2d75ea56b5f0$var$Toast.type.error},t))}}$895b2d75ea56b5f0$exports={Toast:$895b2d75ea56b5f0$var$Toast};var $bb0fea222fc5aea5$require$Toast=$895b2d75ea56b5f0$exports.Toast,$45Ip7=parcelRequire("45Ip7"),$bb0fea222fc5aea5$require$UIKit=$45Ip7.UIKit,$86d2ffde19fb8791$exports={};class $86d2ffde19fb8791$var$UILoading{#j;text="";interval;fullScreen=!1;#K=()=>{};constructor(){this.#j=$text.uuid}updateText(e){$(this.#j).text=e}setLoop(e){if("function"!=typeof e)throw"loop must be a function";this.#K=e}done(){clearInterval(this.interval)}load(){$ui.render({props:{navBarHidden:this.fullScreen},views:[{type:"spinner",props:{loading:!0},layout:(e,t)=>{e.centerY.equalTo(t.super).offset(-15),e.width.equalTo(t.super)}},{type:"label",props:{id:this.#j,align:$align.center,text:""},layout:(e,t)=>{e.top.equalTo(t.prev.bottom).offset(10),e.left.right.equalTo(t.super)}}],layout:$layout.fill,events:{appeared:()=>{this.interval=setInterval((()=>{this.#K()}),100)}}})}}$86d2ffde19fb8791$exports={UILoading:$86d2ffde19fb8791$var$UILoading};var $bb0fea222fc5aea5$require$UILoading=$86d2ffde19fb8791$exports.UILoading,$6Xrbz=parcelRequire("6Xrbz"),$bb0fea222fc5aea5$require$ValidationError=$6Xrbz.ValidationError,$liCrE=parcelRequire("liCrE"),$bb0fea222fc5aea5$require$View=$liCrE.View,$bb0fea222fc5aea5$require$PageView=$liCrE.PageView,$gMc1q=parcelRequire("gMc1q"),$bb0fea222fc5aea5$require$ViewController=$gMc1q.ViewController,$12xzj=parcelRequire("12xzj"),$bb0fea222fc5aea5$require$NavigationView=$12xzj.NavigationView,$dcStC=parcelRequire("dcStC"),$bb0fea222fc5aea5$require$NavigationBar=$dcStC.NavigationBar,$bb0fea222fc5aea5$require$NavigationBarController=$dcStC.NavigationBarController,$gAYmG=parcelRequire("gAYmG"),$bb0fea222fc5aea5$require$NavigationBarItems=$gAYmG.NavigationBarItems,$bb0fea222fc5aea5$require$BarButtonItem=$gAYmG.BarButtonItem,$ee5e1f8d12d987dc$exports={},$fYz8N=parcelRequire("fYz8N"),$ee5e1f8d12d987dc$require$Controller=$fYz8N.Controller,$gAYmG=parcelRequire("gAYmG"),$ee5e1f8d12d987dc$require$BarTitleView=$gAYmG.BarTitleView;class $ee5e1f8d12d987dc$var$SearchBar extends $ee5e1f8d12d987dc$require$BarTitleView{height=35;topOffset=15;bottomOffset=10;kbType=$kbType.search;placeholder=$l10n("SEARCH");inputEvents={};keyboardView;accessoryView;constructor(e){super(e),this.setController(new $ee5e1f8d12d987dc$var$SearchBarController),this.controller.setSearchBar(this)}setEvent(e,t){return this.inputEvents[e]=t,this}setPlaceholder(e){return this.placeholder=e,this}setKbType(e){return this.kbType=e,this}setKeyboardView(e){return this.keyboardView=e,this}setAccessoryView(e){return this.accessoryView=e,this}getView(){return this.props={id:this.id,smoothCorners:!0,cornerRadius:6,bgcolor:$color("#EEF1F1","#212121")},this.views=[{type:"input",props:{id:this.id+"-input",type:this.kbType,bgcolor:$color("clear"),placeholder:this.placeholder,keyboardView:this.keyboardView,accessoryView:this.accessoryView},layout:$layout.fill,events:Object.assign({changed:e=>this.controller.callEvent("onChange",e.text),returned:e=>this.controller.callEvent("onReturn",e.text)},this.inputEvents)}],this.layout=(e,t)=>{e.height.equalTo(this.height),e.top.equalTo(t.super.safeArea).offset(this.topOffset),e.left.equalTo(t.super.safeArea).offset(15),e.right.equalTo(t.super.safeArea).offset(-15)},this}}class $ee5e1f8d12d987dc$var$SearchBarController extends $ee5e1f8d12d987dc$require$Controller{setSearchBar(e){return this.searchBar=e,this}updateSelector(){this.selector={inputBox:$(this.searchBar.id),input:$(this.searchBar.id+"-input")}}hide(){this.updateSelector(),this.selector.inputBox.updateLayout((e=>{e.height.equalTo(0)}))}show(){this.updateSelector(),this.selector.inputBox.updateLayout((e=>{e.height.equalTo(this.searchBar.height)}))}didScroll(e){this.updateSelector();let t=this.searchBar.height-e;if(t=t>0?t>this.searchBar.height?this.searchBar.height:t:0,this.selector.inputBox.updateLayout((e=>{e.height.equalTo(t)})),e>0){const t=(this.searchBar.height/2-5-e)/10;this.selector.input.alpha=t}else this.selector.input.alpha=1}didEndDragging(e,t,i){this.updateSelector(),e>=0&&e<=this.searchBar.height&&i($point(0,e>=this.searchBar.height/2?this.searchBar.height:0))}}$ee5e1f8d12d987dc$exports={SearchBar:$ee5e1f8d12d987dc$var$SearchBar,SearchBarController:$ee5e1f8d12d987dc$var$SearchBarController};var $bb0fea222fc5aea5$require$SearchBar=$ee5e1f8d12d987dc$exports.SearchBar,$bb0fea222fc5aea5$require$SearchBarController=$ee5e1f8d12d987dc$exports.SearchBarController;module.exports={VERSION:$bb0fea222fc5aea5$require$VERSION,Controller:$bb0fea222fc5aea5$require$Controller,FileManager:$bb0fea222fc5aea5$require$FileManager,FileStorageParameterError:$bb0fea222fc5aea5$require$FileStorageParameterError,FileStorageFileNotFoundError:$bb0fea222fc5aea5$require$FileStorageFileNotFoundError,FileStorage:$bb0fea222fc5aea5$require$FileStorage,FixedFooterView:$bb0fea222fc5aea5$require$FixedFooterView,Kernel:$bb0fea222fc5aea5$require$Kernel,Matrix:$bb0fea222fc5aea5$require$Matrix,Request:$bb0fea222fc5aea5$require$Request,Setting:$bb0fea222fc5aea5$require$Setting,Sheet:$bb0fea222fc5aea5$require$Sheet,TabBarCellView:$bb0fea222fc5aea5$require$TabBarCellView,TabBarHeaderView:$bb0fea222fc5aea5$require$TabBarHeaderView,TabBarController:$bb0fea222fc5aea5$require$TabBarController,Tasks:$bb0fea222fc5aea5$require$Tasks,Toast:$bb0fea222fc5aea5$require$Toast,UIKit:$bb0fea222fc5aea5$require$UIKit,UILoading:$bb0fea222fc5aea5$require$UILoading,ValidationError:$bb0fea222fc5aea5$require$ValidationError,View:$bb0fea222fc5aea5$require$View,PageView:$bb0fea222fc5aea5$require$PageView,ViewController:$bb0fea222fc5aea5$require$ViewController,NavigationView:$bb0fea222fc5aea5$require$NavigationView,NavigationBar:$bb0fea222fc5aea5$require$NavigationBar,NavigationBarController:$bb0fea222fc5aea5$require$NavigationBarController,NavigationBarItems:$bb0fea222fc5aea5$require$NavigationBarItems,BarButtonItem:$bb0fea222fc5aea5$require$BarButtonItem,SearchBar:$bb0fea222fc5aea5$require$SearchBar,SearchBarController:$bb0fea222fc5aea5$require$SearchBarController}})),parcelRequire.register("jEwwi",(function(e,t){var i=parcelRequire("gxpqj").Kernel;class r{sqlite;constructor(e){this.kernel=e,this.dbName="CAIO.db",this.localDb=`/${this.dbName}`,this.imagePath="/image",this.imageOriginalPath=`${this.imagePath}/original`,this.imagePreviewPath=`${this.imagePath}/preview`,this.tempPath="/temp",this.tempDbFile=`${this.tempPath}/${this.dbName}`,this.tempImagePath=`${this.tempPath}/image`,this.exportFileName="CAIO.zip",this.init()}init(){this.sqlite=$sqlite.open(this.kernel.fileStorage.filePath(this.localDb)),this.sqlite.update("CREATE TABLE IF NOT EXISTS clips(uuid TEXT PRIMARY KEY NOT NULL, text TEXT, md5 TEXT, prev TEXT, next TEXT)"),this.sqlite.update("CREATE TABLE IF NOT EXISTS favorite(uuid TEXT PRIMARY KEY NOT NULL, text TEXT, md5 TEXT, prev TEXT, next TEXT)"),this.sqlite.update("CREATE TABLE IF NOT EXISTS tag(uuid TEXT PRIMARY KEY NOT NULL, tag TEXT)")}rebuild(){const e=this.tempPath+"/rebuild.db";this.kernel.fileStorage.delete(e);const t=new r(this.kernel);t.localDb=e,t.init();const i=(e,i)=>{const r=[];e.forEach((e=>{const s={uuid:e.uuid,text:e.text,md5:e.md5,tag:e.tag,image:e.image,prev:null,next:r[0]?.uuid??null};t.beginTransaction();try{t.insert(i,s),s.next&&(r[0].prev=s.uuid,t.update(i,r[0])),t.commit(),r.unshift(s)}catch(e){throw t.rollback(),this.kernel.error(e),e}}))};["clips","favorite"].map((e=>{let t=this.all(e);try{const e=this.sort(JSON.parse(JSON.stringify(t)));if(e.length>t.length)throw new Error;t=e.reverse()}catch{}i(t,e)}));const s=this.sqlite.query("SELECT * FROM tag");this.parseTag(s).forEach((e=>{t.beginTransaction();try{t.setTag(e.uuid,e.tag),t.commit()}catch(e){throw t.rollback(),this.kernel.error(e),e}})),this.kernel.fileStorage.copy(e,this.localDb)}deleteAllData(){this.kernel.fileStorage.delete(this.imagePath),this.kernel.fileStorage.delete(this.localDb)}clearTemp(){this.kernel.fileStorage.delete(this.tempPath)}async export(e){this.clearTemp(),this.kernel.fileStorage.copy(this.localDb,this.tempDbFile),this.kernel.fileStorage.copy(this.imagePath,this.tempImagePath);const t=this.tempPath+"/"+this.exportFileName;await $archiver.zip({directory:this.kernel.fileStorage.filePath(this.tempPath),dest:this.kernel.fileStorage.filePath(t)}),$share.sheet({items:[{name:this.exportFileName,data:$data({path:this.kernel.fileStorage.filePath(t)})}],handler:i=>{this.kernel.fileStorage.delete(t),e(i)}})}async import(e){if("db"===e.fileName.slice(-2)){if(!this.kernel.fileStorage.writeSync(this.localDb,e))throw new Error("WRITE_DB_FILE_FAILED")}else if("zip"===e.fileName.slice(-3)){if(!await $archiver.unzip({file:e,dest:this.kernel.fileStorage.filePath(this.tempPath)}))throw new Error("UNZIP_FAILED");this.kernel.fileStorage.move(this.tempDbFile,this.localDb),this.kernel.fileStorage.move(this.tempImagePath,this.imagePath)}}sort(e,t=9e3){const i={};let r=0,s=null;e.forEach((e=>{i[e.uuid]=e,null===e.prev&&(s=e.uuid),r++}));const a=[];if(r>0)try{let e=i[s];for(;null!==e.next&&t>0;)t--,a.push(e),e=i[e.next];a.push(e)}catch(e){throw"Unable to sort: "+e}return a}parse(e){const t=e.result,i=e.error;if(null!==i)throw new Error(`Code [${i.code}] ${i.domain} ${i.localizedDescription}`);const r=[];for(;t.next();)r.push({uuid:t.get("uuid"),section:t.get("section"),text:t.get("text"),md5:t.get("md5"),tag:t.get("tag")??"",prev:t.get("prev")??null,next:t.get("next")??null});return t.close(),r}parseTag(e){if(null!==e.error)throw e.error;const t=[];for(;e.result.next();)t.push({uuid:e.result.get("uuid"),tag:e.result.get("tag")});return e.result.close(),t}beginTransaction(){this.sqlite.beginTransaction()}commit(){this.sqlite.commit()}rollback(){this.sqlite.rollback()}getByUUID(e){e=e.replace("'","");const t=this.sqlite.query({sql:`\n SELECT *, 'clips' AS section FROM clips WHERE uuid = '${e}'\n UNION\n SELECT *, 'favorite' AS section FROM favorite WHERE uuid = '${e}'\n `});return this.parse(t)[0]}getByMD5(e){e=e.replace("'","");const t=this.sqlite.query({sql:`\n SELECT *, 'clips' AS section FROM clips WHERE md5 = '${e}'\n UNION\n SELECT *, 'favorite' AS section FROM favorite WHERE md5 = '${e}'\n `});return this.parse(t)[0]}search(e){const t=this.sqlite.query({sql:"SELECT * from\n (SELECT clips.*, 'clips' AS section FROM clips WHERE text like ?\n UNION\n SELECT favorite.*, 'favorite' AS section FROM favorite WHERE text like ?) a\n LEFT JOIN tag ON a.uuid = tag.uuid\n ",args:[`%${e}%`,`%${e}%`]});return this.parse(t)}isImage(e){return e?.startsWith("@image=")}pathToKey(e){return`@image=${e=JSON.stringify(e)}`}keyToPath(e){return!!this.isImage(e)&&JSON.parse(e.slice(7))}deleteTable(e){const t=this.sqlite.update(`DELETE FROM ${e}`);if(!t.result)throw t.error}all(e){const t=this.sqlite.query(`SELECT ${e}.*, tag, '${e}' AS section FROM ${e} LEFT JOIN tag ON ${e}.uuid = tag.uuid`);return this.parse(t)}insert(e,t){if(t.image){const e=t.image,r=$text.uuid,s={original:`${this.imageOriginalPath}/${r}.png`,preview:`${this.imagePreviewPath}/${r}.jpg`};this.kernel.fileStorage.write(s.original,e.png),this.kernel.fileStorage.write(s.preview,i.compressImage(e).jpg(.8)),t.text=this.pathToKey(s)}const r=this.sqlite.update({sql:`INSERT INTO ${e} (uuid, text, md5, prev, next) values (?, ?, ?, ?, ?)`,args:[t.uuid,t.text,$text.MD5(t.text),t.prev,t.next]});if(!r.result)throw r.error}update(e,t){if(Object.keys(t).length<4||"string"!=typeof t.uuid)return;const i=this.sqlite.update({sql:`UPDATE ${e} SET text = ?, md5 = ?, prev = ?, next = ? WHERE uuid = ?`,args:[t.text,$text.MD5(t.text),t.prev,t.next,t.uuid]});if(!i.result)throw i.error}updateText(e,t,i){if("string"!=typeof t)return;const r=this.sqlite.update({sql:`UPDATE ${e} SET text = ?, md5 = ? WHERE uuid = ?`,args:[i,$text.MD5(i),t]});if(!r.result)throw r.error}delete(e,t){const i=this.getByUUID(t);this.beginTransaction();try{const i=this.sqlite.update({sql:`DELETE FROM ${e} WHERE uuid = ?`,args:[t]});if(!i.result)throw i.error;this.deleteTag(t),this.commit()}catch(e){throw this.rollback(),e}const r=this.keyToPath(i?.text);r&&(this.kernel.fileStorage.delete(r.original),this.kernel.fileStorage.delete(r.preview))}setTag(e,t){const i=this.sqlite.update({sql:"INSERT OR REPLACE INTO tag (uuid, tag) values (?, ?)",args:[e,t]});if(!i.result)throw i.error}deleteTag(e){const t=this.sqlite.update({sql:"DELETE FROM tag WHERE uuid = ?",args:[e]});if(!t.result)throw t.error}}e.exports=r})),parcelRequire.register("imdB1",(function(e,t){var i=parcelRequire("gxpqj"),r=i.View,s=i.Kernel,a=i.UIKit,n=i.Sheet,o=i.ViewController,l=i.NavigationView,c=i.NavigationBar,h=i.Toast,d=parcelRequire("f0nX9"),p=parcelRequire("ZnuTV"),u=parcelRequire("ay4Kj"),g=parcelRequire("9LqeL"),f=parcelRequire("eSp9Z"),y=f.ActionData,b=f.ActionEnv;e.exports=class extends p{listId="clips-list";#Y=!1;#G=-1;tabLeftMargin=20;horizontalMargin=20;verticalMargin=20;containerMargin=0;fontSize=16;copiedIndicatorSize=6;imageContentHeight=50;tagFontSize=14;tagContainerHeight=25;menuItemActionMaxCount=5;tabHeight=44;copied=$cache.get("clips.copied")??{};#W={};constructor(e){super(e),this.viewController=new o,this.search=new u(this.kernel),this.search.setCallback((e=>{(new n).setView(this.getListView(this.listId+"-search-result",e.map((e=>this.lineData(e))))).addNavBar({title:$l10n("SEARCH_RESULT"),popButton:{title:$l10n("DONE"),tapped:()=>this.search.dismiss()}}).init().present()}))}get singleLineHeight(){return this.#G<0&&(this.#G=$text.sizeThatFits({text:"A",width:this.fontSize,font:$font(this.fontSize)}).height),this.#G}setSingleLine(){this.#Y=!0,this.imageContentHeight=this.singleLineHeight}getTextHeight(e){return this.#W[e]||(this.#W[e]=this.#Y?this.singleLineHeight:Math.min($text.sizeThatFits({text:e,width:a.windowSize.width-2*(this.horizontalMargin+this.containerMargin),font:$font(this.fontSize)}).height,2*this.singleLineHeight)),this.#W[e]}appListen(){s.isTaio||$app.listen({resume:()=>{this.updateList(!0),$delay(.5,(()=>{this.readClipboard()}))}})}listReady(){this.updateList(),s.isTaio||($delay(.5,(()=>{if($context.query.copy){const e=$context.query.copy,t=this.kernel.storage.getByUUID(e);this.setClipboardText(t.text),this.setCopied(e,this.getRowByUUID(e)),$ui.success($l10n("COPIED"))}else $context.query.add?this.getAddTextView():$context.query.actions&&(this.kernel.isUseJsboxNav?this.kernel.actionManager.present():this.kernel.tabBarController.switchPageTo("actions"))})),$delay(.5,(()=>{this.readClipboard()})),this.appListen())}updateList(e=!1){e&&this.loadAllClips(),$(this.listId).data=this.clips.map((e=>this.lineData(e,this.copied.uuid===e.uuid))),this.updateListBackground()}updateListBackground(){const e=$(this.listId+"-empty-list-background");e&&(e.hidden=this.clips.length>0)}updateCopied(e={}){Object.assign(this.copied,e),this.kernel.print(`this.copied: ${JSON.stringify(this.copied,null,2)}`),$cache.set("clips.copied",this.copied)}setCopied(e,t,i=!0){if(!e||e===this.copied.uuid&&this.tabIndex===this.copied?.tabIndex&&t===this.copied?.row)return;let r={};this.copied.uuid!==e&&(r=this.kernel.storage.getByUUID(e)??{}),r.tabIndex=this.tabIndex,r.row=t;const s=this.copied.row;this.updateCopied(r),i&&$delay(.3,(()=>{const e=$(this.listId);e.cell($indexPath(0,s)).get("copied").hidden=!0,e.cell($indexPath(0,t)).get("copied").hidden=!1}))}readClipboard(e=!1){if(e||this.kernel.setting.get("clipboard.autoSave")){if(this.kernel.print("read clipboard"),!this.isChanged)return void(e&&$ui.toast($l10n("CLIPBOARD_NO_CHANGE")));if(this.switchTab(1,!0),$clipboard.images?.length>0)return!!e&&($clipboard.images.forEach((e=>{this.add(e)})),!0);const t=$clipboard.text;if(!t||""===t)return!1;if(this.copied.text===t)return!1;const i=$text.MD5(t);if(this.savedClipboardIndex[i]){const e=this.kernel.storage.getByMD5(i);this.setCopied(e.uuid,this.getRowByUUID(e.uuid))}else{const e=this.add(t);this.copy(t,e.uuid,0)}}return!1}add(e){try{const t=super.add(e);return this.updateListBackground(),$(this.listId).insert({indexPath:$indexPath(0,0),value:this.lineData(t)}),this.copied?.tabIndex===this.tabIndex&&this.setCopied(this.copied.uuid,this.copied?.row+1,!1),t}catch(e){$ui.alert(e)}}delete(e,t){try{super.delete(e,t),this.copied.uuid===e&&(this.copied={},$clipboard.clear()),this.updateListBackground()}catch(e){$ui.alert(e)}}update(e,t,i){return!!super.update(e,t,i)&&(this.updateList(),e===this.copied.uuid&&(this.setClipboardText(t),this.updateCopied({text:t})),!0)}move(e,t,i=!0){if(e!==t)try{if(super.move(e,t),!i)return;const r=$(this.listId);ee&&this.copied.rowt||this.copied.row===t)&&this.setCopied(this.copied.uuid,e{i.text?$share.sheet(i.text):$ui.warning($l10n("NONE"))}}];if(this.kernel.isUseJsboxNav)i.uikitPush(e,(e=>t(e)),r);else{const s=i.getNavigationView(e,(e=>t(e)),r);this.viewController.push(s)}}getAddTextView(){this.edit("",(e=>{""!==e&&this.add(e)}))}menuItems(e=!1){const t=[{inline:!0,items:[{title:$l10n("TAG"),symbol:"tag",handler:(e,t)=>{const i=this.clips[t.row].uuid;$input.text({placeholder:$l10n("ADD_TAG"),text:e.text,handler:e=>{(e=e.trim()).length>0?this.kernel.storage.setTag(i,e):this.kernel.storage.deleteTag(i),this.updateList(!0)}})}}]},{inline:!0,items:[{title:$l10n("SHARE"),symbol:"square.and.arrow.up",handler:(e,t)=>{const i=this.clips[t.row].text;let r=i;const s=this.kernel.storage.keyToPath(i);if(s&&this.kernel.fileStorage.exists(s.original)){const e=this.kernel.fileStorage.readSync(s.original)?.image?.png;r={name:e.fileName,data:e}}$share.sheet([r])}},{title:$l10n("COPY"),symbol:"square.on.square",handler:(e,t)=>{const i=this.clips[t.row];this.copy(i.text,i.uuid,t.row)}},{title:$l10n("DELETE"),symbol:"trash",destructive:!0,handler:(e,t)=>{this.kernel.deleteConfirm($l10n("CONFIRM_DELETE_MSG"),(()=>{const i=this.clips[t.row];this.delete(i.uuid,t.row),e.delete(t)}))}}]}];if(e)return t;const i=e=>{const t=this.kernel.actionManager.getActionHandler(e.type,e.dir);return e.handler=(e,i)=>{const r=this.clips[i.row],s=new y({env:b.clipboard,text:r.text,uuid:r.uuid});t(s)},e.title=e.name,e.symbol=e.icon,e},r=this.kernel.actionManager.getActions("clipboard"),s={inline:!0,items:r.slice(0,this.menuItemActionMaxCount).map(i)};return r.length>this.menuItemActionMaxCount&&s.items.push({title:$l10n("MORE_ACTIONS"),symbol:"square.grid.2x2",items:r.slice(this.menuItemActionMaxCount).map(i)}),[s,...t]}switchTab(e,t=!1){this.tabIndex=e,this.updateList(),t&&($(this.listId+"-tab").index=this.tabIndex)}tabView(){return{type:"tab",props:{id:this.listId+"-tab",items:this.tabItems,index:this.tabIndex,dynamicWidth:!0},events:{changed:e=>this.switchTab(e.index)},layout:(e,t)=>{e.centerY.equalTo(t.super),t.prev?e.left.equalTo(t.prev.right).offset(this.tabLeftMargin):e.left.inset(this.tabLeftMargin)}}}lineData(e,t=!1){const i={hidden:!0},r={text:""},s=this.kernel.storage.keyToPath(e.text);return s?(i.src=s.preview,i.hidden=!1):r.text=e.text,{copied:{hidden:!t},image:i,tag:{text:e.tag},content:r}}listTemplate(){return{props:{bgcolor:$color("clear")},views:[{type:"view",views:[{type:"view",props:{id:"copied",circular:this.copiedIndicatorSize,hidden:!0,bgcolor:$color("green")},layout:(e,t)=>{e.centerY.equalTo(t.super),e.size.equalTo(this.copiedIndicatorSize),e.left.equalTo(t.super).inset(this.horizontalMargin/2-this.copiedIndicatorSize/2)}},{type:"label",props:{id:"content",lines:this.#Y?1:2,font:$font(this.fontSize)},layout:(e,t)=>{e.left.right.equalTo(t.super).inset(this.horizontalMargin),this.#Y?e.top.inset(this.imageContentHeight/2):e.top.inset(this.verticalMargin)}},{type:"image",props:{id:"image",hidden:!0},layout:$layout.fill}],layout:$layout.fill},{type:"label",props:{id:"tag",color:$color("systemGray2"),font:$font(this.tagFontSize)},layout:(e,t)=>{e.bottom.width.equalTo(t.super),e.left.inset(this.horizontalMargin),e.height.equalTo(this.tagContainerHeight)}}]}}getListView(e=this.listId,t=[]){const i={type:"list",props:{id:e,associateWithNavigationBar:!1,bgcolor:$color("clear"),separatorInset:$insets(0,this.horizontalMargin,0,0),menu:{items:this.menuItems()},data:t,template:this.listTemplate(),actions:[{title:$l10n("COPY"),color:$color("systemLink"),handler:(e,t)=>{const i=this.clips[t.row];this.copy(i.text,i.uuid,t.row)}},{title:$l10n("FAVORITE"),color:$color("orange"),handler:(e,t)=>{const i=this.clips[t.row];this.favorite(i,t.row)}}]},layout:$layout.fill,events:{ready:()=>this.listReady(),rowHeight:(e,t)=>{const i=e.object(t),r=i.tag.text?this.tagContainerHeight:this.verticalMargin;return(this.kernel.storage.isImage(i.content.text)?this.imageContentHeight:this.getTextHeight(i.content.text))+this.verticalMargin+r},didSelect:(e,t,i)=>{const r=this.clips[t.row],s=r.text,a=this.kernel.storage.keyToPath(s);a&&this.kernel.fileStorage.exists(a.original)?$quicklook.open({image:this.kernel.fileStorage.readSync(a.original)?.image}):this.edit(r.text,(e=>{r.md5!==$text.MD5(e)&&this.update(r.uuid,e,t.row)}))},pulled:e=>{this.updateList(!0),$delay(.5,(()=>e.endRefreshing()))}}},s={type:"label",props:{id:e+"-empty-list-background",color:$color("secondaryText"),hidden:this.clips.length>0,text:$l10n("NONE"),align:$align.center},layout:$layout.center};return r.createFromViews([i,s])}getNavigationView(){const e=this.tabView();e.type="menu",e.layout=(e,t)=>{e.top.left.right.equalTo(t.super),e.height.equalTo(this.tabHeight)};const t=this.getListView();t.views.unshift(e),t.views[1].layout=(e,t)=>{e.bottom.left.right.equalTo(t.super),e.top.equalTo(t.prev.bottom)},t.views.push(this.search.getSearchHistoryView());const i=(new l).navigationBarTitle($l10n("CLIPS")).setView(t);return i.navigationBarItems.setTitleView(this.search.getSearchBarView()).pinTitleView().setRightButtons([{symbol:"plus.circle",tapped:()=>this.getAddTextView()}]).setLeftButtons([{title:$l10n("EDIT"),tapped:()=>{new g(this).presentSheet()}},{symbol:"square.and.arrow.down.on.square",tapped:e=>{e.start(),this.readClipboard(!0),e.done()}}]),i.navigationBar.setBackgroundColor(a.primaryViewBackgroundColor).setLargeTitleDisplayMode(c.largeTitleDisplayModeNever),this.kernel.isUseJsboxNav&&i.navigationBar.removeTopSafeArea(),i}}})),parcelRequire.register("f0nX9",(function(e,t){var i=parcelRequire("gxpqj"),r=i.UIKit,s=i.NavigationBar,a=i.NavigationView,n=i.Sheet,o=parcelRequire("eSp9Z"),l=o.ActionEnv,c=o.ActionData;e.exports=class{#J="";constructor(e){this.kernel=e,this.id="editor",this.originalContent=void 0}set text(e=""){void 0===this.originalContent&&(this.originalContent=e),this.#J=e}get text(){return this.#J}getActionButton(){return{symbol:"bolt.circle",tapped:(e,t)=>{t&&(e=t);const i=$(this.id).selectedRange,r=new c({env:l.editor,editor:{setContent:e=>this.setContent(e)},text:i.length>0?this.text.slice(i.location,i.location+i.length):this.text,selectedRange:i}),s=$ui.popover({sourceView:e,directions:$popoverDirection.up,size:$size(200,300),views:[this.kernel.actionManager.getActionListView((e=>{s.dismiss(),$delay(.5,(()=>e(r)))}))]})}}}setContent(e){this.text=e,$(this.id).text=e}getView(e="text"){return{type:e,layout:$layout.fill,props:{id:this.id,lineNumbers:this.kernel.setting.get("editor.code.lineNumbers"),theme:this.kernel.setting.get($device.isDarkMode?"editor.code.darkTheme":"editor.code.lightTheme"),text:this.text,insets:$insets(15,15,"text"===e?this.kernel.setting.get("editor.text.insets"):15,15)},events:{ready:e=>{""===this.text&&setTimeout((()=>e.focus()),500)},didChange:e=>{this.text=e.text}}}}pageSheet(e="",t,i,r=[],s="text"){this.text=e,r.unshift(this.getActionButton());const a=new n;a.setView(this.getView(s)).addNavBar({title:i,popButton:{title:$l10n("DONE"),tapped:()=>t(this.text)},rightButtons:r}),a.navigationView.navigationBar.contentViewHeightOffset=0,a.init().present()}uikitPush(e="",t,i=[],s="text"){this.text=e,i.unshift(this.getActionButton()),r.push({title:"",navButtons:i.map((e=>(e.handler=e.tapped,e.tapped=void 0,e))),views:[this.getView(s)],disappeared:()=>t(this.text)})}getNavigationView(e="",t,i=[],r="text"){this.text=e,i.unshift(this.getActionButton());const n=new a;return n.navigationBar.contentViewHeightOffset=0,n.navigationBar.setLargeTitleDisplayMode(s.largeTitleDisplayModeNever),n.navigationBarItems.setRightButtons(i),n.setView(this.getView(r)).navigationBarTitle(""),n.setEvent("onPop",(()=>t(this.text))),n}}})),parcelRequire.register("eSp9Z",(function(e,t){var i=parcelRequire("gxpqj"),r=i.Kernel,s=i.Sheet;class a{static keyboard=0;static today=0;static editor=1;static clipboard=2;static action=3}e.exports={ActionEnv:a,ActionData:class{env;args;text;originalContent;uuid;selectedRange;textBeforeInput;textAfterInput;editor;constructor({env:e,args:t,text:i,uuid:r=null,selectedRange:s=null,textBeforeInput:a=null,textAfterInput:n=null,editor:o=null}={}){this.env=e,this.args=t,this.text=i,this.originalContent=i,this.uuid=r,this.selectedRange=s,this.textBeforeInput=a,this.textAfterInput=n,this.editor=o}},Action:class{#X;constructor(e,t,i){this.#X=e,this.config=t,Object.assign(this,i),this.originalContent=this.text;const s=this.l10n();Object.keys(s).forEach((e=>{r.l10n(e,s[e])}))}l10n(){return{}}pageSheet({view:e,title:t="",done:i,doneText:r=$l10n("DONE"),rightButtons:a=[]}){(new s).setView(e).addNavBar({title:t,popButton:{title:r,tapped:()=>{i&&i()}},rightButtons:a}).init().present()}getAllClips(){return{favorite:this.#X.storage.all("favorite").map((e=>e.text)),clips:this.#X.storage.all("clips").map((e=>e.text))}}async clearAllClips(){if(0!==(await $ui.alert({title:$l10n("DELETE_DATA"),message:$l10n("DELETE_TABLE").replace("${table}",$l10n("CLIPS")),actions:[{title:$l10n("DELETE"),style:$alertActionType.destructive},{title:$l10n("CANCEL")}]})).index)return!1;try{return this.#X.storage.deleteTable("clips"),!0}catch(e){throw this.#X.error(e),e}}setContent(e){this.text=e,this.env===a.editor&&this.editor.setContent(e)}getAction(e,t,i){return this.#X.actionManager.getAction(e,t,i)}async runAction(e,t){const i=this.getAction(e,t);return await i.do()}async request(e,t,i={},r={}){try{this.#X.print(`sending request [${t}]: ${e}`);const s=await $http.request({header:r,url:e,method:t,body:i,timeout:5});if(s.error)throw s.error;if(s?.response?.statusCode>=400){let e=s.data;throw"object"==typeof e&&(e=JSON.stringify(e)),new Error("http error: ["+s.response.statusCode+"] "+e)}return s}catch(e){throw e.code&&(e=new Error("network error: ["+e.code+"] "+e.localizedDescription)),e}}getUrls(){return(this.text??"").match(/(https?:\/\/)([\da-z\.-]+)\.([a-z\.]{2,6})([:0-9])*([\/\w\#\.\-\?\=\&])*\s?/gi)??[]}}}})),parcelRequire.register("ZnuTV",(function(e,t){var i=parcelRequire("gxpqj").UIKit;e.exports=class{kernel;pasteboard=$objc("UIPasteboard").$generalPasteboard();#Q=[];savedClipboardIndex={};tabItems=[$l10n("FAVORITE"),$l10n("CLIPS")];tabItemsIndex=["favorite","clips"];constructor(e){this.kernel=e}set tabIndex(e){$cache.set("caio.main.tab.index",e)}get tabIndex(){return $cache.get("caio.main.tab.index")??0}get table(){return this.tabItemsIndex[this.tabIndex]}get tableL10n(){return this.tabItems[this.tabIndex]}get allClips(){return 0===this.#Q.length&&this.loadAllClips(),this.#Q}set allClips(e){this.#Q=e.map((e=>new Proxy(e??[],{set:(e,t,i)=>Reflect.set(e,t,i),get:(e,t)=>Reflect.get(e,t)})))}get clips(){return this.allClips[this.tabIndex]}get isChanged(){const e=this.pasteboard.$changeCount(),t=$cache.get("clipboard.changeCount");return $cache.set("clipboard.changeCount",e),t!==e}getRowByUUID(e){let t=this.clips.length;for(let i=0;i{const i=JSON.parse(JSON.stringify(e));return Object.assign(i,t)},r=this.table;this.clips[t]||(this.clips[t]={uuid:null,text:"",next:null,prev:this.clips[t-1].uuid});try{this.kernel.storage.beginTransaction();const s=i(this.clips[e]),a=i(this.clips[t]);if(this.clips[e-1]){const t=i(this.clips[e-1],{next:this.clips[e].next});this.kernel.storage.update(r,t),this.clips[e-1]=t}if(this.clips[e+1]){const t=i(this.clips[e+1],{prev:this.clips[e].prev});this.kernel.storage.update(r,t),this.clips[e+1]=t}if(this.clips[t-1]){const s=i(this.clips[t-1],{next:this.clips[e].uuid});this.kernel.storage.update(r,s),this.clips[t-1]=s}const n=i(a,{prev:s.uuid,next:this.clips[t].next});this.kernel.storage.update(r,n);const o=i(s,{prev:this.clips[t].prev,next:a.uuid});this.kernel.storage.update(r,o),this.clips[t]=n,this.clips[e]=o,this.clips.splice(t,0,this.clips[e]),this.clips.splice(e>t?e+1:e,1),this.kernel.storage.commit()}catch(e){throw this.kernel.error(e),this.kernel.storage.rollback(),e}finally{null===this.clips[t].uuid&&this.clips.splice(t,1)}}favorite(e,t){e.next=this.allClips[0][0]?.uuid??null,e.prev=null;try{this.kernel.storage.beginTransaction(),this.kernel.storage.insert("favorite",e),e.next&&(this.allClips[0][0].prev=e.uuid,this.kernel.storage.update("favorite",this.allClips[0][0])),this.kernel.storage.commit(),"favorite"!==e?.section&&(e.section="favorite",this.delete(e.uuid,t)),this.allClips[0].unshift(e),this.savedClipboardIndex[e.md5]=1}catch(e){throw this.kernel.error(e),this.kernel.storage.rollback(),e}}loadAllClips(){this.kernel.print("load all clips");const e=e=>{try{return this.kernel.storage.sort(e,this.kernel.setting.get("clipboard.maxItemLength")).map((e=>(this.savedClipboardIndex[e.md5]=1,e)))}catch(e){$ui.alert({title:$l10n("REBUILD_DATABASE"),message:$l10n("CLIPS_STRUCTURE_ERROR"),actions:[{title:$l10n("OK"),handler:()=>{const e=i.loading();e.start(),this.kernel.storage.rebuild(),e.end(),$delay(.8,(()=>$addin.restart()))}},{title:$l10n("CANCEL")}]}),this.kernel.error(e)}};this.allClips=[e(this.kernel.storage.all(this.tabItemsIndex[0])),e(this.kernel.storage.all(this.tabItemsIndex[1]))]}}})),parcelRequire.register("ay4Kj",(function(e,t){var i=parcelRequire("gxpqj"),r=i.UIKit,s=i.SearchBar;e.exports=class{listId="clips-list-search";kernel;callback=()=>{};onBegin=()=>{};onDismiss=()=>{};constructor(e){this.kernel=e,this.searchBar=new s,this.searchBarId=this.searchBar.id+"-input"}get searchHistoryView(){return{hide:()=>$(this.listId+"-history").hidden=!0,show:()=>$(this.listId+"-history").hidden=!1}}get searchHistory(){return[{title:$l10n("SEARCH_HISTORY"),rows:$cache.get("caio.search.history")?.reverse()??[]}]}getAccessoryView(){return r.blurBox({height:50},[{type:"button",props:{bgcolor:$color("clear"),tintColor:$color("primaryText"),symbol:"xmark.circle"},layout:(e,t)=>{e.right.inset(0),e.height.equalTo(t.super),e.width.equalTo(t.super.height)},events:{tapped:()=>this.dismiss()}},{type:"button",props:{bgcolor:$color("clear"),tintColor:$color("primaryText"),symbol:"keyboard.chevron.compact.down"},layout:(e,t)=>{e.right.equalTo(t.prev.left),e.height.equalTo(t.super),e.width.equalTo(t.super.height)},events:{tapped:()=>$(this.searchBarId).blur()}}])}getSearchHistoryView(){return{type:"list",props:{id:this.listId+"-history",hidden:!0,stickyHeader:!0,data:this.searchHistory,separatorInset:$insets(0,13,0,0),actions:[{title:$l10n("DELETE"),handler:(e,t)=>{const i=e.data;this.updateSearchHistory(i[0].rows.reverse())}}]},events:{didSelect:(e,t,i)=>{this.searchAction(i),$(this.searchBarId).text=i}},layout:$layout.fill}}setCallback(e){this.callback=e}setOnBegin(e){this.onBegin=e}setOnDismiss(e){this.onDismiss=e}begin(){this.searchHistoryView.show(),this.onBegin()}dismiss(){$(this.searchBarId).blur(),$(this.searchBarId).text="",this.searchHistoryView.hide(),this.onDismiss()}searchAction(e){try{if(""!==e){const t=this.kernel.storage.search(e);t&&t.length>0?($(this.searchBarId).blur(),this.callback(t)):$ui.toast($l10n("NO_SEARCH_RESULT")),this.pushSearchHistory(e)}}catch(e){throw e}}pushSearchHistory(e){let t=$cache.get("caio.search.history")??[];-1===t.indexOf(e)&&(t.push(e),t.length>20&&(t=t.slice(-20)),$(this.listId+"-history").data=this.searchHistory,$cache.set("caio.search.history",t))}updateSearchHistory(e=[]){$cache.set("caio.search.history",e)}getSearchBarView(){return this.searchBar.controller.setEvent("onReturn",(e=>{""!==e?this.searchAction(e):this.searchHistoryView.show()})),this.searchBar.controller.setEvent("onChange",(e=>{""===e&&this.searchHistoryView.show()})),this.searchBar.setEvent("didBeginEditing",(e=>{""===e.text&&this.begin()})),this.searchBar.setAccessoryView(this.getAccessoryView()),this.searchBar}}})),parcelRequire.register("9LqeL",(function(e,t){var i=parcelRequire("gxpqj"),r=i.View,s=i.UIKit,a=i.Sheet;class n{static symbol={selected:"checkmark.circle.fill",unselected:"circle"};listId="clips-list-editor";reorder={};toolBarHeight=44;#Z=void 0;#ee={};constructor(e){this.clipsInstance=e,this.kernel=e.kernel}get editorSelectedIsEmpty(){let e=!0;const t=this.editorSelected;for(const i of Object.keys(t))if(t[i]){e=!1;break}return e}get editorSelectedIsFull(){let e=0,t=0;const i=this.editorSelected;for(const r of Object.keys(i))++t,i[r]&&++e;return t===e}get editorSelected(){return void 0===this.#Z&&(Array(this.clipsInstance.clips.length).fill(0).map(((e,t)=>this.#ee[t]=!1)),this.#Z=new Proxy(this.#ee,{set:(e,t,i,r)=>{Reflect.set(e,t,i,r),t=Number(t);const s=this.editorSelectedIsEmpty,a=$(this.listId+"-select-button"),o=$(this.listId+"-delete-button");a.title=this.editorSelectedIsFull?$l10n("DESELECT_ALL"):$l10n("SELECT_ALL"),o.hidden=s;const l=$(this.listId);return l.data=this.clipsInstance.clips.map(((t,i)=>{const r=this.lineData(t);return r.checkmark={symbol:e[i]?n.symbol.selected:n.symbol.unselected},r})),l.reorder=s,!0}})),this.#Z}set editorSelected(e){this.#Z=e}selectAll(){const e=this.editorSelectedIsFull;this.clipsInstance.clips.forEach(((t,i)=>{this.editorSelected[i]=!e}))}deleteSelected(){this.kernel.deleteConfirm($l10n("CONFIRM_DELETE_MSG"),(()=>{const e=$(this.listId),t=$(this.clipsInstance.listId);Object.keys(this.editorSelected).reverse().forEach((i=>{if(this.editorSelected[i]){i=Number(i);const r=this.clipsInstance.clips[i];this.kernel.print(`delete selected: [${i}]\n${r.text}`),this.clipsInstance.delete(r.uuid,i),t.delete(i),e.delete(i)}}))}))}getToolBarView(){return s.blurBox({},[s.separatorLine(),{type:"view",views:[{type:"button",props:{id:this.listId+"-select-button",title:$l10n("SELECT_ALL"),titleColor:$color("tint"),bgcolor:$color("clear")},layout:(e,t)=>{e.left.inset(this.clipsInstance.horizontalMargin),e.centerY.equalTo(t.super)},events:{tapped:()=>this.selectAll()}},{type:"button",props:{id:this.listId+"-delete-button",symbol:"trash",hidden:!0,tintColor:$color("red"),bgcolor:$color("clear")},layout:(e,t)=>{e.right.inset(this.clipsInstance.horizontalMargin),e.centerY.equalTo(t.super)},events:{tapped:()=>this.deleteSelected()}}],layout:(e,t)=>{e.left.right.top.equalTo(t.super),e.bottom.equalTo(t.super.safeAreaBottom)}}],((e,t)=>{e.left.right.bottom.equalTo(t.super),e.top.equalTo(t.super.safeAreaBottom).offset(-this.toolBarHeight)}))}lineData(e){const t=this.clipsInstance.lineData(e);return t.checkmark={symbol:n.symbol.unselected},t}listTemplate(){const e=this.clipsInstance.listTemplate();return e.views[0].layout=(e,t)=>{e.height.right.equalTo(t.super),e.left.inset(30)},e.views.push({type:"image",props:{id:"checkmark",symbol:n.symbol.unselected,contentMode:$contentMode.scaleAspectFit},layout:(e,t)=>{e.centerY.equalTo(t.super),e.left.inset(15),e.size.equalTo($size(25,25))}}),e}getListEditerView(){return{type:"list",props:{id:this.listId,bgcolor:s.primaryViewBackgroundColor,separatorInset:$insets(0,this.clipsInstance.horizontalMargin,0,0),indicatorInsets:$insets(0,0,this.toolBarHeight,0),data:this.clipsInstance.clips.map((e=>this.lineData(e))),template:this.listTemplate(),reorder:!0,footer:{height:this.toolBarHeight},crossSections:!1},events:{rowHeight:(e,t)=>{const i=this.clipsInstance.clips[t.row].text;return(this.kernel.storage.isImage(i)?this.imageContentHeight:this.clipsInstance.getTextHeight(i))+2*this.clipsInstance.verticalMargin},reorderBegan:e=>{this.reorder.began=!0,this.reorder.from=e.row,this.reorder.to=void 0},reorderMoved:(e,t)=>{this.reorder.to=t.row},reorderFinished:()=>{this.reorder.began=!1,void 0!==this.reorder.to&&this.clipsInstance.move(this.reorder.from,this.reorder.to)},didSelect:(e,t,i)=>{this.editorSelected[t.row]=!this.editorSelected[t.row]}},layout:$layout.fill}}presentSheet(){const e=new a;e.setView(r.createFromViews([this.getListEditerView(),this.getToolBarView()])).addNavBar({title:"",popButton:{title:$l10n("CLOSE")},rightButtons:[{title:$l10n("CLEAR"),color:$color("red"),tapped:async()=>{if(0===(await $ui.alert({title:$l10n("DELETE_DATA"),message:$l10n("DELETE_TABLE").replace("${table}",this.clipsInstance.tableL10n),actions:[{title:$l10n("DELETE"),style:$alertActionType.destructive},{title:$l10n("CANCEL")}]})).index)try{this.kernel.storage.deleteTable(this.clipsInstance.table),e.dismiss(),this.clipsInstance.updateList(!0)}catch(e){this.kernel.error(e),$ui.error(e)}}}]}).init().present()}}e.exports=n})),parcelRequire.register("44eiF",(function(e,t){var i=parcelRequire("gxpqj"),r=i.Matrix,s=i.Setting,a=i.NavigationView,n=i.BarButtonItem,o=i.Sheet,l=i.UIKit,c=parcelRequire("f0nX9"),h=parcelRequire("47XCm"),d=parcelRequire("eSp9Z"),p=d.ActionEnv,u=d.ActionData;e.exports=class extends h{matrix;reorder={};addActionButtonId="action-manager-button-add";syncLabelId="action-manager-sync-label";get actionList(){return super.actions.map((e=>{const t=[];return e.items.forEach((e=>{t.push(this.actionToData(e))})),{title:e.title,items:t,rows:t}}))}actionSyncStatus(){$app.listen({actionSyncStatus:e=>{if(e.status===h.syncStatus.syncing)this.undateAddActionButton(!0),this.undateSyncLabel($l10n("SYNCING"));else if(e.status===h.syncStatus.success)try{this.matrix.update(this.actionList)}catch(e){this.kernel.error(e),this.undateSyncLabel(e),$ui.error(e)}finally{this.undateSyncLabel(),this.undateAddActionButton(!1)}}})}editActionInfoPageSheet(e,t){const i=this.getActionTypes(),r={};i.forEach(((e,t)=>{r[e]=t}));const a=!Boolean(e);a?this.editingActionInfo={type:"clipboard",name:"MyAction",color:"#CC00CC",icon:"icon_062.png",readme:""}:(this.editingActionInfo=e,this.editingActionInfo.readme=this.getActionReadme(e.type,e.dir));const n=new s({structure:{},set:(e,t)=>(this.editingActionInfo[e]="type"===e?t[1]:t,!0),get:(e,t=null)=>"type"===e?r[this.editingActionInfo.type]:Object.prototype.hasOwnProperty.call(this.editingActionInfo,e)?this.editingActionInfo[e]:t}),l=n.createInput("name",["pencil.circle","#FF3366"],$l10n("NAME")),c=n.createColor("color",["pencil.tip.crop.circle","#0066CC"],$l10n("COLOR")),h=n.createIcon("icon",["star.circle","#FF9933"],$l10n("ICON"),this.kernel.setting.getColor(this.editingActionInfo.color)),d=n.createMenu("type",["tag.circle","#33CC33"],$l10n("TYPE"),i,!0),p={type:"view",views:[{type:"text",props:{id:"action-text",textColor:$color("#000000","secondaryText"),bgcolor:$color("systemBackground"),text:this.editingActionInfo.readme,insets:$insets(10,10,10,10)},layout:$layout.fill,events:{tapped:e=>{$("actionInfoPageSheetList").scrollToOffset($point(0,a?280:230)),$delay(.2,(()=>e.focus()))},didChange:e=>{this.editingActionInfo.readme=e.text}}}],layout:$layout.fill},u=[{title:$l10n("INFORMATION"),rows:[l,c,h]},{title:$l10n("DESCRIPTION"),rows:[p]}];a&&(u[0].rows=u[0].rows.concat(d));(new o).setView({type:"list",props:{id:"actionInfoPageSheetList",bgcolor:$color("insetGroupedBackground"),style:2,separatorInset:$insets(0,50,0,10),data:u},layout:$layout.fill,events:{rowHeight:(e,t)=>1===t.section?120:50}}).addNavBar({title:"",popButton:{title:$l10n("DONE"),tapped:()=>{this.editingActionInfo.dir||(this.editingActionInfo.dir=$text.MD5(this.editingActionInfo.name)),this.saveActionInfo(this.editingActionInfo),t&&t(this.editingActionInfo)}}}).init().present()}editActionMainJs(e="",t){new c(this.kernel).pageSheet(e,(e=>{this.saveMainJs(t,e)}),t.name,[{symbol:"book.circle",tapped:()=>{const e=$file.read("scripts/action/README.md").string;(new o).setView({type:"markdown",props:{content:e},layout:(e,t)=>{e.size.equalTo(t.super)}}).init().present()}}],"code")}move(e,t){if(e.section===t.section&&e.row===t.row)return;super.move(e,t);const i=this.matrix,r=this.actionToData(this.actions[t.section].items[t.row]);e.row{const i=e.cell(t),r=i.get("info").info;this.editActionInfoPageSheet(r,(e=>{i.get("info").info=e,i.get("color").bgcolor=this.kernel.setting.getColor(e.color),i.get("name").text=e.name,"icon_"===e.icon.slice(0,5)?i.get("icon").icon=$icon(e.icon.slice(5,e.icon.indexOf(".")),$color("#ffffff")):i.get("icon").image=$image(e.icon)}))}},{title:$l10n("EDIT_SCRIPT"),symbol:"square.and.pencil",handler:(e,t,i)=>{const r=i.info.info;if(!r)return;const s=`${this.userActionPath}/${r.type}/${r.dir}/main.js`,a=$file.read(s).string;this.editActionMainJs(a,r)}},{inline:!0,items:[{title:"README",symbol:"book",handler:(e,t)=>{const i=e.cell(t).get("info").info;let r;try{r=__ACTIONS__[i.type][i.dir]["README.md"]}catch{r=this.getActionReadme(i.type,i.dir)}(new o).setView({type:"markdown",props:{content:r},layout:(e,t)=>{e.size.equalTo(t.super)}}).init().present()}}]},{inline:!0,items:[{title:$l10n("DELETE"),symbol:"trash",destructive:!0,handler:(e,t,i)=>{this.kernel.deleteConfirm($l10n("CONFIRM_DELETE_MSG"),(()=>{this.delete(i.info.info),e.delete(t)}))}}]}]}getNavButtons(){return[{symbol:"plus.circle",id:this.addActionButtonId,menu:{pullDown:!0,asPrimary:!0,items:[{title:$l10n("CREATE_NEW_ACTION"),handler:()=>{this.editActionInfoPageSheet(null,(e=>{this.matrix.insert({indexPath:$indexPath(this.getActionTypes().indexOf(e.type),0),value:this.actionToData(e)});const t=$file.read(`${this.actionPath}/template.js`).string;this.saveMainJs(e,t),this.editActionMainJs(t,e)}))}},{title:$l10n("CREATE_NEW_TYPE"),handler:()=>{$input.text({text:"",placeholder:$l10n("CREATE_NEW_TYPE"),handler:e=>{if(""===(e=e.trim()))return void $ui.toast($l10n("INVALID_VALUE"));const t=`${this.userActionPath}/${e}`;$file.isDirectory(t)?$ui.warning($l10n("TYPE_ALREADY_EXISTS")):($file.mkdir(t),$ui.success($l10n("SUCCESS")))}})}}]}},{symbol:"arrow.up.arrow.down.circle",tapped:(e,t)=>{$ui.popover({sourceView:t,directions:$popoverDirection.up,size:$size(200,300),views:[this.getActionListView(void 0,{reorder:!0,actions:[{title:"delete",handler:(e,t)=>{const i=this.matrix,r=i.object(t,!1).info.info;this.delete(r),i.delete(t,!1)}}]},{reorderBegan:e=>{this.reorder.from=e,this.reorder.to=void 0},reorderMoved:(e,t)=>{this.reorder.to=t},reorderFinished:e=>{void 0!==this.reorder.to&&this.move(this.reorder.from,this.reorder.to,e)}})]})}}]}actionToData(e){return{name:{text:e.name},icon:"icon_"===e.icon.slice(0,5)?{icon:$icon(e.icon.slice(5,e.icon.indexOf(".")),$color("#ffffff"))}:{image:$image(e.icon)},color:{bgcolor:this.kernel.setting.getColor(e.color)},info:{info:e}}}undateSyncLabel(e){e||(e=$l10n("LAST_SYNC_AT")+this.getSyncDate().toLocaleString()),$(this.syncLabelId)&&($(this.syncLabelId).text=e)}undateAddActionButton(e){const t=this.navigationView?.navigationBarItems?.getButton(this.addActionButtonId)??{};t&&t.setLoading(e)}getActionListView(e,t={},i={}){return e&&(i.didSelect=(t,i,r)=>{const s=r.info.info,a=this.kernel.actionManager.getActionHandler(s.type,s.dir);e(a)}),{type:"list",layout:(e,t)=>{e.top.width.equalTo(t.super.safeArea),e.bottom.inset(0)},events:i,props:Object.assign({reorder:!1,bgcolor:$color("clear"),rowHeight:60,sectionTitleHeight:30,stickyHeader:!0,data:this.actionList,template:{props:{bgcolor:$color("clear")},views:[{type:"image",props:{id:"color",cornerRadius:8,smoothCorners:!0},layout:(e,t)=>{e.centerY.equalTo(t.super),e.left.inset(15),e.size.equalTo($size(30,30))}},{type:"image",props:{id:"icon",tintColor:$color("#ffffff")},layout:(e,t)=>{e.centerY.equalTo(t.super),e.left.inset(20),e.size.equalTo($size(20,20))}},{type:"label",props:{id:"name",lines:1,font:$font(16)},layout:(e,t)=>{e.height.equalTo(30),e.centerY.equalTo(t.super),e.left.equalTo(t.prev.right).offset(15)}},{type:"label",props:{id:"info"}}]}},t)}}getMatrixView({columns:e=2,spacing:t=15,itemHeight:i=100}={}){return this.matrix=r.create({type:"matrix",props:{columns:e,itemHeight:i,spacing:t,bgcolor:l.scrollViewBackgroundColor,menu:{items:this.menuItems()},data:this.actionList,template:{props:{smoothCorners:!0,cornerRadius:10,bgcolor:$color("#ffffff","#242424")},views:[{type:"image",props:{id:"color",cornerRadius:8,smoothCorners:!0},layout:e=>{e.top.left.inset(10),e.size.equalTo($size(30,30))}},{type:"image",props:{id:"icon",tintColor:$color("#ffffff")},layout:e=>{e.top.left.inset(15),e.size.equalTo($size(20,20))}},{type:"button",props:{bgcolor:$color("clear"),tintColor:l.textColor,titleColor:l.textColor,contentEdgeInsets:$insets(0,0,0,0),titleEdgeInsets:$insets(0,0,0,0),imageEdgeInsets:$insets(0,0,0,0)},views:[{type:"image",props:{symbol:"ellipsis.circle"},layout:(e,t)=>{e.center.equalTo(t.super),e.size.equalTo(n.style.iconSize)}}],events:{tapped:e=>{const t=e.next.info;if(!t)return;const i=`${this.userActionPath}/${t.type}/${t.dir}/main.js`,r=$file.read(i).string;this.editActionMainJs(r,t)}},layout:e=>{e.top.right.inset(0),e.size.equalTo(n.style.width)}},{type:"view",props:{id:"info",hidden:!0}},{type:"label",props:{id:"name",font:$font(16)},layout:(e,t)=>{e.bottom.left.inset(10),e.width.equalTo(t.super)}}]},footer:{type:"view",props:{hidden:!this.kernel.setting.get("experimental.syncAction"),height:this.kernel.setting.get("experimental.syncAction")?50:0},views:[{type:"label",props:{id:this.syncLabelId,color:$color("secondaryText"),font:$font(12),text:$l10n("LAST_SYNC_AT")+this.getSyncDate().toLocaleString()},layout:(e,i)=>{e.size.equalTo(i.super),e.top.inset(-30),e.left.inset(t)}}]}},layout:$layout.fill,events:{didSelect:(e,t,i)=>{const r=i.info.info,s=new u({env:p.action,text:"clipboard"===r.type||"uncategorized"===r.type?$clipboard.text:null});this.getActionHandler(r.type,r.dir)(s)},pulled:e=>{$delay(.5,(async()=>{this.undateAddActionButton(!0),await this.sync(),this.actionsNeedReload(),this.matrix.update(this.actionList),this.undateSyncLabel(),this.undateAddActionButton(!1),e.endRefreshing()}))}}}),this.actionSyncStatus(),this.matrix.definition}getPage(){return this.navigationView=new a,this.navigationView.navigationBarItems.setRightButtons(this.getNavButtons()),this.navigationView.setView(this.getMatrixView()).navigationBarTitle($l10n("ACTIONS")),this.navigationView.getPage()}present(){const e=new o,t=this.getNavButtons();this.kernel.setting.get("experimental.syncAction")&&t.push({symbol:"arrow.up.arrow.down.circle",tapped:async(e,t)=>{e.actionStart(),this.undateAddActionButton(!0),await this.sync(),this.actionsNeedReload(),this.matrix.update(this.actionList),this.undateSyncLabel(),e.actionDone(),this.undateAddActionButton(!1)}}),e.setView(this.getMatrixView()).addNavBar({title:$l10n("ACTIONS"),popButton:{symbol:"xmark.circle"},rightButtons:t}).init().present()}}})),parcelRequire.register("47XCm",(function(e,t){var i=parcelRequire("eSp9Z"),r=i.ActionEnv,s=i.ActionData,a=i.Action;class n{static syncStatus={syncing:0,success:1};#te=3;#ie=!1;#re;constructor(e){this.kernel=e,this.actionPath="scripts/action",this.actionOrderFile="order.json",this.tempPath=`${this.kernel.fileStorage.basePath}/temp`,this.userActionPath=`${this.kernel.fileStorage.basePath}/user_action`,this.localSyncFile=this.userActionPath+"/data.json",this.iCloudPath="drive://CAIO/user_action",this.iCloudSyncFile=this.iCloudPath+"/data.json",this.iCloudSyncFileUndownloaded=this.iCloudPath+"/.data.json.icloud",this.typeNameMap={},this.checkUserAction(),$thread.background({delay:this.#te,handler:()=>this.sync(!0)})}get actions(){return this.#re||(this.#re=this.getActionTypes().map((e=>({title:this.getTypeName(e),items:this.getActions(e)})))),this.#re}actionsNeedReload(e=!1){this.#re=void 0,e&&$file.write({data:$data({string:JSON.stringify({date:Date.now()})}),path:this.localSyncFile})}importExampleAction(){try{Object.keys(__ACTIONS__).forEach((e=>{const t=`${this.userActionPath}/${e}`;Object.keys(__ACTIONS__[e]).forEach((i=>{$file.exists(`${t}/${i}/main.js`)||($file.mkdir(t),$file.mkdir(`${t}/${i}`),$file.write({data:$data({string:__ACTIONS__[e][i]["main.js"]}),path:`${t}/${i}/main.js`}),$file.write({data:$data({string:__ACTIONS__[e][i]["config.json"]}),path:`${t}/${i}/config.json`}),$file.write({data:$data({string:__ACTIONS__[e][i]["README.md"]}),path:`${t}/${i}/README.md`}))}))}))}catch{$file.list(this.actionPath).forEach((e=>{const t=`${this.actionPath}/${e}`;if($file.isDirectory(t)){const i=`${this.userActionPath}/${e}`;$file.list(t).forEach((e=>{$file.exists(`${i}/${e}/main.js`)||($file.mkdir(i),$file.copy({src:`${t}/${e}`,dst:`${i}/${e}`}))}))}}))}}#se(e=""){if(e=e.trim("/"),!$file.exists(e)){const t=e.lastIndexOf("/");if(-1!==t){const i=e.substring(0,t);this.#se(i)}$file.mkdir(e)}}async downloadFiles(e){const t=$file.list(e);for(let i=0;ithis.sync(e)}));let t;this.#ie=!0,this.checkSyncData(),t=$file.exists(this.iCloudSyncFileUndownloaded)?await $file.download(this.iCloudSyncFileUndownloaded):$file.read(this.iCloudSyncFile),t=JSON.parse(t);const i=JSON.parse($file.read(this.localSyncFile).string);if(i.datet.date&&($file.write({data:$data({string:JSON.stringify({date:i.date})}),path:this.iCloudSyncFile}),await $wait(this.#te),$app.notify({name:"actionSyncStatus",object:{status:n.syncStatus.success}}));this.#ie=!1,e&&$thread.background({delay:this.#te,handler:()=>this.sync(e)})}checkUserAction(){$file.exists(this.userActionPath)&&0!==$file.list(this.userActionPath).length||($file.mkdir(this.userActionPath),this.importExampleAction()),$file.exists(this.iCloudPath)&&0!==$file.list(this.iCloudPath).length||($file.mkdir(this.iCloudPath),$file.copy({src:this.userActionPath,dst:this.iCloudPath}))}getActionTypes(){const e=["clipboard","editor"];return e.concat($file.list(this.userActionPath).filter((t=>{if($file.isDirectory(`${this.userActionPath}/${t}`)&&e.indexOf(t)<0)return t})))}getActionOrder(e){const t=`${this.userActionPath}/${e}/${this.actionOrderFile}`;return $file.exists(t)?JSON.parse($file.read(t).string):[]}getActionPath(e,t){return`${this.userActionPath}/${e}/${t}`}getActionConfig(e,t){return JSON.parse($file.read(`${this.getActionPath(e,t)}/config.json`).string)}getActionReadme(e,t){return $file.read(`${this.getActionPath(e,t)}/README.md`).string}getAction(e,t,i){const n=this.getActionPath(e,t),o=this.getActionConfig(e,t);try{const e=$file.read(`${n}/main.js`).string,t=new Function("Action","ActionEnv","ActionData",`${e}\n return MyAction`)(a,r,s);return new t(this.kernel,o,i)}catch(e){$ui.error(e),this.kernel.error(e)}}getActionHandler(e,t){return async i=>{try{const r=this.getAction(e,t,i);return await r.do()}catch(e){$ui.error(e),this.kernel.error(e)}}}getActions(e){const t=[],i=`${this.userActionPath}/${e}`;if(!$file.exists(i))return[];const r=r=>{const s=`${i}/${r}/`;if($file.isDirectory(s)){const i=this.getActionConfig(e,r);t.push(Object.assign(i,{dir:r,type:e,name:i.name??r,icon:i.icon,color:i.color}))}},s=this.getActionOrder(e);return s.forEach((e=>r(e))),$file.list(i).forEach((e=>{-1===s.indexOf(e)&&r(e)})),t}getTypeName(e){const t=e.toUpperCase(),i=$l10n(t),r=i===t?e:i;return this.typeNameMap[r]=e,r}getTypeDir(e){return this.typeNameMap[e]??e}#ae(e,t,i,r){"string"!=typeof r&&(r=JSON.stringify(r));const s=`${this.userActionPath}/${e}/${t}`;if($file.exists(s)||$file.mkdir(s),r===$file.read(`${s}/${i}`)?.string)return;$file.write({data:$data({string:r}),path:`${s}/${i}`});const a=`${this.iCloudPath}/${e}/${t}`;$file.exists(a)||$file.mkdir(a),$file.write({data:$data({string:r}),path:`${a}/${i}`})}saveActionInfo(e){this.#ae(e.type,e.dir,"config.json",{icon:e.icon,color:e.color,name:e.name}),this.#ae(e.type,e.dir,"README.md",e.readme),this.actionsNeedReload(!0)}saveMainJs(e,t){this.#ae(e.type,e.dir,"main.js",t)}saveOrder(e,t){$file.write({data:$data({string:JSON.stringify(t)}),path:`${this.userActionPath}/${e}/${this.actionOrderFile}`}),$file.write({data:$data({string:JSON.stringify(t)}),path:`${this.iCloudPath}/${e}/${this.actionOrderFile}`}),this.actionsNeedReload(!0)}move(e,t){if(e.section===t.section&&e.row===t.row)return;const i=this.actions[e.section],r=i.items,s=this.getTypeDir(i.title),a=e=>e.map((e=>e.dir));if(e.section===t.section)r.splice(e.rowt.row?e.row+1:e.row,1),this.saveOrder(s,a(r));else{const i=this.actions[t.section],n=i.items,o=this.getTypeDir(i.title);n.splice(t.row,0,r[e.row]),r.splice(e.row,1),this.saveOrder(o,a(n)),this.saveOrder(s,a(r)),$file.move({src:`${this.userActionPath}/${s}/${n[t.row].dir}`,dst:`${this.userActionPath}/${o}/${n[t.row].dir}`}),$file.move({src:`${this.iCloudPath}/${s}/${n[t.row].dir}`,dst:`${this.iCloudPath}/${o}/${n[t.row].dir}`})}this.actionsNeedReload(!0)}delete(e){$file.delete(`${this.userActionPath}/${e.type}/${e.dir}`),$file.delete(`${this.iCloudPath}/${e.type}/${e.dir}`),this.actionsNeedReload(!0)}}e.exports=n})),parcelRequire.register("gYDdO",(function(e,t){function i(e,t=[]){t.forEach((t=>{$file.exists(t)&&(e.print(`delete file: ${t}`),$file.delete(t))}))}function r(e,t,i){const r=e.storage.sqlite.query(`SELECT count(*), name FROM sqlite_master WHERE type = "table" AND name = "${t}"`);if(null!==r.error)throw new Error(`Code [${r.error.code}] ${r.error.domain} ${r.error.localizedDescription}`);r.result.next();const s=r.result.get(0);r.result.close(),s>0&&(e.print(`copy data from old table: ${t}`),e.storage.sqlite.update(`INSERT INTO ${i} SELECT * FROM ${t}`),e.print(`drop table: ${t}`),e.storage.sqlite.update(`DROP TABLE ${t}`))}async function s(e,t={}){const i="scripts/action",r=`${e.fileStorage.basePath}/user_action`,s=[];for(let e of Object.keys(t))t[e].forEach((t=>{const r=JSON.parse($file.read(`${i}/${e}/${t}/config.json`).string);s.push(r.name)}));if(1!==(await $ui.alert({title:$l10n("compatibility.rebuildUserAction.alert.title"),message:$l10n("compatibility.rebuildUserAction.alert.message")+"\n"+JSON.stringify(s,null,2)+"\n"+$l10n("compatibility.rebuildUserAction.alert.message2"),actions:[{title:$l10n("OK")},{title:$l10n("CANCEL")}]})).index)for(let s of Object.keys(t))t[s].forEach((t=>{$file.exists(`${r}/${s}/${t}`)&&(e.print(`rebuild user action: ${s}/${t}`),$file.copy({src:`${i}/${s}/${t}/main.js`,dst:`${r}/${s}/${t}/main.js`}))}))}e.exports=async function(e){if(!e)return;const t=$cache.get("compatibility.version")??0;try{t<1&&(e.print(`compatibility: userVersion [${t}] lower than [1], start action`),await async function(e){i(e,["scripts/action/clipboard/ClearClipboard","scripts/ui/clipboard.js","scripts/ui/clipboard-data.js","scripts/ui/clipboard-search.js"]),r(e,"clipboard","clips"),await s(e,{uncategorized:["ExportAllContent","DisplayClipboard"],clipboard:["B23Clean"]}),$cache.get("caio.keyboard.height")&&(e.setting.set("keyboard.previewAndHeight",$cache.get("caio.keyboard.height")),$cache.remove("caio.keyboard.height"))}(e)),t<2&&(e.print(`compatibility: userVersion [${t}] lower than [2], start action`),await async function(e){i(e,["scripts/storage.js","scripts/ui/clips-data.js","scripts/ui/components/action-manager-data.js"]),r(e,"pin","favorite"),await s(e,{uncategorized:["ExportAllContent"]})}(e))}catch(t){throw e.error(t),t}$cache.set("compatibility.version",2)}})),parcelRequire.register("9RsVy",(function(e,t){var i=parcelRequire("gxpqj"),r=i.Kernel,s=i.UIKit,a=parcelRequire("2aNLD"),n=parcelRequire("ilpYs");let o;function l(){o.setting.method.exportClipboard=e=>{e.actionStart(),o.storage.export((t=>{t?e.actionDone():e.actionCancel()}))},o.setting.method.importClipboard=e=>{e.actionStart(),$ui.alert({title:$l10n("ALERT_INFO"),message:$l10n("OVERWRITE_ALERT"),actions:[{title:$l10n("OK"),handler:()=>{$drive.open({handler:t=>{void 0!==t?"db"===t.fileName.slice(-2)||"zip"===t.fileName.slice(-3)?o.storage.import(t).then((()=>{e.actionDone(),$delay(.3,(()=>{$addin.restart()}))})).catch((t=>{$ui.error(t),o.print(t),e.actionCancel()})):($ui.warning($l10n("FILE_TYPE_ERROR")),e.actionCancel()):e.actionCancel()}})}},{title:$l10n("CANCEL"),handler:()=>e.actionCancel()}]})},o.setting.method.rebuildDatabase=e=>{e.actionStart();$ui.alert({title:$l10n("REBUILD_DATABASE_ALERT"),actions:[{title:$l10n("REBUILD"),style:$alertActionType.destructive,handler:()=>{(()=>{try{o.storage.rebuild(),e.actionDone(),$delay(.8,(()=>$addin.restart()))}catch(t){e.actionCancel(),$ui.alert(t)}})()}},{title:$l10n("CANCEL"),handler:()=>{e.actionCancel()}}]})},o.setting.method.deleteAllData=e=>{e.actionStart(),$ui.alert({title:$l10n("DELETE_ALL_DATA_ALERT"),actions:[{title:$l10n("DELETE"),style:$alertActionType.destructive,handler:()=>{o.storage.deleteAllData(),e.actionDone(),$delay(.5,(()=>$addin.restart()))}},{title:$l10n("CANCEL"),handler:()=>{e.actionCancel()}}]})}}e.exports=function(e){o=e,o.setting.method.checkUpdate=async e=>{e.actionStart();const t="scripts/libs/easy-jsbox.js";if($file.exists(t))try{const e=await o.checkUpdate();e&&($file.write({data:$data({string:e}),path:t}),$ui.toast("The framework has been updated."))}catch{}$http.get({url:"https://raw.githubusercontent.com/ipuppet/CAIO/master/config.json",handler:t=>{const i=t.data?.info.version;let s;try{s=__INFO__}catch{s=JSON.parse($file.read("config.json").string).info}r.versionCompare(i,s.version)>0?$ui.alert({title:"New Version",message:`New version found: ${i}\nUpdate via Github or click the button to open Erots.`,actions:[{title:$l10n("CANCEL")},{title:"Erots",handler:()=>{$addin.run({name:"Erots",query:{q:"show",objectId:"603e6eaaca0dd64fcef93e2d"}})}}]}):$ui.toast("No need to update"),e.actionDone()}})},o.setting.method.previewWidget=e=>{const{Widget:t}=parcelRequire("8Makm"),i={};try{JSON.parse($file.read("widget-options.json").string).forEach((e=>{i[e.name]=e.value}))}catch(e){return void $ui.error(e)}$ui.menu({items:Object.keys(i),handler:e=>{t.render(i[e])}})},o.setting.method.fileManager=()=>{o.fileManager.push("storage")},l(),o.setting.method.exportAction=e=>{e.actionStart();const t="actions.zip",i="/actions.zip",r=o.fileStorage.filePath(i);$archiver.zip({directory:o.actionManager.userActionPath,dest:r,handler:()=>{$share.sheet({items:[{name:t,data:$data({path:r})}],handler:t=>{t?e.actionDone():e.actionCancel(),o.fileStorage.delete(i)}})}})},o.setting.method.importAction=e=>{e.actionStart(),$drive.open({handler:t=>{if(void 0!==t)if("zip"===t.fileName.slice(-3)){const i=`${o.fileStorage.basePath}/action_import`;$archiver.unzip({file:t,dest:i,handler:()=>{$file.list(i).forEach((e=>{$file.isDirectory(`${i}/${e}`)&&$file.copy({src:`${i}/${e}`,dst:`${o.actionManager.userActionPath}/${e}`})})),$file.delete(i),e.actionDone()}})}else $ui.warning($l10n("FILE_TYPE_ERROR")),e.actionCancel();else e.actionCancel()}})},o.setting.method.importExampleAction=e=>{e.actionStart(),o.actionManager.importExampleAction(),e.actionDone()},o.setting.method.rebuildAction=e=>{e.actionStart(),$ui.alert({title:$l10n("REBUILD_ACTION_DATABASE_ALERT_TITLE"),message:$l10n("REBUILD_ACTION_DATABASE_ALERT_MESSAGE"),actions:[{title:$l10n("REBUILD"),style:$alertActionType.destructive,handler:()=>{$file.delete(o.actionManager.userActionPath),$file.delete(o.actionManager.iCloudPath),e.actionDone(),$delay(.8,(()=>$addin.restart()))}},{title:$l10n("CANCEL"),handler:()=>e.actionCancel()}]})},function(){const e=parcelRequire("7eNYp"),t=200;o.setting.method.previewKeyboard=()=>{const i=new e(o),r=$text.uuid,s=e=>{$(r).updateLayout((t=>{t.height.equalTo(e)})),i.keyboardHeight=e},a=e=>(e-t)/200;return{views:[{type:"label",layout:(e,t)=>{e.top.inset(20),e.centerX.equalTo(t.super)},events:{ready:e=>e.text=i.keyboardHeight,tapped:e=>{$input.text({type:$kbType.number,text:i.keyboardHeight,handler:i=>{if(/^[0-9]+$/.test(i)){let r=Number(i);r=Math.min(r,400),r=Math.max(r,t),e.text=r,e.next.value=a(r),s(r)}else $ui.toast("Only integers can be entered.")}})}}},{type:"slider",props:{max:1,min:0},layout:(e,t)=>{e.top.equalTo(t.prev.bottom),e.right.inset(20),e.width.equalTo(t.super).offset(-40)},events:{ready:e=>e.value=a(i.keyboardHeight),changed:e=>{const i=Math.floor(200*e.value+t);e.prev.text=i,s(i)}}},{type:"view",props:{id:r},views:[i.getView()],layout:(e,t)=>{e.width.equalTo(t.super),e.height.equalTo(i.keyboardHeight),e.bottom.inset(0)}}],layout:$layout.fill}},o.setting.method.setKeyboardQuickStart=()=>a.sheet()}(),o.setting.method.previewTodayWidget=e=>{e.touchHighlightStart();const t=new(parcelRequire("49je6"))(o).getView();s.push({views:[t],disappeared:()=>e.touchHighlightEnd()})},o.setting.method.setTodayWidgetActions=e=>{n.sheet(o)}}})),parcelRequire.register("2aNLD",(function(e,t){var i=parcelRequire("gxpqj").Sheet;class r{constructor(){this.listId="keyboard-script-list"}static getAddins(){const e=$cache.get("keyboard.addins");return void 0===e?(this.setAddins(),[]):JSON.parse(e)}static setAddins(e=[]){e.map(((t,i)=>{null===t&&e.splice(i,1)})),$cache.set("keyboard.addins",JSON.stringify(e))}getUnsetAddins(){const e=$addin.current.name,t=r.getAddins(),i=[];return $addin.list?.forEach((r=>{const s=r.displayName;-1===t.indexOf(s)&&e!==s&&i.push(s)})),i}add(){const e={type:"list",props:{data:this.getUnsetAddins()},events:{didSelect:(e,t,i)=>{const s=r.getAddins();s.unshift(i),r.setAddins(s),$(this.listId).insert({indexPath:$indexPath(0,0),value:i}),e.delete(t)}},layout:$layout.fill};(new i).setView(e).addNavBar({title:$l10n("ADD")}).init().present()}getNavButtons(){return[{symbol:"plus",tapped:()=>this.add()}]}getListView(){return{type:"list",props:{id:this.listId,reorder:!0,data:r.getAddins(),actions:[{title:"delete",handler:(e,t)=>{r.setAddins(e.data)}}]},events:{reorderFinished:e=>{r.setAddins(e)}},layout:$layout.fill}}static sheet(){const e=new i,t=new r;e.setView(t.getListView()).addNavBar({title:$l10n("QUICK_START_SCRIPTS"),popButton:{title:$l10n("CLOSE")},rightButtons:t.getNavButtons()}),e.init().present()}}e.exports=r})),parcelRequire.register("ilpYs",(function(e,t){var i=parcelRequire("gxpqj").Sheet;class r{constructor(e){this.listId="today-action-list",this.kernel=e}getActions(){let e=$cache.get("today.actions")??[];"string"==typeof e&&(e=JSON.parse(e),this.setActions(e));const t={};this.kernel.actionManager.getActionTypes().forEach((e=>{this.kernel.actionManager.getActions(e).forEach((e=>{t[e.type+e.dir]=e}))}));const i=[];let r=!1;return e.forEach((e=>{const s=t[e.type+e.dir];s?i.push(s):r=!0})),r&&this.setActions(i),i}setActions(e=[]){e.map(((t,i)=>{t||e.splice(i,1)})),$cache.set("today.actions",e)}getAllActions(){let e=[];return this.kernel.actionManager.getActionTypes().forEach((t=>{e=e.concat(this.kernel.actionManager.getActions(t))})),e}getUnsetActions(){const e=this.getActions().map((e=>e.name)),t=[];return this.getAllActions().forEach((i=>{const r=i.name;-1===e.indexOf(r)&&t.push(i)})),t}getListData(e){return e.map((e=>({action:{text:e.name,info:e},icon:"icon_"===e.icon.slice(0,5)?{icon:$icon(e.icon.slice(5,e.icon.indexOf(".")),$color("#ffffff"))}:{image:$image(e.icon)},color:{bgcolor:this.kernel.setting.getColor(e.color)}})))}getListTemplate(){return{views:[{type:"image",props:{id:"color",cornerRadius:8,smoothCorners:!0},layout:e=>{e.top.left.inset(10),e.size.equalTo($size(30,30))}},{type:"image",props:{id:"icon",tintColor:$color("#ffffff")},layout:e=>{e.top.left.inset(15),e.size.equalTo($size(20,20))}},{type:"label",props:{id:"action"},layout:(e,t)=>{e.bottom.top.inset(10),e.left.equalTo(t.prev.prev.right).offset(10),e.right.inset(10)}}]}}add(){const e={type:"list",props:{data:this.getListData(this.getUnsetActions()),template:this.getListTemplate(),rowHeight:50},events:{didSelect:(e,t,i)=>{const r=i.action.info,s=this.getActions();s.unshift(r),this.setActions(s),$(this.listId).insert({indexPath:$indexPath(0,0),value:this.getListData([r])[0]}),e.delete(t)}},layout:$layout.fill};(new i).setView(e).addNavBar({title:$l10n("ADD"),popButton:{title:$l10n("CLOSE")}}).init().present()}getNavButtons(){return[{symbol:"plus",tapped:()=>this.add()}]}getListView(){return{type:"list",props:{id:this.listId,data:this.getListData(this.getActions()),template:this.getListTemplate(),rowHeight:50,reorder:!0,actions:[{title:"delete",handler:(e,t)=>{this.setActions(e.data.map((e=>e.action.info)))}}]},events:{reorderFinished:e=>{const t=[];e.forEach((e=>{t.push(e.action.info)})),this.setActions(t)}},layout:$layout.fill}}static sheet(e){const t=new i,s=new r(e);t.setView(s.getListView()).addNavBar({title:$l10n("ACTIONS"),popButton:{title:$l10n("CLOSE")},rightButtons:s.getNavButtons()}),t.init().present()}}e.exports=r})),parcelRequire.register("7eNYp",(function(e,t){var i=parcelRequire("eSp9Z"),r=i.ActionData,s=i.ActionEnv,a=parcelRequire("gxpqj"),n=a.UIKit,o=a.BarButtonItem,l=parcelRequire("imdB1"),c=parcelRequire("2aNLD");e.exports=class extends l{#ne;listId="keyboard-clips-list";keyboardSwitchLockId="keyboard-switch-lock";keyboardSwitchLockKey="caio.keyboard.switch.lock";deleteTimer=void 0;continuousDeleteTimer=void 0;continuousDeleteDelay=.5;horizontalMargin=15;verticalMargin=10;copiedIndicatorSize=5;containerMargin=5;fontSize=14;navHeight=50;menuItemActionMaxCount=3;constructor(e){super(e),this.backgroundImage=this.kernel.setting.getImage("keyboard.background.image"),this.backgroundColor=this.kernel.setting.getColor(this.kernel.setting.get("keyboard.background.color")),this.backgroundColorDark=this.kernel.setting.getColor(this.kernel.setting.get("keyboard.background.color.dark")),this.deleteDelay=this.kernel.setting.get("keyboard.deleteDelay"),this.keyboardSetting(),"boolean"!=typeof $cache.get(this.keyboardSwitchLockKey)&&$cache.set(this.keyboardSwitchLockKey,!1)}get keyboardHeight(){return this.kernel.setting.get("keyboard.previewAndHeight")}set keyboardHeight(e){this.kernel.setting.set("keyboard.previewAndHeight",e)}getKeyboardSwitchLock(){const e=$cache.get(this.keyboardSwitchLockKey);return"boolean"!=typeof e&&$cache.set(this.keyboardSwitchLockKey,!0),e}switchKeyboardSwitchLock(){const e=$cache.get(this.keyboardSwitchLockKey);$cache.set(this.keyboardSwitchLockKey,!e),$(this.keyboardSwitchLockId).symbol=e?"lock.open":"lock"}listReady(){this.updateList(),this.kernel.setting.get("clipboard.autoSave")&&$app.env===$env.keyboard&&(this.#ne=$timer.schedule({interval:1,handler:()=>{this.kernel.setting.get("clipboard.autoSave")?this.readClipboard():this.#ne.invalidate()}}))}keyboardSetting(){if($app.env!==$env.keyboard)return;const e=$timer.schedule({interval:0,handler:()=>{$keyboard.height!==this.keyboardHeight?$keyboard.height=this.keyboardHeight:e.invalidate()}});this.kernel.setting.get("keyboard.showJSBoxToolbar")||($keyboard.barHidden=!0)}keyboardTapped(e,t=!0,i=1){return(...r)=>{t&&this.kernel.setting.get("keyboard.tapticEngine")&&$device.taptic(i),e(...r)}}getTopButtons(){const e=[{symbol:"keyboard.chevron.compact.down",tapped:this.keyboardTapped((()=>$keyboard.dismiss()))},{symbol:"square.and.arrow.down.on.square",tapped:this.keyboardTapped((e=>{e.start(),this.readClipboard(!0),e.done()}))},{symbol:"bolt.circle",tapped:this.keyboardTapped(((e,t)=>{const i=$ui.popover({sourceView:t,directions:$popoverDirection.up,size:$size(200,300),views:[this.kernel.actionManager.getActionListView((e=>{i.dismiss(),$delay(.5,(async()=>{const t=new r({env:s.keyboard,textBeforeInput:$keyboard.textBeforeInput,textAfterInput:$keyboard.textAfterInput,text:$keyboard.selectedText??await $keyboard.getAllText()});e(t)}))}))]})}))}];return{type:"view",views:e.map(((e,t)=>(new o).setAlign(n.align.right).setSymbol(e.symbol).setEvent("tapped",e.tapped).definition)),layout:(t,i)=>{const r=new o;t.height.equalTo(i.super),t.right.inset(this.containerMargin-r.edges),t.width.equalTo(r.width*e.length+r.edges)}}}getTopBarView(){return{type:"view",views:[{type:"view",layout:$layout.fill,views:[{type:"label",props:{text:$l10n("CAIO"),font:$font("bold",20)},events:{tapped:()=>this.kernel.openInJsbox(),ready:e=>{$cache.get("tips.keyboard.title")||($cache.set("tips.keyboard.title",!0),$ui.popover({sourceView:e,size:$size(200,60),directions:$popoverDirection.up,views:[{type:"label",props:{lines:0,text:$l10n("CLICK_TO_OPEN_JSBOX"),align:$align.center},layout:$layout.fillSafeArea}]}))}},layout:(e,t)=>{e.centerY.equalTo(t.super),e.left.equalTo(t.super).offset(this.containerMargin)}}].concat(this.tabView(),this.getTopButtons())}],layout:(e,t)=>{e.top.width.equalTo(t.super),e.height.equalTo(this.navHeight)}}}getButtonView(e,t){const i=$size(38,38),r=this.containerMargin;return n.blurBox({info:{align:t},smoothCorners:!0,cornerRadius:5},[{type:"button",props:Object.assign({symbol:e.symbol,title:e.title,id:e.id??$text.uuid,font:$font(16),bgcolor:this.backgroundImage?$color($rgba(172,176,184,.3),$rgba(71,71,73,.3)):$color("#ACB0B8","#474749"),tintColor:n.textColor,titleColor:n.textColor,info:{align:t}},e.menu?{menu:e.menu}:{}),events:Object.assign({},e.tapped?{tapped:e.tapped}:{},e.events),layout:$layout.fill}],((s,a)=>{if(e.title){const t=$text.sizeThatFits({text:e.title,width:n.windowSize.width,font:$font(16)}),a=Math.ceil(t.width)+2*r;s.size.equalTo($size(a,i.height))}else s.size.equalTo(i);s.centerY.equalTo(a.super),a.prev&&a.prev.info.align===t?t===n.align.right?s.right.equalTo(a.prev.left).offset(-r):s.left.equalTo(a.prev.right).offset(r):t===n.align.right?s.right.inset(r):s.left.inset(r)}))}getBottomBarView(){const e=[],t=[];return $device.hasFaceID&&!$device.isIpadPro||e.push({symbol:"globe",tapped:this.keyboardTapped((()=>$keyboard.next())),menu:{pullDown:!0,items:[{title:$l10n("SWITCH_KEYBOARD"),handler:this.keyboardTapped((()=>$keyboard.next()))},{title:$l10n("OPEN_IN_JSBOX"),handler:()=>this.kernel.openInJsbox()}]}}),this.kernel.setting.get("keyboard.switchAfterInsert")&&e.push({symbol:this.getKeyboardSwitchLock()?"lock":"lock.open",id:this.keyboardSwitchLockId,tapped:this.keyboardTapped((()=>this.switchKeyboardSwitchLock()))}),e.push({symbol:"paperplane",menu:{pullDown:!0,asPrimary:!0,items:c.getAddins().reverse().map((e=>({title:e,handler:this.keyboardTapped((()=>$addin.run(e)))})))}}),t.push({title:$l10n("SEND"),tapped:this.keyboardTapped((()=>$keyboard.send()))},{symbol:"delete.left",events:{touchesBegan:this.keyboardTapped((()=>{$keyboard.delete(),this.continuousDeleteTimer=$delay(this.continuousDeleteDelay,(()=>{this.deleteTimer=$timer.schedule({interval:this.deleteDelay,handler:this.keyboardTapped((()=>$keyboard.delete()),this.kernel.setting.get("keyboard.tapticEngineForDelete"),0)})}))})),touchesEnded:()=>{this.deleteTimer?.invalidate(),this.continuousDeleteTimer?.cancel(),this.deleteTimer=void 0,this.continuousDeleteTimer=void 0}}}),{type:"view",views:[...e.map((e=>this.getButtonView(e,n.align.left))),...t.map((e=>this.getButtonView(e,n.align.right)))],layout:(e,t)=>{e.bottom.left.right.equalTo(t.super.safeArea),e.top.equalTo(t.prev.bottom)}}}menuItems(){const e=super.menuItems();return[e[0],e[2]]}getListView(){const e=super.getListView();e.layout=(e,t)=>{e.top.equalTo(this.navHeight),e.width.equalTo(t.super),e.bottom.equalTo(t.super.safeAreaBottom).offset(-this.navHeight)};const t=e.views[0];t.events.didSelect=(e,t)=>{const i=this.clips[t.row],r=this.kernel.storage.keyToPath(i.text);r&&this.kernel.fileStorage.exists(r.original)?$quicklook.open({image:this.kernel.fileStorage.readSync(r.original)?.image}):($keyboard.insert(i.text),this.kernel.setting.get("keyboard.switchAfterInsert")&&!this.getKeyboardSwitchLock()&&$keyboard.next())},t.props.separatorInset=$insets(0,this.horizontalMargin,0,this.horizontalMargin);const i=n.blurBox({style:$blurStyle.ultraThinMaterial,smoothCorners:!0,cornerRadius:2*this.containerMargin},[t],((e,t)=>{e.bottom.top.equalTo(t.super),e.left.right.inset(this.containerMargin)}));return e.views[0]=i,e}getView(){return{type:"view",props:{id:"keyboard.main",bgcolor:$color(this.backgroundColor,this.backgroundColorDark)},views:[{type:"image",props:{image:this.backgroundImage,hidden:null===this.backgroundImage},layout:$layout.fill},this.getTopBarView(),this.getListView(),this.getBottomBarView()],layout:$layout.fill}}}})),parcelRequire.register("49je6",(function(e,t){var i=parcelRequire("eSp9Z"),r=i.ActionData,s=i.ActionEnv,a=parcelRequire("gxpqj"),n=a.View,o=a.UIKit,l=a.BarButtonItem,c=a.NavigationBarItems,h=a.NavigationBar,d=parcelRequire("imdB1"),p=parcelRequire("ilpYs");e.exports=class extends d{tabLeftMargin=8;horizontalMargin=15;verticalMargin=10;copiedIndicatorSize=5;fontSize=14;navHeight=38;taptic=1;tagFontSize=10;tagContainerHeight=12;matrixItemHeight=50;inLauncher=$app.env===$env.today&&-1===$app.widgetIndex;launcherNavHeight=44;constructor(e){super(e),this.actionsId="today-list-actions",this.listContainerId="today-list-container",this.readClipboardButtonId="today-nav-readClipboard",this.listId="today-list",this.tabItems.push($l10n("ACTIONS")),this.navigationBarItems=new c,this.bottomBar=new h,this.bottomBar.navigationBarItems=this.navigationBarItems,this.todayActions=new p(this.kernel),this.setClipboarPageSize($widget.mode),this.listPageNow=[0,0],this.listSection=Math.min(this.tabIndex,1),this.setSingleLine()}get isActionPage(){return 2===this.tabIndex}set tabIndex(e){$cache.set("caio.today.tab.index",e)}get tabIndex(){return $cache.get("caio.today.tab.index")??0}listReady(){$widget.modeChanged=e=>{this.setClipboarPageSize(e),this.updateList()},this.setClipboarPageSize($widget.mode),this.updateList(!0),this.appListen(),$delay(.5,(()=>this.readClipboard()))}readClipboard(e=!1){return!this.isActionPage&&$app.env===$env.today&&(super.readClipboard(e),!0)}setClipboarPageSize(e){if(0===e)this.listPageSize=1;else{const e=(($app.env===$env.app?o.windowSize.height:$widget.height)-2*this.navHeight-(this.inLauncher?this.launcherNavHeight:0))/(this.singleLineHeight+2*this.verticalMargin),t=Math.floor(e);this.listPageSize=t,e-t>=.6&&this.listPageSize++}}buttonTapped(e,t=!0){return(...i)=>{t&&this.kernel.setting.get("keyboard.tapticEngine")&&$device.taptic(this.taptic),e(...i)}}navButtons(){return[{symbol:"square.and.arrow.down.on.square",props:{id:this.readClipboardButtonId,hidden:this.isActionPage},tapped:this.buttonTapped((e=>{e.start(),this.readClipboard(!0)?e.done():e.cancel()}))}].map((e=>{const t=new l;return t.setAlign(o.align.right).setSymbol(e.symbol).setEvent("tapped",e.tapped).setProps(e.props??{}),t.definition}))}switchTab(e){this.tabIndex=e,2===e?($(this.listContainerId).hidden=!0,$(this.actionsId).hidden=!1,$(this.readClipboardButtonId).hidden=!0):(this.listSection=e,$(this.actionsId).hidden=!0,$(this.listContainerId).hidden=!1,$(this.readClipboardButtonId).hidden=!1,this.updateList())}getNavBarView(){return{type:"view",views:[{type:"view",layout:$layout.fill,views:[this.tabView(),{type:"label"},...this.navButtons()]}],layout:(e,t)=>{e.top.width.equalTo(t.super),e.height.equalTo(this.navHeight)}}}getBottomBarView(){this.navigationBarItems.setLeftButtons([{symbol:"chevron.backward.circle",tapped:this.buttonTapped((()=>{this.clipboardPrevPage()}))}]).setRightButtons([{symbol:"chevron.forward.circle",tapped:this.buttonTapped((()=>{this.clipboardNextPage()}))}]),this.bottomBar.setTitle(this.listPageNow[this.listSection]+1).setLargeTitleDisplayMode(h.largeTitleDisplayModeNever);const e=this.bottomBar.getNavigationBarView();return e.layout=(e,t)=>{e.bottom.left.right.equalTo(t.super.safeArea),e.top.equalTo(t.prev.bottom)},e}updateList(){const e=this.listPageNow[this.listSection]*this.listPageSize,t=e+this.listPageSize;$(this.listId).data=this.allClips[this.listSection].slice(e,t).map((e=>this.lineData(e,this.copied.uuid===e.uuid))),$(this.bottomBar.id+"-small-title").text=this.listPageNow[this.listSection]+1}clipboardPrevPage(){this.listPageNow[this.listSection]>0&&(this.listPageNow[this.listSection]--,this.updateList())}clipboardNextPage(){const e=Math.ceil(this.allClips[this.listSection].length/this.listPageSize);this.listPageNow[this.listSection]this.listReady(),rowHeight:(e,t)=>{const i=e.object(t).tag.text?this.tagContainerHeight:this.verticalMargin;return this.singleLineHeight+this.verticalMargin+i},didSelect:this.buttonTapped(((e,t)=>{const i=this.clips[t.row],r=this.kernel.storage.keyToPath(i.text);r&&this.kernel.fileStorage.exists(r.original)?$clipboard.image=this.kernel.fileStorage.readSync(r.original).image:(this.setClipboardText(i.text),this.setCopied(i.uuid,t.row)),$ui.toast($l10n("COPIED"))}))},layout:(e,t)=>{e.top.width.equalTo(t.super),e.bottom.equalTo(t.super).offset(-this.navHeight)}},this.getBottomBarView()],layout:(e,t)=>{e.top.equalTo(this.navHeight),e.bottom.left.right.equalTo(t.super.safeArea)}}}getActionView(){let e=this.todayActions.getActions();0===e.length&&(e=this.todayActions.getAllActions());const t={type:"matrix",props:{bgcolor:$color("clear"),columns:2,itemHeight:this.matrixItemHeight,spacing:this.tabLeftMargin,data:e.map((e=>this.kernel.actionManager.actionToData(e))),template:{props:{smoothCorners:!0,cornerRadius:10,bgcolor:$color($rgba(255,255,255,.3),$rgba(0,0,0,.3))},views:[{type:"image",props:{id:"color",cornerRadius:8,smoothCorners:!0},layout:e=>{const t=this.matrixItemHeight-20;e.top.left.inset((this.matrixItemHeight-t)/2),e.size.equalTo($size(t,t))}},{type:"image",props:{id:"icon",tintColor:$color("#ffffff")},layout:(e,t)=>{e.edges.equalTo(t.prev).insets(5)}},{type:"label",props:{id:"name",font:$font(14)},layout:(e,t)=>{e.bottom.top.inset(10),e.left.equalTo(t.prev.prev.right).offset(10),e.right.inset(10)}},{type:"view",props:{id:"info",hidden:!0}}]}},layout:$layout.fill,events:{didSelect:(e,t,i)=>{const a=i.info.info,n=new r({env:s.today,text:"clipboard"===a.type||"uncategorized"===a.type?$clipboard.text:null});this.kernel.actionManager.getActionHandler(a.type,a.dir)(n)}}};return{type:"view",props:{id:this.actionsId,hidden:2!==this.tabIndex},views:[t],layout:(e,t)=>{e.top.equalTo(this.navHeight),e.bottom.left.right.equalTo(t.super.safeArea)}}}getView(){return n.create({props:{titleColor:o.textColor,barColor:o.primaryViewBackgroundColor},views:[{type:"view",views:[this.getNavBarView(),this.getListView(),this.getActionView()],layout:$layout.fill}],events:{appeared:async()=>{if($app.env!==$env.today)return;const e=$timer.schedule({interval:0,handler:()=>{$ui.animate({duration:.3,animation:()=>{$ui.vc.ocValue().$view().$setBackgroundColor($color("clear"))},completion:()=>{e.invalidate()}})}})}}})}}})),$app.strings={en:{ALERT_INFO:"Alert",NONE:"Nothing",DONE:"Done",CLOSE:"Close",FAILED_TO_LOAD_VIEW:"Faild to load view",VIEW_NOT_PROVIDED:"The view is not provided",UNCATEGORIZED:"Uncategorized",SHARE:"Share",CLICK_TO_OPEN_JSBOX:"Click the title to open the main app.",CLIPS:"Clips",CLIPBOARD:"Clipboard",UNIVERSAL_CLIPBOARD:"Universal Clipboard",UNIVERSAL_CLIPBOARD_TIPS:"Universal Clipboard allows you to copy something on your iPhone, and paste it on your Mac–or vice-versa–using iCloud.",CLIPS_STRUCTURE_ERROR:"Clips data structure is abnormal",CLIPBOARD_NO_CHANGE:"Clipboard no change",ADD:"Add",TAG:"Tag",ADD_TAG:"Add Tag",EDIT:"Edit",SEARCH:"Search",SEARCH_HISTORY:"Search History",SEARCH_RESULT:"Search Result",NO_SEARCH_RESULT:"No item found.",FAVORITE:"Favorite",COPY:"Copy",COPIED:"Copied",SORT:"Sort",ACTIONS:"Actions",MORE_ACTIONS:"More Actions",PREVIEW:"Preview",MAX_ITEM_LENGTH:"Line Limit",TEXT_MAX_LENGTH:"Display Character Length",AUTO_SAVE:"Auto Save",AUTO_SYNC:"Auto Sync",SYNC_NOW:"Sync Now",UNZIP_FAILED:"Unzip file failed",SYNC_ALERT_INFO:"If it has not been synced locally, the iCloud data will be pulled directly. \\nDo you want to continue?",DELETE_ICLOUD_DATA:"Delete iCloud Data",REBUILD:"Rebuild",REBUILD_DATABASE:"Rebuild Database",REBUILD_DATABASE_ALERT:"Rebuilding the database will lose the order information, do you want to confirm the rebuild?",DELETE_ALL_DATA:"Delete All Data",DELETE_ALL_DATA_ALERT:"Are you sure you want to delete all your data?",DELETE_DATA:"Delete Data",DELETE_TABLE:"Delete all data from ${table}?",SELECT_ALL:"Select All",DESELECT_ALL:"Deselect All",EDITOR:"Editor",CREATE_NEW:"Create New",CREATE_NEW_ACTION:"New Action",CREATE_NEW_TYPE:"New Category",TYPE_ALREADY_EXISTS:"This category already exists",EDIT_DETAILS:"Edit Details",EDIT_SCRIPT:"Edit Script",INFORMATION:"Information",NAME:"Name",ICON:"Icon",TYPE:"Category",DESCRIPTION:"Description",CODE:"Code",TEXT_INSETS:"Text bottom margin",SHOW_LINE_NUMBER:"Show line number",LIGHT_MODE_THEME:"Light Mode Theme",DARK_MODE_THEME:"Dark Mode Theme",SAVE:"Save",SAVE_SUCCESS:"Save success",SAVE_ERROR:"Save failed",DELETE:"Delete",CONFIRM_DELETE_TITLE:"Delete Confirmation",CONFIRM_DELETE_MSG:"Are you sure you want to delete?",DELETE_SUCCESS:"Delete success",DELETE_ERROR:"Delete failed",IMPORT_EXAMPLE_ACTIONS:"Import example actions",REBUILD_ACTION_DATABASE:"Rebuild Action Database",REBUILD_ACTION_DATABASE_ALERT_TITLE:"Are you sure you want to rebuild?",REBUILD_ACTION_DATABASE_ALERT_MESSAGE:"Rebuild also deletes the data saved in iCloud Drive!",EXPORT:"Export",IMPORT:"Import",FILE_TYPE_ERROR:"File type does not match",OVERWRITE_ALERT:"This operation will overwrite the current data. Do you want to continue?",KEYBOARD:"Keyboard",KEYBOARD_HEIGHT:"Keyboard Height",BACKGROUND_COLOR:"Background Color",BACKGROUND_COLOR_DARK:"Dark Background Color",BACKGROUND_IMAGE:"Background Image",DELETE_DELAY:"Delete Delay",SWITCH_AFTER_INSERT:"Switch After Insert",JSBOX_TOOLBAR:"JSBox Toolbar",QUICK_START_SCRIPTS:"Quick Start Scripts",SEND:"Send",OPEN_IN_JSBOX:"Open in JSBox",SWITCH_KEYBOARD:"Switch Keyboard",TAPTIC_ENGINE:"Taptic Engine",TAPTIC_ENGINE_FOR_DELETE:"Taptic Engine For Delete",CHECK_UPDATE:"Check Update",UPDATE:"Update",WIDGET:"Widget",RECENT:"Recent",CLICK_ACTION:"Click Action",TODAY_WIDGET:"Today Widget",PREV_PAGE:"Prev",NEXT_PAGE:"Next",DISPLAY_MODE:"Display Mode",CLASSIC:"Classic",MODERN:"Modern",FILE_MANAGEMENT:"File Management","compatibility.rebuildUserAction.alert.title":"We need to rebuild some of the action!","compatibility.rebuildUserAction.alert.message":"If you tap the OK button, the following actions will be rebuilt:","compatibility.rebuildUserAction.alert.message2":"Only the action logic will be changed, and the name and icon will remain as it is.",EXPERIMENTAL:"Experimental",SYNC_ACTIONS:"Sync Actions",SYNCING:"Syncing...",LAST_SYNC_AT:"Last sync at: "},"zh-Hans":{ALERT_INFO:"提示",NONE:"什么都没有",DONE:"完成",CLOSE:"关闭",FAILED_TO_LOAD_VIEW:"加载视图失败",VIEW_NOT_PROVIDED:"未提供该视图",UNCATEGORIZED:"未分类",SHARE:"分享",CLICK_TO_OPEN_JSBOX:"点击标题打开主应用。",CLIPS:"剪切板",CLIPBOARD:"剪切板",UNIVERSAL_CLIPBOARD:"通用剪贴板",UNIVERSAL_CLIPBOARD_TIPS:"用剪贴板允许您在iPhone上复制某些内容,然后使用iCloud将其粘贴到Mac上(反之亦然)。",CLIPS_STRUCTURE_ERROR:"剪切板数据结构异常",CLIPBOARD_NO_CHANGE:"剪切板无变化",ADD:"添加",TAG:"标签",ADD_TAG:"添加标签",EDIT:"编辑",SEARCH:"搜索",SEARCH_HISTORY:"搜索历史",SEARCH_RESULT:"搜索结果",NO_SEARCH_RESULT:"搜索无结果",FAVORITE:"收藏",COPY:"复制",COPIED:"已复制",SORT:"排序",ACTIONS:"动作",MORE_ACTIONS:"更多动作",PREVIEW:"预览",MAX_ITEM_LENGTH:"行数限制",TEXT_MAX_LENGTH:"显示字符长度",AUTO_SAVE:"自动保存",AUTO_SYNC:"自动同步",SYNC_NOW:"立即同步",UNZIP_FAILED:"解压文件失败",SYNC_ALERT_INFO:"若未在本机进行过同步则会直接拉取 iCloud 数据。\\n是否继续?",DELETE_ICLOUD_DATA:"删除 iCloud 数据",REBUILD:"重建",REBUILD_DATABASE:"重建数据库",REBUILD_DATABASE_ALERT:"重建数据库将会丢失顺序信息,是否确认重建?",DELETE_ALL_DATA:"删除所有数据",DELETE_ALL_DATA_ALERT:"确定要删除所有数据吗?",DELETE_DATA:"删除数据",DELETE_TABLE:"删除${table}的所有数据?",SELECT_ALL:"全选",DESELECT_ALL:"取消全选",EDITOR:"编辑器",CREATE_NEW:"新建",CREATE_NEW_ACTION:"新建动作",CREATE_NEW_TYPE:"新建分类",TYPE_ALREADY_EXISTS:"该类别已经存在",EDIT_DETAILS:"编辑信息",EDIT_SCRIPT:"编辑脚本",INFORMATION:"信息",NAME:"名称",ICON:"图标",TYPE:"分类",DESCRIPTION:"描述",CODE:"代码",TEXT_INSETS:"文本下边距",SHOW_LINE_NUMBER:"显示行号",LIGHT_MODE_THEME:"浅色模式主题",DARK_MODE_THEME:"深色模式主题",SAVE:"保存",SAVE_SUCCESS:"保存成功",SAVE_ERROR:"保存失败",DELETE:"删除",CONFIRM_DELETE_TITLE:"删除前确认",CONFIRM_DELETE_MSG:"确认要删除吗?",DELETE_SUCCESS:"删除成功",DELETE_ERROR:"删除失败",IMPORT_EXAMPLE_ACTIONS:"导入示例动作",REBUILD_ACTION_DATABASE:"重建动作库",REBUILD_ACTION_DATABASE_ALERT_TITLE:"您确认要重建?",REBUILD_ACTION_DATABASE_ALERT_MESSAGE:"重建会同时删除保存在 iCloud 云盘中的数据!",EXPORT:"导出",IMPORT:"导入",FILE_TYPE_ERROR:"文件类型不符",OVERWRITE_ALERT:"该操作将会覆盖当前数据,是否继续?",KEYBOARD:"键盘",KEYBOARD_HEIGHT:"键盘高度",BACKGROUND_COLOR:"背景色",BACKGROUND_COLOR_DARK:"深色模式背景色",BACKGROUND_IMAGE:"背景图片",DELETE_DELAY:"删除延时",SWITCH_AFTER_INSERT:"输入后切换",JSBOX_TOOLBAR:"JSBox 工具栏",QUICK_START_SCRIPTS:"快速启动脚本",SEND:"发送",OPEN_IN_JSBOX:"在 JSBox 中打开",SWITCH_KEYBOARD:"切换键盘",TAPTIC_ENGINE:"触感反馈",TAPTIC_ENGINE_FOR_DELETE:"删除按钮触感反馈",CHECK_UPDATE:"检查更新",UPDATE:"更新",WIDGET:"小组件",RECENT:"最近内容",CLICK_ACTION:"点击事件",TODAY_WIDGET:"通知中心小组件",PREV_PAGE:"上一页",NEXT_PAGE:"下一页",DISPLAY_MODE:"显示模式",CLASSIC:"经典",MODERN:"现代",FILE_MANAGEMENT:"文件管理","compatibility.rebuildUserAction.alert.title":"我们需要重建部分动作!","compatibility.rebuildUserAction.alert.message":"如果您点击 好,以下动作将会被重建:","compatibility.rebuildUserAction.alert.message2":"只有动作逻辑会被更改,名称和图标将维持现状。",EXPERIMENTAL:"实验功能",SYNC_ACTIONS:"动作同步",SYNCING:"正在同步...",LAST_SYNC_AT:"最后同步:"}},$app.theme="auto",$app.minSDKVer="2.19.0",$app.minOSVer="14.0.0",$app.idleTimerDisabled=!1,$app.keyboardToolbarEnabled=!0,$app.rotateDisabled=!1,__INFO__={name:"CAIO",version:"1.8.2",author:"ipuppet",module:!1},__README__={"README.md":"# CAIO\r\n\r\n> Clipboard all in one.\r\n> \r\n> A Clipboard tool based on JSBox.\r\n\r\nSupport for home widget and notification center widgets.\r\n\r\n## Build Taio Action\r\n\r\nBuild script depend on [Parcel](https://parceljs.org/).\r\n\r\n```shell\r\nnpm i -g parcel\r\nnpm run build\r\n```\r\n\r\nYou can also use the packaged files directly [dist/CAIO-en.json](./dist/CAIO-en.json).\r\n\r\n## Actions\r\n\r\n> For details on how to write, see `scripts/action/README.md` or the book button in the upper right corner of the `Action` edit page in the app.\r\n\r\n### `Action` data difference in different environments\r\n\r\n- The data processed by the `Action` button at the top of the home page is the currently copied content.\r\n- The data processed by the `Action` menu that pops up by long-pressing the list is the selected content.\r\n- The data processed by the `Action` button in the editor is whatever is being edited.\r\n\r\n\r\n## Today Widget\r\n\r\n> Click to copy, long press to trigger the action.\r\n\r\nPlease try to avoid using the Today Widget when JSBox is running CAIO.","README_CN.md":"# CAIO\r\n\r\n> Clipboard all in one.\r\n> \r\n> A Clipboard tool based on JSBox.\r\n\r\n支持桌面小组件和通知中心小组件\r\n\r\n## 构建 Taio 动作\r\n\r\n构建脚本依赖 [Parcel](https://parceljs.org/)\r\n\r\n```shell\r\nnpm i -g parcel\r\nnpm run build\r\n```\r\n\r\n您也可以直接使用已打包好的文件 [dist/CAIO-zh-Hans.json](./dist/CAIO-zh-Hans.json)\r\n\r\n## Actions\r\n\r\n> 编写方式详见 `scripts/action/README.md` 或应用内 `Action` 编辑页面右上角图书按钮。\r\n\r\n### 不同环境中 `Action` 数据区别\r\n\r\n- 首页顶部 `Action` 按钮处理的数据为当前复制的内容\r\n- 长按列表弹出的 `Action` 菜单处理的数据为被选中的内容\r\n- 编辑器中顶部 `Action` 按钮(闪电图形按钮)处理的数据为正在编辑的所有内容\r\n\r\n\r\n## Today Widget\r\n\r\n> 点击复制,长按触发动作。\r\n\r\n请尽量避免在 JSBox 运行 CAIO 时使用 Today Widget"},__SETTING__=[{items:[{icon:["doc.on.clipboard","#FFCC66"],type:"child",title:"CLIPS",key:"clipboard",children:[{items:[{icon:["link","#FF6633"],title:"UNIVERSAL_CLIPBOARD",type:"switch",key:"clipboard.universal",value:!0},{icon:["cursorarrow.rays","#FF6633"],title:"Tips",type:"script",key:"clipboard.tips.universal",value:"$ui.alert({title:$l10n('UNIVERSAL_CLIPBOARD'),message:$l10n('UNIVERSAL_CLIPBOARD_TIPS')})"}]},{items:[{icon:["text.alignleft","#FFCC66"],title:"MAX_ITEM_LENGTH",type:"number",key:"clipboard.maxItemLength",value:100},{icon:["square.and.arrow.down.on.square","#FF6633"],title:"AUTO_SAVE",type:"switch",key:"clipboard.autoSave",value:!0}]},{items:[{icon:["square.and.arrow.up"],title:"EXPORT",type:"script",key:"clipboard.export",value:"this.method.exportClipboard"},{icon:["square.and.arrow.down","#FFCC33"],title:"IMPORT",type:"script",key:"clipboard.import",value:"this.method.importClipboard"}]},{items:[{icon:["arrow.2.circlepath","red"],title:"REBUILD_DATABASE",type:"script",key:"clipboard.rebuildDatabase",value:"this.method.rebuildDatabase"},{icon:["trash","red"],title:"DELETE_ALL_DATA",type:"script",key:"clipboard.deleteAllData",value:"this.method.deleteAllData"}]}]},{icon:["bolt.circle","#FF6633"],type:"child",title:"ACTIONS",key:"action",children:[{items:[{icon:["bolt.circle","#FF6633"],title:"IMPORT_EXAMPLE_ACTIONS",type:"script",key:"action.importExampleAction",value:"this.method.importExampleAction"}]},{items:[{icon:["square.and.arrow.up"],title:"EXPORT",type:"script",key:"action.export",value:"this.method.exportAction"},{icon:["square.and.arrow.down","#FFCC33"],title:"IMPORT",type:"script",key:"action.import",value:"this.method.importAction"}]},{items:[{icon:["arrow.2.circlepath","red"],title:"REBUILD_ACTION_DATABASE",type:"script",key:"action.rebuildAction",value:"this.method.rebuildAction"}]}]},{icon:["pencil.circle","#CC0099"],type:"child",title:"EDITOR",key:"editor",children:[{title:"CLIPS",items:[{icon:["wand.and.stars","#FF6633"],title:"TEXT_INSETS",type:"number",key:"editor.text.insets",value:300}]},{title:"CODE",items:[{icon:["list.number","#6699CC"],title:"SHOW_LINE_NUMBER",type:"switch",key:"editor.code.lineNumbers",value:!1},{icon:["wand.and.stars","#FF6633"],title:"LIGHT_MODE_THEME",type:"input",key:"editor.code.lightTheme",value:"atom-one-light"},{icon:["wand.and.stars","#FF6633"],title:"DARK_MODE_THEME",type:"input",key:"editor.code.darkTheme",value:"atom-one-dark"}]}]},{icon:["keyboard","#a2a5a6"],type:"child",title:"KEYBOARD",key:"keyboard",children:[{items:[{icon:["rectangle.3.offgrid.fill"],title:"PREVIEW",type:"push",key:"keyboard.previewAndHeight",view:"this.method.previewKeyboard",value:267}]},{items:[{icon:["sun.min","#A569BD"],title:"BACKGROUND_COLOR",type:"color",key:"keyboard.background.color",value:"#D1D3D9"},{icon:["sun.min","#A569BD"],title:"BACKGROUND_COLOR_DARK",type:"color",key:"keyboard.background.color.dark",value:"#313131"},{icon:["photo","#FFCC66"],title:"BACKGROUND_IMAGE",type:"image",key:"keyboard.background.image"}]},{items:[{icon:["globe","#1899c4"],title:"SWITCH_AFTER_INSERT",type:"switch",key:"keyboard.switchAfterInsert",value:!1},{icon:["cursor.rays","#FF8C00"],title:"TAPTIC_ENGINE",type:"switch",key:"keyboard.tapticEngine",value:!0},{icon:["option","#157EFB"],title:"JSBOX_TOOLBAR",type:"switch",key:"keyboard.showJSBoxToolbar",value:!1},{icon:["paperplane"],title:"QUICK_START_SCRIPTS",type:"script",key:"keyboard.setKeyboardQuickStart",value:"this.method.setKeyboardQuickStart"}]},{items:[{icon:["cursor.rays","#FF8C00"],title:"TAPTIC_ENGINE_FOR_DELETE",type:"switch",key:"keyboard.tapticEngineForDelete",value:!0},{icon:["rays","#FFCC33"],title:"DELETE_DELAY",type:"number",key:"keyboard.deleteDelay",value:.05}]}]},{icon:["rectangle.3.offgrid.fill","#1899c4"],type:"child",title:"WIDGET",key:"widget",children:[{items:[{icon:["rectangle.3.offgrid.fill"],title:"PREVIEW",type:"script",key:"previewWidget",value:"this.method.previewWidget"}]},{title:"2x2",items:[{icon:["link"],title:"CLICK_ACTION",type:"menu",key:"widget.2x2.widgetURL",items:["ADD","ACTIONS","CLIPS"],value:2}]}]},{icon:["filemenu.and.selection","#ebcc34"],type:"child",title:"TODAY_WIDGET",key:"todayWidget",children:[{items:[{icon:["rectangle.3.offgrid.fill"],title:"PREVIEW",type:"script",key:"todayWidget.preview",value:"this.method.previewTodayWidget"}]},{items:[{icon:["bolt.circle"],title:"ACTIONS",type:"script",key:"todayWidget.setTodayWidgetActions",value:"this.method.setTodayWidgetActions"}]}]}]},{items:[{icon:["rectangle.topthird.inset.filled","#A569BD"],title:"DISPLAY_MODE",type:"tab",key:"mainUIDisplayMode",items:["CLASSIC","MODERN"],value:0},{icon:["folder.fill","#FF9900"],title:"FILE_MANAGEMENT",type:"script",key:"fileManager",value:"this.method.fileManager"}]},{items:[{icon:["wrench.and.screwdriver"],title:"EXPERIMENTAL",type:"child",key:"EXPERIMENTAL",children:[{items:[{icon:["bolt.circle"],title:"SYNC_ACTIONS",type:"switch",key:"experimental.syncAction",value:!1}]}]}]},{items:[{icon:["/assets/icon/github.com.jpeg","white"],title:"Github",type:"info",key:"github",value:["ipuppet/CAIO","https://github.com/ipuppet/CAIO"]},{icon:["/assets/icon/telegram.png","white"],title:"Telegram",type:"info",key:"telegram",value:["JSBoxTG","https://t.me/JSBoxTG"]},{icon:["person.fill","#FF9900"],title:"AUTHOR",type:"info",key:"author",value:["ipuppet","https://blog.ultagic.com"]},{icon:["arrow.2.circlepath"],title:"CHECK_UPDATE",type:"script",key:"checkUpdate",value:"this.method.checkUpdate"},{icon:["book.fill","#A569BD"],title:"README",type:"script",key:"readme",value:"this.method.readme"}]}],__ACTIONS__={clipboard:{B23Clean:{"config.json":'{\r\n "icon": "trash",\r\n "color": "#FF0000",\r\n "name": "b23 清除追踪"\r\n}',"main.js":'/**\r\n * @typedef {import("../../action").Action} Action\r\n */\r\nclass MyAction extends Action {\r\n l10n() {\r\n return {\r\n "zh-Hans": {\r\n "b23clean.converting": "正在转换...",\r\n "b23clean.noUrl": "未检测到链接",\r\n "b23clean.noBiliUrl": "未检测到 bilibili 链接",\r\n "b23clean.success": "已转换为 BV 视频链接",\r\n "b23clean.noChange": "无变化",\r\n "b23clean.multipleLinks": "多条链接仅在编辑模式下可用。"\r\n },\r\n en: {\r\n "b23clean.converting": "Converting...",\r\n "b23clean.noUrl": "No link detected",\r\n "b23clean.noBiliUrl": "bilibili link not detected",\r\n "b23clean.success": "Converted to BV video link",\r\n "b23clean.noChange": "No change",\r\n "b23clean.multipleLinks": "Multiple links are only available in edit mode."\r\n }\r\n }\r\n }\r\n\r\n async cleanUrl(b23url) {\r\n if (b23url.indexOf("bilibili.com") === -1 && b23url.indexOf("b23.tv") === -1) {\r\n throw new Error($l10n("b23clean.noBiliUrl"))\r\n }\r\n\r\n let url = b23url\r\n if (b23url.indexOf("b23.tv") >= 0) {\r\n const resp = await $http.get(b23url)\r\n url = resp.response.url\r\n }\r\n\r\n const queryStart = url.indexOf("?")\r\n if (queryStart > -1) {\r\n url = url.substring(0, queryStart - 1)\r\n }\r\n\r\n return url\r\n }\r\n\r\n /**\r\n * 系统会调用 do() 方法\r\n */\r\n async do() {\r\n $ui.toast($l10n("b23clean.converting"), 1000)\r\n\r\n try {\r\n const b23url = this.getUrls()\r\n if (b23url.length === 0) {\r\n throw new Error($l10n("b23clean.noUrl"))\r\n }\r\n\r\n if (b23url.length === 1) {\r\n let url = await this.cleanUrl(b23url[0])\r\n $ui.clearToast()\r\n $ui.alert({\r\n title: $l10n("b23clean.success"),\r\n message: url,\r\n actions: [\r\n { title: $l10n("OK") },\r\n {\r\n title: $l10n("COPY"),\r\n handler: () => {\r\n $clipboard.text = url\r\n $ui.success($l10n("COPIED"))\r\n }\r\n }\r\n ]\r\n })\r\n } else {\r\n if (this.env !== ActionEnv.editor) {\r\n $ui.toast($l10n("b23clean.multipleLinks"))\r\n return\r\n }\r\n let flag = false\r\n for (let i = 0; i < b23url.length; i++) {\r\n try {\r\n const url = b23url[i].trim()\r\n const replacedUrl = await this.cleanUrl(url)\r\n flag = true\r\n\r\n if (url !== replacedUrl) {\r\n const newText = this.text.replace(url, replacedUrl)\r\n this.setContent(newText)\r\n }\r\n } catch {}\r\n }\r\n if (!flag) {\r\n throw new Error($l10n("b23clean.noBiliUrl"))\r\n } else {\r\n $ui.toast($l10n("b23clean.noChange"))\r\n }\r\n }\r\n } catch (error) {\r\n $ui.clearToast()\r\n $delay(0.5, () => $ui.error(error))\r\n }\r\n }\r\n}\r\n',"README.md":"## B23Clean\r\n\r\n清除 b23.tv 分享链接中的追踪参数,转换为 BV 视频链接。"},CleanClipboard:{"config.json":'{\r\n "icon": "trash",\r\n "color": "#FF0000",\r\n "name": "清除剪切板"\r\n}',"main.js":'/**\r\n * @typedef {import("../../action").Action} Action\r\n */\r\nclass MyAction extends Action {\r\n l10n() {\r\n return {\r\n "zh-Hans": {\r\n "clipboard.clean.success": "剪切板已清空"\r\n },\r\n en: {\r\n "clipboard.clean.success": "Clipboard is cleaned"\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * 系统会调用 do() 方法\r\n */\r\n do() {\r\n $clipboard.clear()\r\n $ui.success($l10n("clipboard.clean.success"))\r\n }\r\n}\r\n',"README.md":"## CleanClipboard\r\n\r\n清空当前剪切板内容。"},DownloadFromUrl:{"config.json":'{\r\n "icon": "square.and.arrow.down",\r\n "color": "#FF0099",\r\n "name": "从链接下载"\r\n}',"main.js":'class MyAction extends Action {\r\n async downloadContent(url) {\r\n const response = await $http.get({\r\n url,\r\n showsProgress: true\r\n })\r\n if (response.error) {\r\n $ui.alert(response.error.localizedDescription)\r\n } else {\r\n return response\r\n }\r\n }\r\n\r\n async do() {\r\n const url = this.getUrls()\r\n let response = undefined\r\n if (url.length > 1) {\r\n $ui.menu({\r\n items: url,\r\n handler: async (title, index) => {\r\n response = await this.downloadContent(url[index])\r\n }\r\n })\r\n } else if (url.length === 1) {\r\n response = await this.downloadContent(url[0])\r\n } else {\r\n $ui.warning("未检测到链接")\r\n return\r\n }\r\n $share.sheet([\r\n {\r\n name: response.response.suggestedFilename,\r\n data: response.data\r\n }\r\n ])\r\n return response\r\n }\r\n}\r\n',"README.md":"## DownloadFromUrl\r\n\r\n从链接下载内容,如 js 文件内容等。"},GetFromWin:{"config.json":'{\r\n "icon": "square.and.arrow.down",\r\n "color": "#33CC33",\r\n "name": "读取 clipsync"\r\n}',"main.js":'/**\r\n * @typedef {import("../../action").Action} Action\r\n */\r\nclass MyAction extends Action {\r\n async getIp(refresh = false) {\r\n let address = $cache.get("caio.action.clipsync.address")\r\n if (refresh || !address) {\r\n address = await $input.text({\r\n placeholder: "Address",\r\n text: $cache.get("caio.action.clipsync.address")\r\n })\r\n }\r\n\r\n $cache.set("caio.action.clipsync.address", address)\r\n\r\n if (!address.startsWith("http")) {\r\n address = "http://" + address\r\n }\r\n\r\n return address\r\n }\r\n\r\n async do() {\r\n let address = await this.getIp()\r\n\r\n $ui.toast("Loading...", 5)\r\n try {\r\n const resp = await this.request(address + "/api/clip", "GET")\r\n if (resp.data.status) {\r\n $ui.success("success")\r\n $clipboard.text = resp.data.data\r\n }\r\n } catch (error) {\r\n $ui.clearToast()\r\n $ui.alert({\r\n title: "Error",\r\n message: String(error),\r\n actions: [\r\n { title: "OK" },\r\n {\r\n title: "Reset Adress",\r\n handler: () => this.getIp(true)\r\n }\r\n ]\r\n })\r\n }\r\n }\r\n}\r\n',"README.md":"## GetFromWin\r\n\r\n通 clipsync 读取 PC 剪切板。\r\n\r\n服务端:[clipsync](https://github.com/ipuppet/clipsync)\r\n"},OpenUrl:{"config.json":'{\r\n "icon": "link",\r\n "color": "#FF0099",\r\n "name": "打开链接"\r\n}',"main.js":'class MyAction extends Action {\r\n l10n() {\r\n return {\r\n "zh-Hans": {\r\n "openLink.nourl": "未检测到链接"\r\n },\r\n en: {\r\n "openLink.nourl": "No link detected"\r\n }\r\n }\r\n }\r\n\r\n openUrl(url) {\r\n $app.openURL(url.trim())\r\n }\r\n\r\n do() {\r\n const url = this.getUrls()\r\n if (url.length > 1) {\r\n $ui.menu({\r\n items: url,\r\n handler: (title, index) => {\r\n this.openUrl(url[index])\r\n }\r\n })\r\n } else if (url.length === 1) {\r\n this.openUrl(url[0])\r\n } else {\r\n $ui.warning($l10n("openLink.nourl"))\r\n }\r\n }\r\n}\r\n',"README.md":"## OpenUrl\r\n\r\n提取文本中的URL并打开。"},SendToWin:{"config.json":'{\r\n "icon": "square.and.arrow.up",\r\n "color": "#33CC33",\r\n "name": "推送 clipsync"\r\n}',"main.js":'/**\r\n * @typedef {import("../../action").Action} Action\r\n */\r\nclass MyAction extends Action {\r\n async getIp(refresh = false) {\r\n let address = $cache.get("caio.action.clipsync.address")\r\n if (refresh || !address) {\r\n address = await $input.text({\r\n placeholder: "Address",\r\n text: $cache.get("caio.action.clipsync.address")\r\n })\r\n }\r\n\r\n $cache.set("caio.action.clipsync.address", address)\r\n\r\n if (!address.startsWith("http")) {\r\n address = "http://" + address\r\n }\r\n\r\n return address\r\n }\r\n\r\n async do() {\r\n let address = await this.getIp()\r\n\r\n $ui.toast("Loading...", 5)\r\n try {\r\n const resp = await this.request(address + "/api/clip", "POST", {\r\n data: $clipboard.text\r\n })\r\n if (resp.data.status) {\r\n $ui.success("success")\r\n }\r\n } catch (error) {\r\n $ui.clearToast()\r\n $ui.alert({\r\n title: "Error",\r\n message: String(error),\r\n actions: [\r\n { title: "OK" },\r\n {\r\n title: "Reset Adress",\r\n handler: () => this.getIp(true)\r\n }\r\n ]\r\n })\r\n }\r\n }\r\n}\r\n',"README.md":"## SendToWin\r\n\r\n通 clipsync 推送剪切板至 PC。\r\n\r\n服务端:[clipsync](https://github.com/ipuppet/clipsync)\r\n"},Tokenize:{"config.json":'{\r\n "icon": "pencil.and.ellipsis.rectangle",\r\n "color": "#0099FF",\r\n "name": "分词复制"\r\n}',"main.js":'class MyAction extends Action {\r\n getView() {\r\n const color = {\r\n background: {\r\n normal: $color("#E7F2FF", "#E7F2FF"),\r\n highlight: $color("##074FF", "#BBDAFF")\r\n },\r\n text: {\r\n normal: $color("##074FF", "##074FF"),\r\n highlight: $color("#FFFFFF", "#ADADAD")\r\n }\r\n }\r\n const fontSize = 16\r\n const edges = 10\r\n return {\r\n type: "matrix",\r\n layout: $layout.fill,\r\n props: {\r\n spacing: edges,\r\n data: this.results.map(item => ({ label: { text: item } })),\r\n template: {\r\n views: [{\r\n type: "label",\r\n props: {\r\n id: "label",\r\n align: $align.center,\r\n cornerRadius: edges,\r\n bgcolor: color.background.normal,\r\n font: $font(fontSize),\r\n textColor: color.text.normal\r\n },\r\n layout: $layout.fill\r\n }]\r\n }\r\n },\r\n events: {\r\n highlighted: () => { },\r\n itemSize: (sender, indexPath) => {\r\n const width = fontSize * this.results[indexPath.item].length + 1\r\n if (this.maxtrixItemHeight === undefined)\r\n this.maxtrixItemHeight = fontSize + edges * 2\r\n return $size(width + edges * 2, this.maxtrixItemHeight)\r\n },\r\n didSelect: (sender, indexPath) => {\r\n const index = this.selected.indexOf(indexPath.item)\r\n const label = sender.cell(indexPath).get("label")\r\n if (index === -1) {\r\n this.selected.push(indexPath.item)\r\n label.bgcolor = color.background.highlight\r\n label.textColor = color.text.highlight\r\n } else {\r\n this.selected.splice(index, 1)\r\n label.bgcolor = color.background.normal\r\n label.textColor = color.text.normal\r\n }\r\n }\r\n }\r\n }\r\n }\r\n /**\r\n * 系统会调用 do() 方法\r\n */\r\n do() {\r\n this.selected = []\r\n this.results = []\r\n $text.tokenize({\r\n text: this.text,\r\n handler: results => {\r\n this.results = results\r\n this.pageSheet({\r\n view: this.getView(),\r\n done: () => {\r\n const result = []\r\n this.selected.sort().forEach(i => {\r\n result.push(this.results[i])\r\n })\r\n if (result.length > 0) {\r\n const text = result.join("")\r\n $clipboard.text = text\r\n $ui.alert({\r\n title: "完成",\r\n message: `已复制内容:${text}`\r\n })\r\n }\r\n }\r\n })\r\n }\r\n })\r\n }\r\n}\r\n',"README.md":"## Tokenize\r\n\r\n将文本分词处理后复制。"}},editor:{PreviewMarkdown:{"config.json":'{\r\n "icon": "book",\r\n "color": "#9900CC",\r\n "name": "预览Markdown"\r\n}',"main.js":'class MyAction extends Action {\r\n do() {\r\n this.pageSheet({\r\n view: {\r\n type: "markdown",\r\n props: { content: this.text },\r\n layout: $layout.fill\r\n }\r\n })\r\n }\r\n}\r\n',"README.md":"## PreviewMarkdown\r\n\r\n预览Markdown。"},SelectedText:{"config.json":'{\r\n "icon": "crop",\r\n "color": "#6699CC",\r\n "name": "选中的文本"\r\n}',"main.js":"class MyAction extends Action {\r\n do() {\r\n if (this.selectedRange.length > 0) {\r\n const selectedText = this.text\r\n $ui.alert(selectedText)\r\n }\r\n }\r\n}\r\n","README.md":"## SelectedText\r\n\r\n显示选中的文本。"}},uncategorized:{DeleteClips:{"config.json":'{\r\n "icon": "trash",\r\n "color": "#FF0000",\r\n "name": "删除所有剪切板"\r\n}',"main.js":'/**\r\n * @typedef {import("../../action").Action} Action\r\n */\r\n\r\nclass MyAction extends Action {\r\n async do() {\r\n try {\r\n const action = await this.clearAllClips()\r\n if (action) {\r\n $ui.success($l10n("DONE"))\r\n }\r\n } catch (error) {\r\n $ui.error(error)\r\n }\r\n }\r\n}\r\n',"README.md":"## DeleteClips\r\n\r\n删除所有已保存的剪切板(不包括收藏)。"},DisplayClipboard:{"config.json":'{\r\n "icon": "option",\r\n "color": "#FF6633",\r\n "name": "显示剪切板"\r\n}',"main.js":'/**\r\n * @typedef {import("../../action").Action} Action\r\n */\r\n\r\nclass MyAction extends Action {\r\n do() {\r\n this.pageSheet({\r\n view: {\r\n type: "label",\r\n props: {\r\n lines: 0,\r\n text: $clipboard.text,\r\n align: $align.center\r\n },\r\n layout: $layout.fill\r\n }\r\n })\r\n }\r\n}\r\n',"README.md":"## DisplayClipboard\r\n\r\n显示当前剪切板内的内容。"},ExportAllContent:{"config.json":'{\r\n "icon": "square.and.arrow.up",\r\n "color": "#FF3300",\r\n "name": "导出数据"\r\n}',"main.js":'class MyAction extends Action {\r\n do() {\r\n const data = this.getAllClips()\r\n if (data.clips.length > 0 || data.favorite.length > 0) {\r\n $share.sheet(JSON.stringify(data, null, 2))\r\n } else {\r\n $ui.alert("无数据")\r\n }\r\n }\r\n}\r\n',"README.md":"## ExportAllContent\r\n\r\n导出所有保存的数据。"},Replace:{"config.json":'{\r\n "icon": "square.and.arrow.up",\r\n "color": "#FF3300",\r\n "name": "查找替换"\r\n}',"main.js":'function HtmlTemplate(html) {\r\n return `\r\n\r\n\r\n \r\n\r\n\r\n${html}\r\n\r\n\r\n`\r\n}\r\n\r\nclass MyAction extends Action {\r\n do() {\r\n $ui.menu({\r\n items: ["忽略大小写", "大小写敏感", "正则表达式"],\r\n handler: async (title, idx) => {\r\n const patternText = await $input.text({\r\n placeholder: "查找内容"\r\n })\r\n const replaceString = await $input.text({\r\n placeholder: "替换内容"\r\n })\r\n let pattern = undefined\r\n if (idx === 0) {\r\n pattern = new RegExp(`(${patternText})+`, "gi")\r\n } else if (idx === 1) {\r\n pattern = new RegExp(`(${patternText})+`, "g")\r\n } else if (idx === 2) {\r\n pattern = new RegExp(patternText, "g")\r\n }\r\n\r\n const matchResultPreview = this.text.replace(pattern, `${replaceString}`)\r\n const matchResult = this.text.replace(pattern, replaceString)\r\n this.pageSheet({\r\n title: "替换预览",\r\n doneText: "替换",\r\n view: {\r\n type: "web",\r\n props: {\r\n html: HtmlTemplate(matchResultPreview)\r\n },\r\n layout: $layout.fill\r\n },\r\n done: () => {\r\n this.setContent(matchResult)\r\n }\r\n })\r\n }\r\n })\r\n // this.setContent("Hello world!")\r\n }\r\n}\r\n',"README.md":"## Replace\r\n\r\n查找替换"}}};var $8Makm=parcelRequire("8Makm");$8Makm.run()})(); \ No newline at end of file diff --git a/scripts/dao/action-manager-data.js b/scripts/dao/action-manager-data.js index 3487aeb8..044d77ba 100644 --- a/scripts/dao/action-manager-data.js +++ b/scripts/dao/action-manager-data.js @@ -32,7 +32,10 @@ class ActionManagerData { // checkUserAction this.checkUserAction() // sync - this.sync() + $thread.background({ + delay: this.#syncInterval, + handler: () => this.sync(true) + }) } get actions() { @@ -47,12 +50,14 @@ class ActionManagerData { return this.#actions } - actionsNeedReload() { + actionsNeedReload(needSync = false) { this.#actions = undefined - $file.write({ - data: $data({ string: JSON.stringify({ date: Date.now() }) }), - path: this.localSyncFile - }) + if (needSync) { + $file.write({ + data: $data({ string: JSON.stringify({ date: Date.now() }) }), + path: this.localSyncFile + }) + } } importExampleAction() { @@ -110,20 +115,57 @@ class ActionManagerData { } } + async downloadFiles(path) { + const list = $file.list(path) + for (let i = 0; i < list.length; i++) { + const subpath = path + "/" + list[i] + if ($file.isDirectory(subpath)) { + await this.downloadFiles(subpath) + } else { + const filename = subpath.substring(subpath.lastIndexOf("/") + 1) + if (filename.endsWith(".icloud")) { + await $file.download(subpath) + } + } + } + } + getSyncDate() { - const localSyncData = JSON.parse($file.read(this.localSyncFile).string) + const localSyncData = JSON.parse($file.read(this.localSyncFile)?.string ?? "{}") return new Date(localSyncData.date) } - async sync() { + checkSyncData() { + if (!$file.exists(this.localSyncFile)) { + $file.write({ + data: $data({ string: JSON.stringify({ date: 0 }) }), + path: this.localSyncFile + }) + } + if (!$file.exists(this.iCloudSyncFile)) { + if ($file.exists(this.iCloudSyncFileUndownloaded)) { + $file.download(this.iCloudSyncFileUndownloaded) + } else { + $file.write({ + data: $data({ string: JSON.stringify({ date: 0 }) }), + path: this.iCloudSyncFile + }) + } + } + } + + async sync(loop = false) { if (!this.kernel.setting.get("experimental.syncAction")) { return } - while (this.#syncLock) { + if (this.#syncLock) { await $wait(this.#syncInterval) + return } this.#syncLock = true + this.checkSyncData() + let iCloudSyncData if ($file.exists(this.iCloudSyncFileUndownloaded)) { iCloudSyncData = await $file.download(this.iCloudSyncFileUndownloaded) @@ -143,6 +185,7 @@ class ActionManagerData { $file.delete(usetActionTempPath) this.#mkdir(usetActionTempPath) // 从 iCloud 复制到 temp + await this.downloadFiles(this.iCloudPath) // download first await $file.copy({ src: this.iCloudPath, dst: usetActionTempPath @@ -157,6 +200,7 @@ class ActionManagerData { this.kernel.print("iCloud data copy success") // 通知更新 UI await $wait(1) + this.actionsNeedReload() $app.notify({ name: "actionSyncStatus", object: { status: ActionManagerData.syncStatus.success } @@ -170,15 +214,21 @@ class ActionManagerData { }) // 停顿一个同步间隔 await $wait(this.#syncInterval) + // 通知更新 UI + $app.notify({ + name: "actionSyncStatus", + object: { status: ActionManagerData.syncStatus.success } + }) } // 解锁,进行下一次同步 this.#syncLock = false - await $wait(this.#syncInterval) - $thread.background({ - delay: 0, - handler: () => this.sync() - }) + if (loop) { + $thread.background({ + delay: this.#syncInterval, + handler: () => this.sync(loop) + }) + } } checkUserAction() { @@ -193,19 +243,6 @@ class ActionManagerData { dst: this.iCloudPath }) } - - if (!$file.exists(this.localSyncFile)) { - $file.write({ - data: $data({ string: JSON.stringify({ date: 0 }) }), - path: this.localSyncFile - }) - } - if (!$file.exists(this.iCloudSyncFile)) { - $file.write({ - data: $data({ string: JSON.stringify({ date: 0 }) }), - path: this.iCloudSyncFile - }) - } } getActionTypes() { @@ -339,7 +376,7 @@ class ActionManagerData { }) this.#saveFile(info.type, info.dir, "README.md", info.readme) - this.actionsNeedReload() + this.actionsNeedReload(true) } saveMainJs(info, content) { @@ -355,7 +392,7 @@ class ActionManagerData { data: $data({ string: JSON.stringify(order) }), path: `${this.iCloudPath}/${type}/${this.actionOrderFile}` }) - this.actionsNeedReload() + this.actionsNeedReload(true) } move(from, to) { @@ -394,13 +431,13 @@ class ActionManagerData { }) } - this.actionsNeedReload() + this.actionsNeedReload(true) } delete(info) { $file.delete(`${this.userActionPath}/${info.type}/${info.dir}`) $file.delete(`${this.iCloudPath}/${info.type}/${info.dir}`) - this.actionsNeedReload() + this.actionsNeedReload(true) } } diff --git a/scripts/libs/easy-jsbox.js b/scripts/libs/easy-jsbox.js index 85f59f9e..8117d490 100644 --- a/scripts/libs/easy-jsbox.js +++ b/scripts/libs/easy-jsbox.js @@ -1 +1 @@ -var $parcel$global="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},$parcel$modules={},$parcel$inits={},parcelRequire=$parcel$global.parcelRequire94c2;null==parcelRequire&&(parcelRequire=function(e){if(e in $parcel$modules)return $parcel$modules[e].exports;if(e in $parcel$inits){var t=$parcel$inits[e];delete $parcel$inits[e];var i={id:e,exports:{}};return $parcel$modules[e]=i,t.call(i.exports,i,i.exports),i.exports}var a=new Error("Cannot find module '"+e+"'");throw a.code="MODULE_NOT_FOUND",a},parcelRequire.register=function(e,t){$parcel$inits[e]=t},$parcel$global.parcelRequire94c2=parcelRequire),parcelRequire.register("45Ip7",(function(e,t){class i{static#e=$objc("UIApplication").$sharedApplication();static#t=$objc("UINotificationFeedbackGenerator").$new();static feedbackSuccess(){i.#t.$notificationOccurred(0)}static feedbackError(){i.#t.$notificationOccurred(2)}static align={left:0,right:1,top:2,bottom:3};static textColor=$color("primaryText");static linkColor=$color("systemLink");static primaryViewBackgroundColor=$color("primarySurface");static scrollViewBackgroundColor=$color("insetGroupedBackground");static scrollViewList=["list","matrix"];static isLargeScreen=$device.isIpad||$device.isIpadPro;static get windowSize(){return $objc("UIWindow").$keyWindow().jsValue().size}static NavigationBarNormalHeight=$objc("UINavigationController").invoke("alloc.init").$navigationBar().jsValue().frame.height;static NavigationBarLargeTitleHeight=$objc("UITabBarController").invoke("alloc.init").$tabBar().jsValue().frame.height+i.NavigationBarNormalHeight;static get isSplitScreenMode(){return i.isLargeScreen&&$device.info.screen.width!==i.windowSize.width}static get topSafeAreaInsets(){return i.#e?.$keyWindow()?.$safeAreaInsets()?.top??0}static get bottomSafeAreaInsets(){return i.#e?.$keyWindow()?.$safeAreaInsets()?.bottom??0}static get statusBarOrientation(){return i.#e.$statusBarOrientation()}static get consoleBarHeight(){if($app.isDebugging){let e=i.#e.$statusBarFrame().height+26;return $device.isIphoneX&&(e+=30),e}return 0}static get isHorizontal(){return 3===i.statusBarOrientation||4===i.statusBarOrientation}static loading(){const e=$ui.create(i.blurBox({cornerRadius:15},[{type:"spinner",props:{loading:!0,style:0},layout:(e,t)=>{e.size.equalTo(t.prev),e.center.equalTo(t.super)}}]));return{start:()=>{$ui.controller.view.insertAtIndex(e,0),e.layout(((e,t)=>{e.center.equalTo(t.super);const a=Math.min(.6*Math.min(i.windowSize.width,i.windowSize.height),260);e.size.equalTo($size(a,a))})),e.moveToFront()},end:()=>{e.remove()}}}static defaultBackgroundColor(e){return i.scrollViewList.indexOf(e)>-1?i.scrollViewBackgroundColor:i.primaryViewBackgroundColor}static separatorLine(e={},t=i.align.bottom){return{type:"canvas",props:e,layout:(e,a)=>{void 0===a.prev?e.top.equalTo(a.super):t===i.align.bottom?e.top.equalTo(a.prev.bottom):e.top.equalTo(a.prev.top),e.height.equalTo(1/$device.info.screen.scale),e.left.right.inset(0)},events:{draw:(t,i)=>{i.strokeColor=e.bgcolor??$color("separatorColor"),i.setLineWidth(1),i.moveToPoint(0,0),i.addLineToPoint(t.frame.width,0),i.strokePath()}}}}static blurBox(e={},t=[],i=$layout.fill){return{type:"blur",props:Object.assign({style:$blurStyle.thinMaterial},e),views:t,layout:i}}static getContentSize(e,t="A",a=i.windowSize.width,r){const s={text:t,width:a,font:e};return void 0!==r&&(s.lineSpacing=r),$text.sizeThatFits(s)}static push({views:e,statusBarStyle:t=0,title:i="",navButtons:a=[{title:""}],bgcolor:r=e[0]?.props?.bgcolor??"primarySurface",disappeared:s}={}){$ui.push({props:{statusBarStyle:t,navButtons:a,title:i,bgcolor:"string"==typeof r?$color(r):r},events:{disappeared:()=>{void 0!==s&&s()}},views:[{type:"view",views:e,layout:(e,t)=>{e.top.equalTo(t.super.safeArea),e.bottom.equalTo(t.super),e.left.right.equalTo(t.super.safeArea)}}]})}}e.exports={UIKit:i}})),parcelRequire.register("7D8Kb",(function(module,exports){var $fYz8N=parcelRequire("fYz8N"),$58e2f5443faff7c0$require$Controller=$fYz8N.Controller,$8aDdQ=parcelRequire("8aDdQ"),$58e2f5443faff7c0$require$FileStorageFileNotFoundError=$8aDdQ.FileStorageFileNotFoundError,$58e2f5443faff7c0$require$FileStorage=$8aDdQ.FileStorage,$cgaQ6=parcelRequire("cgaQ6"),$58e2f5443faff7c0$require$Kernel=$cgaQ6.Kernel,$45Ip7=parcelRequire("45Ip7"),$58e2f5443faff7c0$require$UIKit=$45Ip7.UIKit,$aXWmO=parcelRequire("aXWmO"),$58e2f5443faff7c0$require$Sheet=$aXWmO.Sheet,$12xzj=parcelRequire("12xzj"),$58e2f5443faff7c0$require$NavigationView=$12xzj.NavigationView,$dcStC=parcelRequire("dcStC"),$58e2f5443faff7c0$require$NavigationBar=$dcStC.NavigationBar,$gMc1q=parcelRequire("gMc1q"),$58e2f5443faff7c0$require$ViewController=$gMc1q.ViewController;class SettingLoadConfigError extends Error{constructor(){super("Call loadConfig() first."),this.name="SettingLoadConfigError"}}class SettingReadonlyError extends Error{constructor(){super("Attempted to assign to readonly property."),this.name="SettingReadonlyError"}}class Setting extends $58e2f5443faff7c0$require$Controller{name;setting={};userData;fileStorage;imagePath;viewController=new $58e2f5443faff7c0$require$ViewController;method={readme:()=>{const e=(()=>{const e=$device.info?.language?.startsWith("zh")?"README_CN.md":"README.md";try{return __README__[e]??__README__["README.md"]}catch{return $file.read(e)?.string??$file.read("README.md")?.string}})();(new $58e2f5443faff7c0$require$Sheet).setView({type:"markdown",props:{content:e},layout:(e,t)=>{e.size.equalTo(t.super)}}).init().present()}};rowHeight=50;edgeOffset=10;iconSize=30;#i={};#a=!1;#r=!1;#s;constructor(e={}){super(),"function"==typeof e.set&&"function"==typeof e.get?(this.set=e.set,this.get=e.get,this.userData=e.userData):(this.fileStorage=e.fileStorage??new $58e2f5443faff7c0$require$FileStorage,this.dataFile=e.dataFile??"setting.json"),e.structure?this.setStructure(e.structure):this.setStructurePath(e.structurePath??"setting.json"),this.isUseJsboxNav=e.isUseJsboxNav??!1,this.imagePath=(e.name??"default")+".image/",this.setName(e.name??$text.uuid),this.loadL10n()}useJsboxNav(){return this.isUseJsboxNav=!0,this}#o(){if(!this.#r)throw new SettingLoadConfigError}loadConfig(){const e=["script","info"],t=this.userData??this.fileStorage.readAsJSON(this.dataFile,{});return this.setting=function i(a){const r={};for(let s of a)for(let a of s.items)if("child"===a.type){const e=i(a.children);Object.assign(r,e)}else-1===e.indexOf(a.type)?r[a.key]=a.key in t?t[a.key]:a.value:r[a.key]=a.value;return r}(this.structure),this.#r=!0,this}hasSectionTitle(e){return this.#o(),!!e[0]?.title}loadL10n(){$58e2f5443faff7c0$require$Kernel.l10n("zh-Hans",{OK:"好",DONE:"完成",CANCEL:"取消",CLEAR:"清除",BACK:"返回",ERROR:"发生错误",SUCCESS:"成功",LOADING:"加载中",INVALID_VALUE:"非法参数",CONFIRM_CHANGES:"数据已变化,确认修改?",SETTING:"设置",GENERAL:"一般",ADVANCED:"高级",TIPS:"小贴士",COLOR:"颜色",COPY:"复制",COPIED:"复制成功",JSBOX_ICON:"JSBox 内置图标",SF_SYMBOLS:"SF Symbols",IMAGE_BASE64:"图片 / base64",PREVIEW:"预览",SELECT_IMAGE:"选择图片",CLEAR_IMAGE:"清除图片",NO_IMAGE:"无图片",ABOUT:"关于",VERSION:"Version",AUTHOR:"作者",AT_BOTTOM:"已经到底啦~"},!1),$58e2f5443faff7c0$require$Kernel.l10n("en",{OK:"OK",DONE:"Done",CANCEL:"Cancel",CLEAR:"Clear",BACK:"Back",ERROR:"Error",SUCCESS:"Success",LOADING:"Loading",INVALID_VALUE:"Invalid value",CONFIRM_CHANGES:"The data has changed, confirm the modification?",SETTING:"Setting",GENERAL:"General",ADVANCED:"Advanced",TIPS:"Tips",COLOR:"Color",COPY:"Copy",COPIED:"Copide",JSBOX_ICON:"JSBox in app icon",SF_SYMBOLS:"SF Symbols",IMAGE_BASE64:"Image / base64",PREVIEW:"Preview",SELECT_IMAGE:"Select Image",CLEAR_IMAGE:"Clear Image",NO_IMAGE:"No Image",ABOUT:"About",VERSION:"Version",AUTHOR:"Author",AT_BOTTOM:"It's the end~"},!1)}setUserData(e){this.userData=e}setStructure(e){return this.structure=e,this}setStructurePath(e){return this.structure||this.setStructure($58e2f5443faff7c0$require$FileStorage.readFromRootAsJSON(e)),this}setName(e){return this.name=e,this}setFooter(e){return this.#s=e,this}set footer(e){this.#s=e}get footer(){if(void 0===this.#s){let e=$58e2f5443faff7c0$require$FileStorage.readFromRootAsJSON("config.json",{}).info??{};if(!e.version||!e.author)try{e=__INFO__}catch{}this.#s={},e.version&&e.author&&(this.#s={type:"view",props:{height:70},views:[{type:"label",props:{font:$font(14),text:`${$l10n("VERSION")} ${e.version} ♥ ${e.author}`,textColor:$color({light:"#C0C0C0",dark:"#545454"}),align:$align.center},layout:e=>{e.left.right.inset(0),e.top.inset(10)}}]})}return this.#s}setReadonly(){return this.#a=!0,this}set(e,t){if(this.#a)throw new SettingReadonlyError;return this.#o(),this.setting[e]=t,this.fileStorage.write(this.dataFile,$data({string:JSON.stringify(this.setting)})),this.callEvent("onSet",e,t),!0}get(e,t=null){return this.#o(),Object.prototype.hasOwnProperty.call(this.setting,e)?this.setting[e]:t}getColor(e){return"string"==typeof e?$color(e):$rgba(e.red,e.green,e.blue,e.alpha)}getImagePath(e,t=!1){let i=$text.MD5(e)+".jpg";return t&&(i="compress."+i),this.imagePath+i}getImage(e,t=!1){try{return this.fileStorage.readSync(this.getImagePath(e,t)).image}catch(e){if(e instanceof $58e2f5443faff7c0$require$FileStorageFileNotFoundError)return null;throw e}}getId(e){return`setting-${this.name}-${e}`}#n(e){$(e).bgcolor=$color("systemFill")}#l(e,t=.3){0===t?$(e).bgcolor=$color("clear"):$ui.animate({duration:t,animation:()=>{$(e).bgcolor=$color("clear")}})}#h(e,t,i=!1,a=0){if(t=Object.assign(t,{touchesBegan:()=>{this.#n(e),this.#i[e]=$delay(1,(()=>this.#l(e,0)))},touchesMoved:()=>{this.#i[e]?.cancel(),this.#l(e,0)}}),i){const i=t.tapped;t.tapped=()=>{this.#n(e),setTimeout((()=>this.#l(e)),1e3*a),"function"==typeof i&&i()}}return t}createLineLabel(e,t){return t[1]||(t[1]="#00CC00"),"object"!=typeof t[1]&&(t[1]=[t[1],t[1]]),"object"!=typeof t[0]&&(t[0]=[t[0],t[0]]),{type:"view",views:[{type:"view",props:{bgcolor:$color(t[1][0],t[1][1]),cornerRadius:5,smoothCorners:!0},views:[{type:"image",props:{tintColor:$color("white"),image:$image(t[0][0],t[0][1])},layout:(e,t)=>{e.center.equalTo(t.super),e.size.equalTo(20)}}],layout:(e,t)=>{e.centerY.equalTo(t.super),e.size.equalTo(this.iconSize),e.left.inset(this.edgeOffset)}},{type:"label",props:{text:e,lines:1,textColor:this.textColor,align:$align.left},layout:(e,t)=>{e.centerY.equalTo(t.super),e.height.equalTo(t.super),e.left.equalTo(t.prev.right).offset(this.edgeOffset),e.width.greaterThanOrEqualTo(10)}}],layout:(e,t)=>{e.height.centerY.equalTo(t.super),e.left.inset(0)}}}createInfo(e,t,i){const a=Array.isArray(i),r=a?i[0]:i,s=a?i[1]:i;return{type:"view",props:{selectable:!0},views:[this.createLineLabel(t,e),{type:"label",props:{text:r,align:$align.right,textColor:$color("darkGray")},layout:(e,t)=>{e.centerY.equalTo(t.prev),e.right.inset(this.edgeOffset),e.width.equalTo(180)}},{type:"view",events:{tapped:()=>{$ui.alert({title:t,message:s,actions:[{title:$l10n("COPY"),handler:()=>{$clipboard.text=s,$ui.toast($l10n("COPIED"))}},{title:$l10n("OK")}]})}},layout:(e,t)=>{e.right.inset(0),e.size.equalTo(t.super)}}],layout:$layout.fill}}createSwitch(e,t,i){return{type:"view",props:{id:this.getId(e),selectable:!0},views:[this.createLineLabel(i,t),{type:"switch",props:{on:this.get(e),onColor:$color("#00CC00")},events:{changed:t=>{try{this.set(e,t.on)}catch(e){throw t.on=!t.on,e}}},layout:(e,t)=>{e.centerY.equalTo(t.prev),e.right.inset(this.edgeOffset)}}],layout:$layout.fill}}createString(e,t,i){return{type:"view",props:{id:this.getId(e),selectable:!0},views:[this.createLineLabel(i,t),{type:"button",props:{symbol:"square.and.pencil",bgcolor:$color("clear"),tintColor:$color("primaryText")},events:{tapped:t=>{const i=$ui.popover({sourceView:t,sourceRect:t.bounds,directions:$popoverDirection.down,size:$size(320,150),views:[{type:"text",props:{id:`${this.name}-string-${e}`,align:$align.left,text:this.get(e)},layout:e=>{e.left.right.inset(10),e.top.inset(20),e.height.equalTo(90)}},{type:"button",props:{symbol:"checkmark",bgcolor:$color("clear"),titleEdgeInsets:10,contentEdgeInsets:0},layout:e=>{e.right.inset(10),e.bottom.inset(25),e.size.equalTo(30)},events:{tapped:()=>{this.set(e,$(`${this.name}-string-${e}`).text),i.dismiss()}}}]})}},layout:(e,t)=>{e.centerY.equalTo(t.prev),e.right.inset(0),e.size.equalTo(50)}}],layout:$layout.fill}}createStepper(e,t,i,a,r){const s=this.getId(e),o=`${s}-label`;return{type:"view",props:{id:s,selectable:!0},views:[this.createLineLabel(i,t),{type:"label",props:{id:o,text:this.get(e),textColor:this.textColor,align:$align.left},layout:(e,t)=>{e.height.equalTo(t.super),e.right.inset(120)}},{type:"stepper",props:{min:a,max:r,value:this.get(e)},events:{changed:t=>{$(o).text=t.value;try{this.set(e,t.value)}catch(t){throw $(o).text=this.get(e),t}}},layout:(e,t)=>{e.centerY.equalTo(t.prev),e.right.inset(this.edgeOffset)}}],layout:$layout.fill}}createScript(key,icon,title,script){const id=this.getId(key),buttonId=`${id}-button`,actionStart=()=>{$(buttonId).alpha=0,$(`${buttonId}-spinner`).alpha=1,this.#n(id)},actionCancel=()=>{$(buttonId).alpha=1,$(`${buttonId}-spinner`).alpha=0,this.#l(id)},actionDone=(e=!0,t=$l10n("ERROR"))=>{$(`${buttonId}-spinner`).alpha=0,this.#l(id);const i=$(buttonId);if(!e)return $ui.toast(t),void(i.alpha=1);i.symbol="checkmark",$ui.animate({duration:.6,animation:()=>{i.alpha=1},completion:()=>{setTimeout((()=>{$ui.animate({duration:.4,animation:()=>{i.alpha=0},completion:()=>{i.symbol="chevron.right",$ui.animate({duration:.4,animation:()=>{i.alpha=1},completion:()=>{i.alpha=1}})}})}),600)}})};return{type:"view",props:{id:id},views:[this.createLineLabel(title,icon),{type:"view",views:[{type:"image",props:{id:buttonId,symbol:"chevron.right",tintColor:$color("secondaryText")},layout:(e,t)=>{e.centerY.equalTo(t.super),e.right.inset(0),e.size.equalTo(15)}},{type:"spinner",props:{id:`${buttonId}-spinner`,loading:!0,alpha:0},layout:(e,t)=>{e.size.equalTo(t.prev),e.left.top.equalTo(t.prev)}}],layout:(e,t)=>{e.right.inset(this.edgeOffset),e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],events:this.#h(id,{tapped:()=>{const animate={actionStart:actionStart,actionCancel:actionCancel,actionDone:actionDone,touchHighlightStart:()=>this.#n(id),touchHighlightEnd:()=>this.#l(id)};"function"==typeof script?script(animate):script.startsWith("this")?eval(`(()=>{return ${script}(animate)})()`):eval(script)}}),layout:$layout.fill}}createTab(key,icon,title,items,values){"string"==typeof items?items=eval(`(()=>{return ${items}()})()`):"function"==typeof items&&(items=items()),"string"==typeof values?values=eval(`(()=>{return ${values}()})()`):"function"==typeof values&&(values=values());const id=this.getId(key),isCustomizeValues=items?.length>0&&values?.length===items?.length;return{type:"view",props:{id:id,selectable:!0},views:[this.createLineLabel(title,icon),{type:"tab",props:{items:items??[],index:isCustomizeValues?values.indexOf(this.get(key)):this.get(key),dynamicWidth:!0},layout:(e,t)=>{e.right.inset(this.edgeOffset),e.centerY.equalTo(t.prev)},events:{changed:e=>{isCustomizeValues?this.set(key,values[e.index]):this.set(key,e.index)}}}],layout:$layout.fill}}createMenu(key,icon,title,items,values){const id=this.getId(key),labelId=`${id}-label`,getItems=()=>{let res;return res="string"==typeof items?eval(`(()=>{return ${items}()})()`):"function"==typeof items?items():items??[],res},getValues=()=>{let res;return res="string"==typeof values?eval(`(()=>{return ${values}()})()`):"function"==typeof values?values():values,res},tmpItems=getItems(),tmpValues=getValues(),isCustomizeValues=tmpItems?.length>0&&tmpValues?.length===tmpItems?.length;return{type:"view",props:{id:id,selectable:!0},views:[this.createLineLabel(title,icon),{type:"view",views:[{type:"label",props:{text:isCustomizeValues?tmpItems[tmpValues.indexOf(this.get(key))]:tmpItems[this.get(key)],color:$color("secondaryText"),id:labelId},layout:(e,t)=>{e.right.inset(0),e.height.equalTo(t.super)}}],layout:(e,t)=>{e.right.inset(this.edgeOffset),e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],events:{tapped:()=>{const e=getItems(),t=getValues();$ui.menu({items:e,handler:(e,i)=>{isCustomizeValues?this.set(key,t[i]):this.set(key,i),$(labelId).text=$l10n(e)}})}},layout:$layout.fill}}createColor(e,t,i){const a=this.getId(e),r=`${a}-color`;return{type:"view",props:{id:a,selectable:!0},views:[this.createLineLabel(i,t),{type:"view",views:[{type:"view",props:{id:r,bgcolor:this.getColor(this.get(e)),circular:!0,borderWidth:1,borderColor:$color("#e3e3e3")},layout:(e,t)=>{e.centerY.equalTo(t.super),e.right.inset(this.edgeOffset),e.size.equalTo(20)}},{type:"view",events:{tapped:async()=>{const t=await $picker.color({color:this.getColor(this.get(e))});this.set(e,t.components),$(r).bgcolor=$rgba(t.components.red,t.components.green,t.components.blue,t.components.alpha)}},layout:(e,t)=>{e.right.inset(0),e.height.width.equalTo(t.super.height)}}],layout:(e,t)=>{e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],layout:$layout.fill}}createDate(e,t,i,a=2){const r=this.getId(e),s=e=>{let t="";switch("number"==typeof e&&(e=new Date(e)),a){case 0:t=e.toLocaleTimeString();break;case 1:t=e.toLocaleDateString();break;case 2:t=e.toLocaleString()}return t};return{type:"view",props:{id:r,selectable:!0},views:[this.createLineLabel(i,t),{type:"view",views:[{type:"label",props:{id:`${r}-label`,color:$color("secondaryText"),text:this.get(e)?s(this.get(e)):"None"},layout:(e,t)=>{e.right.inset(0),e.height.equalTo(t.super)}}],events:{tapped:async()=>{const t=this.get(e),i=await $picker.date({props:{mode:a,date:t||Date.now()}});this.set(e,i.getTime()),$(`${r}-label`).text=s(i)}},layout:(e,t)=>{e.right.inset(this.edgeOffset),e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],layout:$layout.fill}}createNumber(e,t,i){return this.createInput(e,t,i,!1,$kbType.decimal,(t=>""!==t&&/^[0-9]+.?[0-9]*$/.test(t)?this.set(e,Number(t)):($ui.toast($l10n("INVALID_VALUE")),!1)))}createInput(e,t,i,a=!1,r=$kbType.default,s){void 0===s&&(s=t=>this.set(e,t));const o=this.getId(e),n=o+"-input";return{type:"view",props:{id:o,selectable:!0},views:[this.createLineLabel(i,t),{type:"input",props:{id:n,type:r,align:$align.right,bgcolor:$color("clear"),textColor:$color("secondaryText"),text:this.get(e),font:$font(16),secure:a,accessoryView:$58e2f5443faff7c0$require$UIKit.blurBox({height:44},[$58e2f5443faff7c0$require$UIKit.separatorLine({},$58e2f5443faff7c0$require$UIKit.align.top),{type:"button",props:{title:$l10n("DONE"),bgcolor:$color("clear"),titleColor:$color("primaryText")},layout:(e,t)=>{e.right.inset(this.edgeOffset),e.centerY.equalTo(t.super)},events:{tapped:()=>{$(n).blur()}}},{type:"button",props:{title:$l10n("CANCEL"),bgcolor:$color("clear"),titleColor:$color("primaryText")},layout:(e,t)=>{e.left.inset(this.edgeOffset),e.centerY.equalTo(t.super)},events:{tapped:()=>{const t=$(n),i=this.get(e,"");t.text!==i&&(t.text=i),t.blur()}}}])},layout:(t,i)=>{t.left.equalTo(i.prev.get("label").right).offset(this.edgeOffset),t.right.inset(this.edgeOffset);const a=$58e2f5443faff7c0$require$UIKit.getContentSize($font(16),this.get(e)).width;t.width.greaterThanOrEqualTo(a+30),t.height.equalTo(i.super)},events:{didBeginEditing:e=>{e.secure=!1,$app.autoKeyboardEnabled||($app.autoKeyboardEnabled=!0)},returned:e=>{e.blur()},didEndEditing:async t=>{const i=this.get(e,"");s(t.text)||(t.text=i),a&&(t.secure=a)}}}],layout:$layout.fill}}createIcon(e,t,i,a="#000000"){const r=this.getId(e),s=`${r}-image`;return{type:"view",props:{id:r,selectable:!0},views:[this.createLineLabel(i,t),{type:"view",views:[{type:"image",props:{cornerRadius:8,bgcolor:"string"==typeof a?$color(a):a,smoothCorners:!0},layout:(e,t)=>{e.right.inset(this.edgeOffset),e.centerY.equalTo(t.super),e.size.equalTo($size(30,30))}},{type:"image",props:{id:s,image:$image(this.get(e)),icon:$icon(this.get(e).slice(5,this.get(e).indexOf(".")),$color("#ffffff")),tintColor:$color("#ffffff")},layout:(e,t)=>{e.right.equalTo(t.prev).offset(-5),e.centerY.equalTo(t.super),e.size.equalTo($size(20,20))}}],events:{tapped:()=>{$ui.menu({items:[$l10n("JSBOX_ICON"),$l10n("SF_SYMBOLS"),$l10n("IMAGE_BASE64")],handler:async(t,i)=>{if(0===i){const t=await $ui.selectIcon();this.set(e,t),$(s).icon=$icon(t.slice(5,t.indexOf(".")),$color("#ffffff"))}else 1!==i&&2!==i||$input.text({text:"",placeholder:t,handler:t=>{""!==t?(this.set(e,t),1===i?$(s).symbol=t:$(s).image=$image(t)):$ui.toast($l10n("INVALID_VALUE"))}})}})}},layout:(e,t)=>{e.right.inset(0),e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],layout:$layout.fill}}createPush(key,icon,title,view,tapped){const id=this.getId(key);return{type:"view",layout:$layout.fill,props:{id:id,selectable:!0},views:[this.createLineLabel(title,icon),{type:"image",props:{symbol:"chevron.right",tintColor:$color("secondaryText")},layout:(e,t)=>{e.centerY.equalTo(t.super),e.right.inset(this.edgeOffset),e.size.equalTo(15)}}],events:{tapped:()=>{const push=view=>{if("string"==typeof view&&view.startsWith("this.method")?view=eval(`(()=>{return ${view}()})()`):"function"==typeof view&&(view=view()),this.isUseJsboxNav)$58e2f5443faff7c0$require$UIKit.push({title:title,props:view.props??{},views:[view]});else{const e=new $58e2f5443faff7c0$require$NavigationView;e.setView(view).navigationBarTitle(title),e.navigationBarItems.addPopButton(),e.navigationBar.setLargeTitleDisplayMode($58e2f5443faff7c0$require$NavigationBar.largeTitleDisplayModeNever),this.hasSectionTitle(view)&&e.navigationBar.setContentViewHeightOffset(-10),this.viewController.push(e)}};"function"==typeof tapped?tapped(push):push(view)}}}}createChild(e,t,i,a){return this.createPush(e,t,i,void 0,(e=>{this.events?.onChildPush?this.callEvent("onChildPush",this.getListView(a,{}),i):e(this.getListView(a,{}))}))}createImage(e,t,i){const a=this.getId(e),r=`${a}-image`,s=$image("questionmark.square.dashed");return{type:"view",props:{id:a,selectable:!0},views:[this.createLineLabel(i,t),{type:"view",views:[{type:"image",props:{id:r,image:this.getImage(e,!0)??s},layout:(e,t)=>{e.right.inset(this.edgeOffset),e.centerY.equalTo(t.super),e.size.equalTo($size(30,30))}}],events:{tapped:()=>{this.#n(a),$ui.menu({items:[$l10n("PREVIEW"),$l10n("SELECT_IMAGE"),$l10n("CLEAR_IMAGE")],handler:(t,i)=>{if(0===i){const t=this.getImage(e);t?$quicklook.open({image:t}):$ui.toast($l10n("NO_IMAGE"))}else 1===i?$photo.pick({format:"data"}).then((t=>{if($ui.toast($l10n("LOADING")),!t.status||!t.data)return void("canceled"!==t?.error?.description&&$ui.toast($l10n("ERROR")));const i=$58e2f5443faff7c0$require$Kernel.compressImage(t.data.image);this.fileStorage.write(this.getImagePath(e,!0),i.jpg(.8)),this.fileStorage.write(this.getImagePath(e),t.data),$(r).image=i,$ui.success($l10n("SUCCESS"))})):2===i&&(this.fileStorage.delete(this.getImagePath(e,!0)),this.fileStorage.delete(this.getImagePath(e)),$(r).image=s,$ui.success($l10n("SUCCESS")))},finished:()=>{this.#l(a)}})}},layout:(e,t)=>{e.right.inset(0),e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],layout:$layout.fill}}#c(e){const t=[];for(let i of e){const e=[];for(let t of i.items){const i=this.get(t.key);let a=null;switch(t.icon||(t.icon=["square.grid.2x2.fill","#00CC00"]),"object"==typeof t.items&&(t.items=t.items.map((e=>$l10n(e)))),t.title=$l10n(t.title),t.type){case"switch":a=this.createSwitch(t.key,t.icon,t.title);break;case"stepper":a=this.createStepper(t.key,t.icon,t.title,t.min??1,t.max??12);break;case"string":a=this.createString(t.key,t.icon,t.title);break;case"info":a=this.createInfo(t.icon,t.title,i);break;case"script":a=this.createScript(t.key,t.icon,t.title,i);break;case"tab":a=this.createTab(t.key,t.icon,t.title,t.items,t.values);break;case"menu":a=this.createMenu(t.key,t.icon,t.title,t.items,t.values);break;case"color":a=this.createColor(t.key,t.icon,t.title);break;case"date":a=this.createDate(t.key,t.icon,t.title,t.mode);break;case"number":a=this.createNumber(t.key,t.icon,t.title);break;case"input":a=this.createInput(t.key,t.icon,t.title,t.secure);break;case"icon":a=this.createIcon(t.key,t.icon,t.title,t.bgcolor);break;case"push":a=this.createPush(t.key,t.icon,t.title,t.view);break;case"child":a=this.createChild(t.key,t.icon,t.title,t.children);break;case"image":a=this.createImage(t.key,t.icon,t.title);break;default:continue}e.push(a)}t.push({title:$l10n(i.title??""),rows:e})}return t}getListView(e,t=this.footer){return{type:"list",props:{id:this.name,style:2,separatorInset:$insets(0,this.iconSize+2*this.edgeOffset,0,this.edgeOffset),bgcolor:$58e2f5443faff7c0$require$UIKit.scrollViewBackgroundColor,footer:t,data:this.#c(e??this.structure)},layout:$layout.fill,events:{rowHeight:(e,t)=>(e.object(t)?.props?.info??{}).rowHeight??this.rowHeight}}}getNavigationView(){const e=new $58e2f5443faff7c0$require$NavigationView;return e.setView(this.getListView(this.structure)).navigationBarTitle($l10n("SETTING")),this.hasSectionTitle(this.structure)&&e.navigationBar.setContentViewHeightOffset(-10),e}getPage(){return this.getNavigationView().getPage()}}module.exports={Setting:Setting}})),parcelRequire.register("fYz8N",(function(e,t){e.exports={Controller:class{events={};setEvents(e){return Object.keys(e).forEach((t=>this.setEvent(t,e[t]))),this}setEvent(e,t){return this.events[e]=t,this}callEvent(e,...t){"function"==typeof this.events[e]&&this.events[e](...t)}}}})),parcelRequire.register("8aDdQ",(function(e,t){class i extends Error{constructor(e){super(`Parameter [${e}] is required.`),this.name="FileStorageParameterError"}}class a extends Error{constructor(e){super(`File not found: ${e}`),this.name="FileStorageFileNotFoundError"}}class r{basePath;constructor({basePath:e="storage"}={}){this.basePath=e,this.#u(this.basePath)}#u(e){$file.isDirectory(e)||$file.mkdir(e)}filePath(e="",t=!0){e.startsWith("/")&&(e=e.substring(1));let i="";if(!(e=`${this.basePath}/${e}`).endsWith("/")){const t=e.lastIndexOf("/");e.lastIndexOf(".")>t&&(i=e.substring(t+1),e=e.substring(0,t+1))}return t&&this.#u(e),e+i}exists(e=""){return e=this.filePath(e,!1),!!$file.exists(e)}write(e="",t){return new Promise(((i,a)=>{try{const r=this.writeSync(e,t);r?i(r):a(r)}catch(e){a(e)}}))}writeSync(e="",t){if(!t)throw new i("data");return $file.write({data:t,path:this.filePath(e)})}read(e=""){return new Promise(((t,i)=>{try{const a=this.readSync(e);a?t(a):i()}catch(e){i(e)}}))}readSync(e=""){if(e=this.filePath(e),!$file.exists(e))throw new a(e);return $file.isDirectory(e)?$file.list(e):$file.read(e)}readAsJSON(e="",t=null){try{const t=this.readSync(e)?.string;return JSON.parse(t)}catch(e){return t}}static readFromRoot(e=""){return new Promise(((t,i)=>{try{const a=r.readFromRootSync(e);a?t(a):i()}catch(e){i(e)}}))}static readFromRootSync(e=""){if(!e)throw new i("path");if(!$file.exists(e))throw new a(e);return $file.isDirectory(e)?$file.list(e):$file.read(e)}static readFromRootAsJSON(e="",t=null){try{const t=r.readFromRootSync(e)?.string;return JSON.parse(t)}catch(e){return t}}delete(e=""){return $file.delete(this.filePath(e,!1))}copy(e,t){e=this.filePath(e),t=this.filePath(t),$file.copy({src:e,dst:t})}move(e,t){e=this.filePath(e),t=this.filePath(t),$file.move({src:e,dst:t})}}e.exports={FileStorageParameterError:i,FileStorageFileNotFoundError:a,FileStorage:r}})),parcelRequire.register("cgaQ6",(function(e,t){var i=parcelRequire("czAIJ").VERSION;class a{startTime=Date.now();isUseJsboxNav=!1;title=$addin?.current?.name;constructor(){$app.isDebugging&&this.debug()}static isTaio=$app.info.bundleID.includes("taio");static l10n(e,t,i=!0){if("string"==typeof t){const e={};t.split(";").forEach((t=>{if(""!==(t=t.trim())){const i=t.split("=");e[i[0].trim().slice(1,-1)]=i[1].trim().slice(1,-1)}})),t=e}const a=$app.strings;a[e]=i?Object.assign($app.strings[e],t):Object.assign(t,$app.strings[e]),$app.strings=a}static compressImage(e,t=921600){const i=$imagekit.info(e);if(i.height*i.width>t){const a=t/(i.height*i.width);e=$imagekit.scaleBy(e,a)}return e}static objectEqual(e,t){let i=Object.getOwnPropertyNames(e),r=Object.getOwnPropertyNames(t);if(i.length!==r.length)return!1;for(let r=0;re?i[e]:0,r=isNaN(Number(t))?t.charCodeAt():Number(t),o=a.length>e?a[e]:0,n=isNaN(Number(o))?o.charCodeAt():Number(o);if(rn){s=1;break}}return s}static deleteConfirm(e,t){$ui.alert({title:$l10n("DELETE_CONFIRM_TITLE"),message:e,actions:[{title:$l10n("DELETE"),style:$alertActionType.destructive,handler:()=>{t()}},{title:$l10n("CANCEL")}]})}static bytesToSize(e){if(0===e)return"0 B";const t=Math.floor(Math.log(e)/Math.log(1024));return(e/Math.pow(1024,t)).toPrecision(3)+" "+["B","KB","MB","GB","TB","PB","EB","ZB","YB"][t]}debug(e,t){this.debugMode=!0,$app.idleTimerDisabled=!0,"function"==typeof e&&(this.debugPrint=e),"function"==typeof t&&(this.debugError=t),this.print("You are running EasyJsBox in debug mode.")}print(e){this.debugMode&&("function"==typeof this.debugPrint?this.debugPrint(e):console.log(e))}error(e){this.debugMode&&("function"==typeof this.debugError?this.debugError(e):console.error(e))}useJsboxNav(){return this.isUseJsboxNav=!0,this}setTitle(e){this.isUseJsboxNav&&($ui.title=e),this.title=e}setNavButtons(e){this.navButtons=e}openInJsbox(){$app.openURL(`jsbox://run?name=${this.title}`)}UIRender(e){try{e.props=Object.assign({title:this.title,navBarHidden:!this.isUseJsboxNav,navButtons:this.navButtons??[],statusBarStyle:0},e.props),e.events||(e.events={});const t=e.events.layoutSubviews,{UIKit:i}=parcelRequire("45Ip7");e.events.layoutSubviews=()=>{$app.notify({name:"interfaceOrientationEvent",object:{statusBarOrientation:i.statusBarOrientation,isHorizontal:i.isHorizontal}}),"function"==typeof t&&t()},$ui.render(e)}catch(e){this.print(e)}}async checkUpdate(){const e=await $http.get("https://raw.githubusercontent.com/ipuppet/EasyJsBox/dev/src/version.js");if(e.error)throw e.error;const t=srcRes.data.match(/.*VERSION.?\"([0-9\.]+)\"/)[1];if(this.print(`easy-jsbox latest version: ${t}`),a.versionCompare(t,i)>0){const e=await $http.get("https://raw.githubusercontent.com/ipuppet/EasyJsBox/dev/dist/easy-jsbox.js");if(e.error)throw e.error;return e.data}return!1}}a.l10n("zh-Hans",{DELETE_CONFIRM_TITLE:"删除前确认"},!1),a.l10n("en",{DELETE_CONFIRM_TITLE:"Delete Confirmation"},!1),e.exports={Kernel:a}})),parcelRequire.register("czAIJ",(function(e,t){e.exports={VERSION:"1.3.3"}})),parcelRequire.register("aXWmO",(function(e,t){var i=parcelRequire("6Xrbz").ValidationError,a=parcelRequire("liCrE").View,r=parcelRequire("45Ip7").UIKit,s=parcelRequire("12xzj").NavigationView,o=parcelRequire("dcStC").NavigationBar,n=parcelRequire("gAYmG").BarButtonItem;class l extends Error{constructor(){super("Please call setView(view) first."),this.name="SheetAddNavBarError"}}class h extends i{constructor(e,t){super(e,t),this.name="SheetViewTypeError"}}class c extends a{#p=()=>{};#d=()=>{};style=c.UIModalPresentationStyle.PageSheet;#g=!1;static UIModalPresentationStyle={Automatic:-2,FullScreen:0,PageSheet:1,FormSheet:2,CurrentContext:3,Custom:4,OverFullScreen:5,OverCurrentContext:6,Popover:7,BlurOverFullScreen:8};navigationView;init(){const{width:e,height:t}=$device.info.screen,i=$objc("UIView").invoke("initWithFrame",$rect(0,0,e,t)),a=$objc("UIViewController").invoke("alloc.init"),s=a.$view();return s.$setBackgroundColor(r.primaryViewBackgroundColor),s.$addSubview(i),a.$setModalPresentationStyle(this.style),a.$setModalInPresentation(this.#g),this.#p=()=>{s.jsValue().add(this.navigationView?.getPage().definition??this.view),$ui.vc.ocValue().invoke("presentViewController:animated:completion:",a,!0,void 0)},this.#d=()=>a.invoke("dismissViewControllerAnimated:completion:",!0,void 0),this}preventDismiss(){return this.#g=!0,this}setStyle(e){return this.style=e,this}setView(e={}){if("object"!=typeof e)throw new h("view","object");return this.view=e,this}addNavBar({title:e="",popButton:t={title:$l10n("DONE")},rightButtons:i=[]}={}){if(void 0===this.view)throw new l;this.navigationView=new s;const a=new n;a.setEvents(Object.assign({tapped:()=>{this.dismiss(),"function"==typeof t.tapped&&t.tapped()}},t.events)).setAlign(r.align.left).setSymbol(t.symbol).setTitle(t.title).setColor(t.color).setMenu(t.menu);const h=a.definition.views[0];return h.layout=(e,t)=>{e.left.equalTo(t.super.safeArea).offset(15),e.centerY.equalTo(t.super.safeArea)},this.navigationView.navigationBar.setLargeTitleDisplayMode(o.largeTitleDisplayModeNever).pageSheetMode(),this.navigationView.navigationBarItems.addPopButton("",h).setRightButtons(i),this.navigationView.setView(this.view).navigationBarTitle(e),this.view.props?.bgcolor&&this.navigationView?.getPage().setProp("bgcolor",this.view.props?.bgcolor),this}present(){this.#p()}dismiss(){this.#d()}}e.exports={Sheet:c}})),parcelRequire.register("6Xrbz",(function(e,t){class i extends Error{constructor(e,t){super(`The type of the parameter '${e}' must be '${t}'`),this.name="ValidationError"}}e.exports={ValidationError:i}})),parcelRequire.register("liCrE",(function(e,t){var i=parcelRequire("45Ip7").UIKit;class a{id=$text.uuid;type;props;views;events;layout;#$=void 0;#f=null;constructor({type:e="view",props:t={},views:i=[],events:a={},layout:r=$layout.fill}={}){this.type=e,this.props=t,this.views=i,this.events=a,this.layout=r,this.props.id?this.id=this.props.id:this.props.id=this.id}static create(e){return new this(e)}static createFromViews(e){return new this({views:e})}get scrollableView(){return this.scrollable?this.#f:null}set scrollableView(e){this.#f=e}get scrollable(){if(void 0===this.#$)if(this.#$=!1,i.scrollViewList.indexOf(this.type)>-1)this.scrollableView=this,this.#$=!0;else if(this.views.length>0){const e=t=>{if(!this.#$&&t?.length>0)for(let r=0;r-1)return typeof t[r]!==a&&(t[r]=a.create(t[r])),this.scrollableView=t[r],void(this.#$=!0);e(t[r].views)}};e(this.views)}return this.#$}set scrollable(e){throw new Error("[scrollable] is readonly prop.")}setProps(e){return Object.keys(e).forEach((t=>this.setProp(t,e[t]))),this}setProp(e,t){return"id"===e&&(this.id=t),this.props[e]=t,this}setViews(e){return this.views=e,this.#$=void 0,this}setEvents(e){return Object.keys(e).forEach((t=>this.setEvent(t,e[t]))),this}setEvent(e,t){return this.events[e]=t,this}eventMiddleware(e,t){const i=this.events[e];return this.events[e]=(...e)=>{"function"==typeof i&&t(i,...e)},this}assignEvent(e,t){const i=this.events[e];return this.events[e]=(...e)=>{"function"==typeof i&&i(...e),t(...e)},this}setLayout(e){return this.layout=e,this}getView(){return this}get definition(){return this.getView()}}e.exports={View:a,PageView:class extends a{constructor(e={}){super(e),this.activeStatus=!0}show(){$(this.props.id).hidden=!1,this.activeStatus=!0}hide(){$(this.props.id).hidden=!0,this.activeStatus=!1}setHorizontalSafeArea(e){return this.horizontalSafeArea=e,this}#b(e,t){e.top.bottom.equalTo(t.super),this.horizontalSafeArea?e.left.right.equalTo(t.super.safeArea):e.left.right.equalTo(t.super)}getView(){return this.layout=this.#b,this.props.clipsToBounds=!0,this.props.hidden=!this.activeStatus,super.getView()}}}})),parcelRequire.register("12xzj",(function(e,t){var i=parcelRequire("fYz8N").Controller,a=parcelRequire("liCrE"),r=a.View,s=a.PageView,o=parcelRequire("6Xrbz").ValidationError,n=parcelRequire("cgaQ6").Kernel,l=parcelRequire("45Ip7").UIKit,h=parcelRequire("dcStC"),c=h.NavigationBar,u=h.NavigationBarController,p=parcelRequire("gAYmG").NavigationBarItems;class d extends o{constructor(e,t){super(e,t),this.name="NavigationViewTypeError"}}e.exports={NavigationView:class extends i{page;navigationController=new u;navigationBar=new c;navigationBarItems=new p;constructor(){super(),this.navigationBar.navigationBarItems=this.navigationBarItems,this.navigationController.navigationBar=this.navigationBar}navigationBarTitle(e){return this.navigationBar.setTitle(e),this}setView(e){if("object"!=typeof e)throw new d("view","object");return this.view=r.create(e),this}#v(){if(!(this.view instanceof r))throw new d("view","View");const e=this.view.scrollableView,t=$app.isDebugging||n.isTaio?0:l.topSafeAreaInsets,i=this.navigationBar.largeTitleDisplayMode===c.largeTitleDisplayModeNever?this.navigationBar.navigationBarNormalHeight:this.navigationBar.navigationBarLargeTitleHeight;let a=this.navigationBar.contentViewHeightOffset+i;if(this.navigationBarItems.titleView&&(a+=this.navigationBarItems.titleView.topOffset,a+=this.navigationBarItems.titleView.height,a+=this.navigationBarItems.titleView.bottomOffset),!this.view.scrollable||!1===e.props.associateWithNavigationBar)return void(this.view.layout=(e,i)=>{e.left.right.equalTo(i.super.safeArea),e.bottom.equalTo(i.super);let r=a-this.navigationBar.contentViewHeightOffset;l.isHorizontal&&!l.isLargeScreen||!this.navigationBar.topSafeArea||(r+=t),e.top.equalTo(r)});e.props.stickyHeader&&(a-=i,a+=this.navigationBar.largeTitleFontHeight),e.props.header?e.props.header={type:"view",props:{height:a+(e.props.header?.props?.height??0)},views:[{type:"view",props:{clipsToBounds:!0},views:[e.props.header],layout:(e,t)=>{e.top.equalTo(a),e.bottom.width.equalTo(t.super)}}]}:e.props.header={props:{height:a}},e.props.footer=Object.assign({props:{}},e.props.footer??{}),e.props.footer.props.height=(this.navigationBarItems.fixedFooterView?.height??0)+(e.props.footer.props?.height??0);const s=this.navigationBarItems.isPinTitleView?this.navigationBarItems.titleView.height+this.navigationBarItems.titleView.bottomOffset+this.navigationBar.contentViewHeightOffset:0;if(e.props.indicatorInsets){const t=e.props.indicatorInsets;e.props.indicatorInsets=$insets(t.top+this.navigationBar.navigationBarNormalHeight+s,t.left,t.bottom+(this.navigationBarItems.fixedFooterView?.height??0),t.right)}else e.props.indicatorInsets=$insets(this.navigationBar.navigationBarNormalHeight+s,0,this.navigationBarItems.fixedFooterView?.height??0,0);e.layout=(t,i)=>{e.props.stickyHeader?t.top.equalTo(i.super.safeArea).offset(this.navigationBar.navigationBarNormalHeight):t.top.equalTo(i.super),t.left.right.equalTo(i.super.safeArea),t.bottom.equalTo(i.super)},e.assignEvent("didScroll",(i=>{let a=i.contentOffset.y;l.isHorizontal&&!l.isLargeScreen||!this.navigationBar.topSafeArea||e.props.stickyHeader||(a+=t),this.navigationController.didScroll(a)})).assignEvent("didEndDragging",((i,a)=>{let r=i.contentOffset.y,s=0;l.isHorizontal&&!l.isLargeScreen||!this.navigationBar.topSafeArea||e.props.stickyHeader||(r+=t,s=t),this.navigationController.didEndDragging(r,a,((...e)=>i.scrollToOffset(...e)),s)})).assignEvent("didEndDecelerating",((...t)=>{t[0].tracking||e.events?.didEndDragging(...t)}))}#w(){if(this.navigationBar.prefersLargeTitles){this.#v();let e={};if(this.navigationBarItems.titleView){const t=this.navigationBar.largeTitleDisplayMode===c.largeTitleDisplayModeNever?1:0;e=r.create({views:[this.navigationBar.backgroundColor?{type:"view",props:{alpha:t,bgcolor:this.navigationBar.backgroundColor,id:this.navigationBar.id+"-title-view-background"},layout:$layout.fill}:l.blurBox({alpha:t,id:this.navigationBar.id+"-title-view-background"}),l.separatorLine({id:this.navigationBar.id+"-title-view-underline",alpha:t}),this.navigationBarItems.titleView.definition],layout:(e,t)=>{e.top.equalTo(t.prev.bottom),e.width.equalTo(t.super),e.height.equalTo(this.navigationBarItems.titleView.topOffset+this.navigationBarItems.titleView.height+this.navigationBarItems.titleView.bottomOffset)}})}this.page=s.createFromViews([this.view,this.navigationBar.getLargeTitleView(),e,this.navigationBar.getNavigationBarView(),this.navigationBarItems.fixedFooterView?.definition??{}])}else this.page=s.createFromViews([this.view]);this.view.props?.bgcolor?this.page.setProp("bgcolor",this.view.props.bgcolor):this.page.setProp("bgcolor",l.defaultBackgroundColor(this.view.type))}getPage(){return this.page||this.#w(),this.page}}}})),parcelRequire.register("dcStC",(function(e,t){var i=parcelRequire("liCrE").View,a=parcelRequire("fYz8N").Controller,r=parcelRequire("45Ip7").UIKit;parcelRequire("gAYmG").BarButtonItem;class s extends i{static largeTitleDisplayModeAutomatic=0;static largeTitleDisplayModeAlways=1;static largeTitleDisplayModeNever=2;static pageSheetNavigationBarHeight=56;navigationBarItems;title="";prefersLargeTitles=!0;largeTitleDisplayMode=s.largeTitleDisplayModeAutomatic;largeTitleFontSize=34;largeTitleFontFamily="bold";largeTitleFontHeight=$text.sizeThatFits({text:"A",width:100,font:$font(this.largeTitleFontFamily,this.largeTitleFontSize)}).height;navigationBarTitleFontSize=17;topSafeArea=!0;contentViewHeightOffset=10;navigationBarNormalHeight=r.NavigationBarNormalHeight;navigationBarLargeTitleHeight=r.NavigationBarLargeTitleHeight;pageSheetMode(){return this.navigationBarLargeTitleHeight-=this.navigationBarNormalHeight,this.navigationBarNormalHeight=s.pageSheetNavigationBarHeight,this.navigationBarLargeTitleHeight+=this.navigationBarNormalHeight,this.topSafeArea=!1,this}setTopSafeArea(){return this.topSafeArea=!0,this}removeTopSafeArea(){return this.topSafeArea=!1,this}setLargeTitleDisplayMode(e){return this.largeTitleDisplayMode=e,this}setBackgroundColor(e){return this.backgroundColor=e,this}setTitle(e){return this.title=e,this}setPrefersLargeTitles(e){return this.prefersLargeTitles=e,this}setContentViewHeightOffset(e){return this.contentViewHeightOffset=e,this}getLargeTitleView(){return this.prefersLargeTitles&&this.largeTitleDisplayMode!==s.largeTitleDisplayModeNever?{type:"label",props:{id:this.id+"-large-title",text:this.title,textColor:r.textColor,align:$align.left,font:$font(this.largeTitleFontFamily,this.largeTitleFontSize),line:1},layout:(e,t)=>{e.left.equalTo(t.super.safeArea).offset(15),e.height.equalTo(this.largeTitleFontHeight),e.top.equalTo(t.super.safeAreaTop).offset(this.navigationBarNormalHeight)}}:{props:{id:this.id+"-large-title"},layout:(e,t)=>{e.left.top.right.inset(0),e.bottom.equalTo(t.super.safeAreaTop).offset(this.navigationBarNormalHeight)}}}getNavigationBarView(){const e=(e,t)=>{let i=0;const a=[];return e.forEach((e=>{i+=e.width,a.push(e.definition)})),i+=e[0]?.edges??0,e.length>0?{type:"view",views:a,layout:(e,a)=>{e.top.equalTo(a.super.safeAreaTop),e.bottom.equalTo(a.super.safeAreaTop).offset(this.navigationBarNormalHeight),t===r.align.left?e.left.equalTo(a.super.safeArea):e.right.equalTo(a.super.safeArea),e.width.equalTo(i)}}:{}},t=e(this.navigationBarItems.rightButtons,r.align.right),i=this.navigationBarItems.popButtonView??e(this.navigationBarItems.leftButtons,r.align.left),a=this.prefersLargeTitles,o=!this.prefersLargeTitles||this.largeTitleDisplayMode===s.largeTitleDisplayModeNever;return{type:"view",props:{id:this.id+"-navigation",bgcolor:$color("clear")},layout:(e,t)=>{e.left.top.right.inset(0),e.bottom.equalTo(t.super.safeAreaTop).offset(this.navigationBarNormalHeight)},views:[this.backgroundColor?{type:"view",props:{hidden:a,bgcolor:this.backgroundColor,id:this.id+"-background"},layout:$layout.fill}:r.blurBox({hidden:a,id:this.id+"-background"}),r.separatorLine({id:this.id+"-underline",alpha:a?0:1}),{type:"view",props:{alpha:0,bgcolor:$color("clear"),id:this.id+"-large-title-mask"},events:{ready:e=>{e.bgcolor=$(this.id+"-large-title")?.prev.bgcolor}},layout:$layout.fill},{type:"label",props:{id:this.id+"-small-title",alpha:o?1:0,text:this.title,font:$font(this.largeTitleFontFamily,this.navigationBarTitleFontSize),align:$align.center,bgcolor:$color("clear"),textColor:r.textColor},layout:(e,t)=>{e.left.right.inset(0),e.height.equalTo(20),e.centerY.equalTo(t.super.safeArea)}}].concat(t,i)}}}class o extends a{static largeTitleViewSmallMode=0;static largeTitleViewLargeMode=1;navigationBar;updateSelector(){this.selector={navigation:$(this.navigationBar.id+"-navigation"),largeTitleView:$(this.navigationBar.id+"-large-title"),smallTitleView:$(this.navigationBar.id+"-small-title"),underlineView:this.navigationBar.navigationBarItems.isPinTitleView?$(this.navigationBar.id+"-title-view-underline"):$(this.navigationBar.id+"-underline"),largeTitleMaskView:$(this.navigationBar.id+"-large-title-mask"),backgroundView:$(this.navigationBar.id+"-background"),titleViewBackgroundView:$(this.navigationBar.id+"-title-view-background")}}toNormal(e=!0){this.updateSelector(),this.selector.backgroundView.hidden=!1,$ui.animate({duration:.2,animation:()=>{this.selector.underlineView.alpha=1,this.selector.smallTitleView.alpha=1,this.selector.largeTitleView.alpha=0}}),e&&this.navigationBar.navigationBarItems&&(this.navigationBar.largeTitleDisplayMode=s.largeTitleDisplayModeNever)}toLargeTitle(e=!0){this.updateSelector(),this.selector.backgroundView.hidden=!0,$ui.animate({duration:.2,animation:()=>{this.selector.underlineView.alpha=0,this.selector.smallTitleView.alpha=0,this.selector.largeTitleView.alpha=1}}),e&&this.navigationBar.navigationBarItems&&(this.navigationBar.largeTitleDisplayMode=s.largeTitleDisplayModeAlways)}#m(e){const t=e===o.largeTitleViewSmallMode;this.selector.largeTitleView.alpha=t?0:1,$ui.animate({duration:.2,animation:()=>{this.selector.smallTitleView.alpha=t?1:0}})}#y(e){if(this.selector.largeTitleView.updateLayout(((t,i)=>{this.navigationBar.navigationBarNormalHeight-e>0?t.top.equalTo(i.super.safeAreaTop).offset(this.navigationBar.navigationBarNormalHeight-e):t.top.equalTo(i.super.safeAreaTop).offset(0)})),e>0)e>=this.navigationBar.navigationBarNormalHeight?this.#m(o.largeTitleViewSmallMode):this.#m(o.largeTitleViewLargeMode);else{this.#m(o.largeTitleViewLargeMode);let t=this.navigationBar.largeTitleFontSize-.04*e;t>40&&(t=40),this.selector.largeTitleView.font=$font(this.navigationBar.largeTitleFontFamily,t)}}#T(e){const t=this.navigationBar.largeTitleDisplayMode===s.largeTitleDisplayModeNever?5:this.navigationBar.navigationBarNormalHeight,i=void 0!==this.selector.titleViewBackgroundView;if(e>t){this.selector.backgroundView.hidden=!1;const a=()=>{i&&this.navigationBar.navigationBarItems.isPinTitleView&&(this.selector.titleViewBackgroundView.alpha=1),this.selector.largeTitleMaskView.alpha=0,this.selector.underlineView.alpha=1};(e-t)/3>=1?a():$ui.animate({duration:.2,animation:()=>{a()}})}else this.selector.largeTitleMaskView.alpha=e>0?1:0,this.selector.underlineView.alpha=0,i&&(this.selector.titleViewBackgroundView.alpha=0),this.selector.backgroundView.hidden=!0}didScroll(e){if(!this.navigationBar.prefersLargeTitles)return;const t=this.navigationBar.largeTitleDisplayMode;if(t!==s.largeTitleDisplayModeAlways)if(this.updateSelector(),t===s.largeTitleDisplayModeAutomatic){if(!this.navigationBar.navigationBarItems?.isPinTitleView&&(this.navigationBar.navigationBarItems?.titleView?.controller.didScroll(e),e>0)){(e-=this.navigationBar.navigationBarItems?.titleView?.height??0)<0&&(e=0)}this.#y(e),this.#T(e)}else t===s.largeTitleDisplayModeNever&&this.#T(e)}didEndDragging(e,t,i,a){if(!this.navigationBar.prefersLargeTitles)return;const r=this.navigationBar.largeTitleDisplayMode;if(r!==s.largeTitleDisplayModeAlways&&(this.updateSelector(),r===s.largeTitleDisplayModeAutomatic)){let r=0;this.navigationBar.navigationBarItems?.isPinTitleView||(this.navigationBar.navigationBarItems?.titleView?.controller.didEndDragging(e,t,i,a),r=this.navigationBar.navigationBarItems?.titleView?.height??0,e-=r),e>=0&&e<=this.navigationBar.largeTitleFontHeight&&i($point(0,e>=this.navigationBar.largeTitleFontHeight/2?this.navigationBar.navigationBarNormalHeight+r-a:r-a))}}}e.exports={NavigationBar:s,NavigationBarController:o}})),parcelRequire.register("gAYmG",(function(e,t){var i=parcelRequire("liCrE").View,a=parcelRequire("45Ip7").UIKit;class r extends i{static#q;edges=15;iconSize=$size(23,23);fontSize=16;color=a.textColor;title;symbol;align=a.align.right;get width(){if(this.title){const e=$text.sizeThatFits({text:this.title,width:a.windowSize.width,font:$font(this.fontSize)});return Math.ceil(e.width)+this.edges}return this.iconSize.width+this.edges}static get style(){return void 0===this.#q&&(this.#q=new r),this.#q}setEdges(e){return this.edges=e,this}setFontSize(e){return this.fontSize=e,this}setColor(e=a.textColor){return this.color=e,this}setTitle(e){return this.title=e,this}setSymbol(e){return this.symbol=e,this}setMenu(e){return this.menu=e,this}setAlign(e){return this.align=e,this}setLoading(e){e?($(this.id).hidden=!0,$("spinner-"+this.id).hidden=!1):($(this.id).hidden=!1,$("spinner-"+this.id).hidden=!0)}#B(){const e=$(`icon-button-${this.id}`),t=$(`icon-checkmark-${this.id}`);e.alpha=0,$(this.id).hidden=!1,$("spinner-"+this.id).hidden=!0,$ui.animate({duration:.6,animation:()=>{t.alpha=1},completion:()=>{$delay(.3,(()=>$ui.animate({duration:.6,animation:()=>{t.alpha=0},completion:()=>{$ui.animate({duration:.4,animation:()=>{e.alpha=1},completion:()=>{e.alpha=1}})}})))}})}getView(){const e=this.events.tapped;return this.events.tapped=t=>{e&&e({start:()=>this.setLoading(!0),done:()=>this.#B(),cancel:()=>this.setLoading(!1)},t)},{type:"view",props:{info:{align:this.align}},views:[{type:"button",props:Object.assign({id:this.id,bgcolor:$color("clear"),font:$font(this.fontSize),titleColor:this.color,contentEdgeInsets:$insets(0,0,0,0),titleEdgeInsets:$insets(0,0,0,0),imageEdgeInsets:$insets(0,0,0,0)},this.menu?{menu:this.menu}:{},this.title?{title:this.title}:{},this.props),views:[{type:"image",props:Object.assign({id:`icon-button-${this.id}`,hidden:void 0===this.symbol,tintColor:this.color},void 0===this.symbol?{}:"string"==typeof this.symbol?{symbol:this.symbol}:{data:this.symbol.png}),layout:(e,t)=>{e.center.equalTo(t.super),e.size.equalTo(this.iconSize)}},{type:"image",props:{id:`icon-checkmark-${this.id}`,alpha:0,tintColor:this.color,symbol:"checkmark"},layout:(e,t)=>{e.center.equalTo(t.super),e.size.equalTo(this.iconSize)}}],events:this.events,layout:$layout.fill},{type:"spinner",props:{id:"spinner-"+this.id,loading:!0,hidden:!0},layout:$layout.fill}],layout:(e,t)=>{if(e.size.equalTo($size(this.width,a.NavigationBarNormalHeight)),e.centerY.equalTo(t.super),t.prev&&t.prev?.info?.align===this.align)this.align===a.align.right?e.right.equalTo(t.prev.left):e.left.equalTo(t.prev.right);else{const t=this.edges/2;this.align===a.align.right?e.right.inset(t):e.left.inset(t)}}}}static creat({id:e,symbol:t,title:i,tapped:s,menu:o,events:n,color:l,align:h=a.align.right}={}){const c=new r;return c.setEvents(Object.assign({tapped:s},n)).setAlign(h).setSymbol(t).setTitle(i).setColor(l).setMenu(o),e&&c.setProp("id",e),c}}e.exports={BarTitleView:class extends i{controller={};setController(e){return this.controller=e,this}},BarButtonItem:r,NavigationBarItems:class{rightButtons=[];leftButtons=[];#S={};hasbutton=!1;isPinTitleView=!1;setTitleView(e){return this.titleView=e,this}pinTitleView(){return this.isPinTitleView=!0,this}setFixedFooterView(e){return this.fixedFooterView=e,this}setRightButtons(e){return e.forEach((e=>this.addRightButton(e))),this.hasbutton||(this.hasbutton=!0),this}setLeftButtons(e){return e.forEach((e=>this.addLeftButton(e))),this.hasbutton||(this.hasbutton=!0),this}addRightButton({id:e,symbol:t,title:i,tapped:s,menu:o,events:n,color:l}={}){const h=r.creat({id:e,symbol:t,title:i,tapped:s,menu:o,events:n,color:l,align:a.align.right});return this.rightButtons.push(h),this.#S[e??h.id]=h,this.hasbutton||(this.hasbutton=!0),this}addLeftButton({id:e,symbol:t,title:i,tapped:s,menu:o,events:n,color:l}={}){const h=r.creat({id:e,symbol:t,title:i,tapped:s,menu:o,events:n,color:l,align:a.align.left});return this.leftButtons.push(h),this.#S[e??h.id]=h,this.hasbutton||(this.hasbutton=!0),this}getButton(e){return this.#S[e]}addPopButton(e,t,i){return e||(e=$l10n("BACK")),this.popButtonView=t??{type:"button",props:{bgcolor:$color("clear"),symbol:"chevron.left",tintColor:a.linkColor,title:` ${e}`,titleColor:a.linkColor,font:$font("bold",16)},layout:(e,t)=>{e.left.equalTo(t.super.safeArea).offset(r.style.edges),e.centerY.equalTo(t.super.safeArea)},events:{tapped:()=>{$ui.pop(),"function"==typeof i&&i()}}},this}removePopButton(){return this.popButtonView=void 0,this}}}})),parcelRequire.register("gMc1q",(function(e,t){var i=parcelRequire("fYz8N").Controller;e.exports={ViewController:class extends i{#C=[];#I(e){e.callEvent("onPop"),this.callEvent("onPop",e),this.#C.pop()}push(e){const t=this.#C[this.#C.length-1];e.navigationBarItems.addPopButton(t?.navigationBar.title),this.#C.push(e),$ui.push({props:{statusBarStyle:0,navBarHidden:!0},events:{dealloc:()=>{this.#I(e)}},views:[e.getPage().definition],layout:$layout.fill})}}}})),String.prototype.trim=function(e,t){return e?"l"===t?this.replace(new RegExp("^\\"+e+"+","g"),""):"r"===t?this.replace(new RegExp("\\"+e+"+$","g"),""):this.replace(new RegExp("^\\"+e+"+|\\"+e+"+$","g"),""):this.replace(/^\s+|\s+$/g,"")};var $czAIJ=parcelRequire("czAIJ"),$bb0fea222fc5aea5$require$VERSION=$czAIJ.VERSION,$fYz8N=parcelRequire("fYz8N"),$bb0fea222fc5aea5$require$Controller=$fYz8N.Controller,$272f042430a952c6$exports={},$45Ip7=parcelRequire("45Ip7"),$272f042430a952c6$require$UIKit=$45Ip7.UIKit,$aXWmO=parcelRequire("aXWmO"),$272f042430a952c6$require$Sheet=$aXWmO.Sheet,$cgaQ6=parcelRequire("cgaQ6"),$272f042430a952c6$require$Kernel=$cgaQ6.Kernel,$12xzj=parcelRequire("12xzj"),$272f042430a952c6$require$NavigationView=$12xzj.NavigationView,$dcStC=parcelRequire("dcStC"),$272f042430a952c6$require$NavigationBar=$dcStC.NavigationBar;class $272f042430a952c6$var$FileManager{viewController;constructor(){this.listId="file-manager-list",this.edges=10,this.iconSize=25,this.loadL10n()}loadL10n(){$272f042430a952c6$require$Kernel.l10n("zh-Hans",{FILE_MANAGER_DELETE_CONFIRM_MSG:"确认要删除吗",DELETE:"删除",CANCEL:"取消",CLOSE:"关闭",SHARE:"分享",SAVE:"保存",SAVE_SUCCESS:"保存成功"},!1),$272f042430a952c6$require$Kernel.l10n("en",{FILE_MANAGER_DELETE_CONFIRM_MSG:"Are you sure you want to delete",DELETE:"Delete",CANCEL:"Cancel",CLOSE:"Close",SHARE:"Share",SAVE:"Save",SAVE_SUCCESS:"Save Success"},!1)}setViewController(e){this.viewController=e}get menu(){return{items:[{title:$l10n("SHARE"),symbol:"square.and.arrow.up",handler:async(e,t)=>{const i=e.object(t).info.info;$share.sheet([$file.absolutePath(i.path)])}}]}}delete(e){$file.delete(e.path)}edit(e){const t=$file.read(e.path);if(t.image)$quicklook.open({image:t.image});else{const i=new $272f042430a952c6$require$Sheet,a=$text.uuid;i.setView({type:"code",layout:$layout.fill,props:{id:a,lineNumbers:!0,theme:$device.isDarkMode?"atom-one-dark":"atom-one-light",text:t.string,insets:$insets(15,15,15,15)}}).addNavBar({title:e.file,popButton:{title:$l10n("CLOSE")},rightButtons:[{title:$l10n("SAVE"),tapped:()=>{$file.write({data:$data({string:$(a).text}),path:e.path}),$ui.success($l10n("SAVE_SUCCESS"))}}]}),i.init().present()}}getFiles(e=""){return $file.list(e).map((t=>{const i=e+"/"+t,a=$file.isDirectory(i);return{info:{info:{path:i,file:t,isDirectory:a}},icon:{symbol:a?"folder.fill":"doc"},name:{text:t},size:{text:a?"":"--"}}})).sort(((e,t)=>e.info.info.isDirectory!==t.info.info.isDirectory?e.info.info.isDirectory?-1:1:e.info.info.isDirectory===t.info.info.isDirectory?e.info.info.file.localeCompare(t.info.info.file):void 0))}async loadFileSize(e){return e.map(((t,i)=>{const a=t.info.info;if(!a.isDirectory)try{e[i].size.text=$272f042430a952c6$require$Kernel.bytesToSize($file.read(a.path).info.size)}catch(t){e[i].size.text=t}})),e}get listTemplate(){return{props:{bgcolor:$color("clear")},views:[{props:{id:"info"}},{type:"image",props:{id:"icon"},layout:(e,t)=>{e.centerY.equalTo(t.super),e.left.inset(this.edges),e.size.equalTo(this.iconSize)}},{type:"label",props:{id:"name",lines:1},layout:(e,t)=>{e.centerY.equalTo(t.super),e.left.equalTo(t.prev.right).offset(this.edges)}},{type:"label",props:{id:"size",color:$color("secondaryText"),lines:1},layout:(e,t)=>{e.centerY.equalTo(t.super),e.right.inset(this.edges)}}]}}#V(e,t){if(this.viewController){const i=new $272f042430a952c6$require$NavigationView;i.setView(t).navigationBarTitle(e),i.navigationBar.setLargeTitleDisplayMode($272f042430a952c6$require$NavigationBar.largeTitleDisplayModeNever),this.viewController.push(i)}else $272f042430a952c6$require$UIKit.push({title:e,views:[t]})}getListView(e=""){return{type:"list",props:{id:this.listId,menu:this.menu,info:{basePath:e},bgcolor:$272f042430a952c6$require$UIKit.primaryViewBackgroundColor,separatorInset:$insets(0,this.edges,0,0),data:[],template:this.listTemplate,actions:[{title:" "+$l10n("DELETE")+" ",color:$color("red"),handler:(e,t)=>{const i=e.object(t).info.info;$272f042430a952c6$require$Kernel.deleteConfirm($l10n("FILE_MANAGER_DELETE_CONFIRM_MSG")+' "'+i.file+'" ?',(()=>{this.delete(i),e.delete(t)}))}}]},layout:$layout.fill,events:{ready:()=>{const t=this.getFiles(e);$(this.listId).data=t,this.loadFileSize(t).then((e=>{$(this.listId).data=e}))},pulled:async e=>{const t=this.getFiles($(this.listId).info.basePath);$(this.listId).data=t,$(this.listId).data=await this.loadFileSize(t),$delay(.5,(()=>{e.endRefreshing()}))},didSelect:(e,t,i)=>{const a=i.info.info;a.isDirectory?this.#V(a.file,this.getListView(a.path)):this.edit(a)}}}}push(e=""){const t=e.substring(e.lastIndexOf("/"));this.#V(t,this.getListView(e))}}$272f042430a952c6$exports={FileManager:$272f042430a952c6$var$FileManager};var $bb0fea222fc5aea5$require$FileManager=$272f042430a952c6$exports.FileManager,$8aDdQ=parcelRequire("8aDdQ"),$bb0fea222fc5aea5$require$FileStorageParameterError=$8aDdQ.FileStorageParameterError,$bb0fea222fc5aea5$require$FileStorageFileNotFoundError=$8aDdQ.FileStorageFileNotFoundError,$bb0fea222fc5aea5$require$FileStorage=$8aDdQ.FileStorage,$4c192cc93140b629$exports={},$liCrE=parcelRequire("liCrE"),$4c192cc93140b629$require$View=$liCrE.View,$45Ip7=parcelRequire("45Ip7"),$4c192cc93140b629$require$UIKit=$45Ip7.UIKit;class $4c192cc93140b629$var$FixedFooterView extends $4c192cc93140b629$require$View{height=60;getView(){return this.type="view",this.setProp("bgcolor",$4c192cc93140b629$require$UIKit.primaryViewBackgroundColor),this.layout=(e,t)=>{e.left.right.bottom.equalTo(t.super),e.top.equalTo(t.super.safeAreaBottom).offset(-this.height)},this.views=[$4c192cc93140b629$require$View.create({props:this.props,views:this.views,layout:(e,t)=>{e.left.right.top.equalTo(t.super),e.height.equalTo(this.height)}})],this}}$4c192cc93140b629$exports={FixedFooterView:$4c192cc93140b629$var$FixedFooterView};var $bb0fea222fc5aea5$require$FixedFooterView=$4c192cc93140b629$exports.FixedFooterView,$cgaQ6=parcelRequire("cgaQ6"),$bb0fea222fc5aea5$require$Kernel=$cgaQ6.Kernel,$50aa538fe0dbd3b0$exports={},$liCrE=parcelRequire("liCrE"),$50aa538fe0dbd3b0$require$View=$liCrE.View;class $50aa538fe0dbd3b0$var$Matrix extends $50aa538fe0dbd3b0$require$View{titleStyle={font:$font("bold",21),height:30};#E;#x;templateIdByIndex(e){return void 0===this.props.template.views[e]?.props?.id&&(void 0===this.props.template.views[e].props&&(this.props.template.views[e].props={}),this.props.template.views[e].props.id=$text.uuid),this.props.template.views[e].props.id}get templateHiddenStatus(){if(!this.#x){this.#x={};for(let e=0;e(e.items=e.items.map((e=>(Object.keys(e).forEach((t=>{e[t].hidden=this.templateHiddenStatus[t]??!1})),Object.keys(this.templateHiddenStatus).forEach((t=>{e[t]||(e[t]={}),e[t].hidden=this.templateHiddenStatus[t]})),e.__templateProps={hidden:!1},e.__title={hidden:!0},e))),e.title&&e.items.unshift(this.#k(e.title)),e)))}rebuildTemplate(){let e={};void 0!==this.props.template.props&&(e=Object.assign(this.props.template.props,{id:"__templateProps",hidden:!1})),this.props.template.props={};const t=[{type:"view",props:e,layout:$layout.fill},{type:"label",props:{id:"__title",hidden:!0,font:this.titleStyle.font},layout:(e,t)=>{e.top.inset(-this.titleStyle.height/4*3),e.height.equalTo(this.titleStyle.height),e.width.equalTo(t.super.safeArea)}}].concat(this.props.template.views);this.props.template.views=t}insert(e,t=!0){return e.indexPath=this.indexPath(e.indexPath,t),$(this.id).insert(e)}delete(e,t=!0){return e=this.indexPath(e,t),$(this.id).delete(e)}object(e,t=!0){return e=this.indexPath(e,t),$(this.id).object(e)}cell(e,t=!0){return e=this.indexPath(e,t),$(this.id).cell(e)}indexPath(e,t){let i=t?0:1;return"number"==typeof e&&(e=$indexPath(0,e)),e=$indexPath(e.section,e.row+i)}update(e){this.props.data=this.rebuildData(e),$(this.id).data=this.props.data}getView(){return this.props.data=this.rebuildData(this.props.data),this.rebuildTemplate(),this.setEvent("itemSize",((e,t)=>{const i=e.object(t)?.__title?.info;if(i?.title)return $size(Math.max($device.info.screen.width,$device.info.screen.height),0);const a=this.props.columns??2,r=this.props.spacing??15,s=this.props.itemWidth??this.props.itemSize?.width??(e.super.frame.width-r*(a+1))/a,o=this.props.itemHeight??this.props.itemSize?.height??100;return $size(s,o)})),this}}$50aa538fe0dbd3b0$exports={Matrix:$50aa538fe0dbd3b0$var$Matrix};var $bb0fea222fc5aea5$require$Matrix=$50aa538fe0dbd3b0$exports.Matrix,$619319e3f3656d3f$exports={};class $619319e3f3656d3f$var$Request{static method={get:"GET",post:"POST",delete:"DELETE",patch:"PATCH",head:"HEAD"};cacheContainerKey=$addin?.current?.name+".request.cache";#N=!1;#O=!1;cacheLife=2592e6;isLogRequest=!1;timeout=5;logger;constructor(e){"function"==typeof e&&(this.logger=e)}get cache(){return $cache.get(this.cacheContainerKey)??{}}#A(e){this.isLogRequest&&"function"==typeof logger&&this.logger(e)}logRequest(e){return this.isLogRequest=!0,"function"==typeof e&&(this.logger=e),this}getCacheKey(e){return $text.MD5(e)}getCache(e,t=null){return this.cache[e]??t}setCache(e,t){if(!t)return;const i=this.cache;i[e]=t,$cache.set(this.cacheContainerKey,i)}removeCache(e){let t=this.cache;delete t[e],$cache.set(this.cacheContainerKey,t)}clearCache(){$cache.remove(this.cacheContainerKey)}useCache(){return this.#N=!0,this}ignoreCacheExp(){this.#O=!0}async request(e,t,i={},a={},r=this.cacheLife){let s;const o=this.#N&&t===$619319e3f3656d3f$var$Request.method.get;if(o){s=this.getCacheKey(e);const t=this.getCache(s);if(t&&(this.#O||t.exp>Date.now()))return this.#A("get data from cache: "+e),t.data}try{this.#A(`sending request [${t}]: ${e}`);const n=await $http.request({header:a,url:e,method:t,body:i,timeout:this.timeout});if(n.error)throw n.error;if(n?.response?.statusCode>=400){let e=n.data;throw"object"==typeof e&&(e=JSON.stringify(e)),new Error("http error: ["+n.response.statusCode+"] "+e)}return o&&this.setCache(s,{exp:Date.now()+r,data:n}),n}catch(e){throw e.code&&(e=new Error("network error: ["+e.code+"] "+e.localizedDescription)),e}}}$619319e3f3656d3f$exports={Request:$619319e3f3656d3f$var$Request};var $bb0fea222fc5aea5$require$Request=$619319e3f3656d3f$exports.Request,$7D8Kb=parcelRequire("7D8Kb"),$bb0fea222fc5aea5$require$Setting=$7D8Kb.Setting,$aXWmO=parcelRequire("aXWmO"),$bb0fea222fc5aea5$require$Sheet=$aXWmO.Sheet,$7dfcabb1e936a92c$exports={},$liCrE=parcelRequire("liCrE"),$7dfcabb1e936a92c$require$View=$liCrE.View,$7dfcabb1e936a92c$require$PageView=$liCrE.PageView,$fYz8N=parcelRequire("fYz8N"),$7dfcabb1e936a92c$require$Controller=$fYz8N.Controller,$45Ip7=parcelRequire("45Ip7"),$7dfcabb1e936a92c$require$UIKit=$45Ip7.UIKit;class $7dfcabb1e936a92c$var$TabBarCellView extends $7dfcabb1e936a92c$require$View{constructor(e={}){super(e),this.setIcon(e.icon),this.setTitle(e.title),void 0!==e.activeStatus&&(this.activeStatus=e.activeStatus)}setIcon(e){return this.icon=e instanceof Array?e:[e,e],this}setTitle(e){return this.title=e,this}active(){$(`${this.props.id}-icon`).image=$image(this.icon[1]),$(`${this.props.id}-icon`).tintColor=$color("systemLink"),$(`${this.props.id}-title`).textColor=$color("systemLink"),this.activeStatus=!0}inactive(){$(`${this.props.id}-icon`).image=$image(this.icon[0]),$(`${this.props.id}-icon`).tintColor=$color("lightGray"),$(`${this.props.id}-title`).textColor=$color("lightGray"),this.activeStatus=!1}getView(){return this.views=[{type:"image",props:{id:`${this.props.id}-icon`,image:$image(this.activeStatus?this.icon[1]:this.icon[0]),bgcolor:$color("clear"),tintColor:$color(this.activeStatus?"systemLink":"lightGray")},layout:(e,t)=>{e.centerX.equalTo(t.super);const i=$7dfcabb1e936a92c$var$TabBarController.tabBarHeight/2;e.size.equalTo(i),e.top.inset(($7dfcabb1e936a92c$var$TabBarController.tabBarHeight-i-13)/2)}},{type:"label",props:{id:`${this.props.id}-title`,text:this.title,font:$font(10),textColor:$color(this.activeStatus?"systemLink":"lightGray")},layout:(e,t)=>{e.centerX.equalTo(t.prev),e.top.equalTo(t.prev.bottom).offset(3)}}],this}}class $7dfcabb1e936a92c$var$TabBarHeaderView extends $7dfcabb1e936a92c$require$View{height=60;getView(){return this.type="view",this.setProp("bgcolor",this.props.bgcolor??$7dfcabb1e936a92c$require$UIKit.primaryViewBackgroundColor),this.layout=(e,t)=>{e.left.right.bottom.equalTo(t.super),e.top.equalTo(t.super.safeAreaBottom).offset(-this.height-$7dfcabb1e936a92c$var$TabBarController.tabBarHeight)},this.views=[$7dfcabb1e936a92c$require$View.create({props:this.props,views:this.views,layout:(e,t)=>{e.left.right.top.equalTo(t.super),e.height.equalTo(this.height)}})],this}}class $7dfcabb1e936a92c$var$TabBarController extends $7dfcabb1e936a92c$require$Controller{static tabBarHeight=50;#L={};#R={};#D;#F;#z=$text.uuid;#P=$text.uuid;bottomSafeAreaInsets=$app.isDebugging?0:$7dfcabb1e936a92c$require$UIKit.bottomSafeAreaInsets;get selected(){return this.#F}set selected(e){this.switchPageTo(e)}get contentOffset(){return $7dfcabb1e936a92c$var$TabBarController.tabBarHeight+(this.#D?.height??0)}setPages(e={}){return Object.keys(e).forEach((t=>this.setPage(t,e[t]))),this}setPage(e,t){return void 0===this.#F&&(this.#F=e),this.#L[e]=t instanceof $7dfcabb1e936a92c$require$PageView?t:$7dfcabb1e936a92c$require$PageView.create(t),this.#F!==e&&(this.#L[e].activeStatus=!1),this}switchPageTo(e){if(this.#L[e]){if(this.#F===e)return;$ui.animate({duration:.4,animation:()=>{this.#R[e].active()}}),this.#R[this.#F].inactive(),this.#L[this.#F].hide(),this.#L[e].show(),this.callEvent("onChange",this.#F,e),this.#F=e,this.initBackground()}}hideBackground(e=!0){$(this.#P).hidden=!0,$ui.animate({duration:e?.2:1e-4,animation:()=>{$(this.#z).alpha=0}})}showBackground(e=!0){$(this.#P).hidden=!1,$ui.animate({duration:e?.2:1e-4,animation:()=>{$(this.#z).alpha=1}})}initBackground(){const e=this.#L[this.selected];e.scrollable&&$delay(0,(()=>{const t=$(e.id).get(e.scrollableView.id),i=t.contentOffset.y;t.contentSize.height+this.bottomSafeAreaInsets-t.frame.height-i<=0?this.hideBackground(!1):this.showBackground(!1)}))}setCells(e={}){return Object.keys(e).forEach((t=>this.setCell(t,e[t]))),this}setCell(e,t){return void 0===this.#F&&(this.#F=e),t instanceof $7dfcabb1e936a92c$var$TabBarCellView||(t=new $7dfcabb1e936a92c$var$TabBarCellView({props:{info:{key:e}},icon:t.icon,title:t.title,activeStatus:this.#F===e})),this.#R[e]=t,this}setHeader(e){return this.#D=e,this}#M(){const e=[];return Object.values(this.#R).forEach((t=>{t.setEvent("tapped",(e=>{const t=e.info.key;this.switchPageTo(t)})),e.push(t.getView())})),e}#H(){return Object.values(this.#L).map((e=>{if(e.scrollable){const t=e.scrollableView;if(t.props.indicatorInsets){const e=t.props.indicatorInsets;t.props.indicatorInsets=$insets(e.top,e.left,e.bottom+this.contentOffset,e.right)}else t.props.indicatorInsets=$insets(0,0,this.contentOffset,0);t.props.footer=Object.assign({props:{}},t.props.footer??{}),t.props.footer.props.height?t.props.footer.props.height+=this.contentOffset:t.props.footer.props.height=this.contentOffset,"function"==typeof t.assignEvent&&t.assignEvent("didScroll",(e=>{const t=e.contentOffset.y;e.contentSize.height+this.bottomSafeAreaInsets-e.frame.height-t<=1?this.hideBackground():this.showBackground()}))}return e.definition}))}generateView(){const e={type:"view",layout:(e,t)=>{e.centerX.equalTo(t.super),e.width.equalTo(t.super),e.top.equalTo(t.super.safeAreaBottom).offset(-$7dfcabb1e936a92c$var$TabBarController.tabBarHeight),e.bottom.equalTo(t.super)},views:[$7dfcabb1e936a92c$require$UIKit.blurBox({id:this.#z}),{type:"stack",layout:$layout.fillSafeArea,props:{axis:$stackViewAxis.horizontal,distribution:$stackViewDistribution.fillEqually,spacing:0,stack:{views:this.#M()}}},$7dfcabb1e936a92c$require$UIKit.separatorLine({id:this.#P},$7dfcabb1e936a92c$require$UIKit.align.top)],events:{ready:()=>this.initBackground()}};return $7dfcabb1e936a92c$require$View.createFromViews(this.#H().concat(this.#D?.definition??[],e))}}$7dfcabb1e936a92c$exports={TabBarCellView:$7dfcabb1e936a92c$var$TabBarCellView,TabBarHeaderView:$7dfcabb1e936a92c$var$TabBarHeaderView,TabBarController:$7dfcabb1e936a92c$var$TabBarController};var $bb0fea222fc5aea5$require$TabBarCellView=$7dfcabb1e936a92c$exports.TabBarCellView,$bb0fea222fc5aea5$require$TabBarHeaderView=$7dfcabb1e936a92c$exports.TabBarHeaderView,$bb0fea222fc5aea5$require$TabBarController=$7dfcabb1e936a92c$exports.TabBarController,$3839e9f9bae78bdd$exports={};class $3839e9f9bae78bdd$var$Tasks{#j={};addTask(e,t=0){const i=$text.uuid;return this.#j[i]=$delay(t,(async()=>{await e(),delete this.#j[i]})),i}cancelTask(e){this.#j[e].cancel()}clearTasks(){Object.values(this.#j).forEach((e=>e.cancel()))}}$3839e9f9bae78bdd$exports={Tasks:$3839e9f9bae78bdd$var$Tasks};var $bb0fea222fc5aea5$require$Tasks=$3839e9f9bae78bdd$exports.Tasks,$895b2d75ea56b5f0$exports={},$45Ip7=parcelRequire("45Ip7"),$895b2d75ea56b5f0$require$UIKit=$45Ip7.UIKit;class $895b2d75ea56b5f0$var$Toast{static type={info:void 0,success:"checkmark",warning:"exclamationmark.triangle",error:"xmark.circle"};static edges=40;static iconSize=100;static labelTopMargin=10;width=Math.min(.6*$895b2d75ea56b5f0$require$UIKit.windowSize.width,260);labelWidth=this.width-2*$895b2d75ea56b5f0$var$Toast.edges;id=$text.uuid;#U="";type=$895b2d75ea56b5f0$var$Toast.type.info;labelLines=2;font=$font("default",26);constructor(e,t=$895b2d75ea56b5f0$var$Toast.type.info,i=2,a=$font("default",26)){this.type=t,this.message=e,this.labelLines=i,this.font=a}get message(){return this.#U}set message(e){this.#U=e,this.fontHeight=$895b2d75ea56b5f0$require$UIKit.getContentSize(this.font,this.message,this.labelWidth,this.labelLines).height,this.height=(this.hasIcon?$895b2d75ea56b5f0$var$Toast.labelTopMargin+$895b2d75ea56b5f0$var$Toast.iconSize:0)+this.fontHeight+2*$895b2d75ea56b5f0$var$Toast.edges}get hasIcon(){return void 0!==this.type}get blurBox(){const e=$895b2d75ea56b5f0$require$UIKit.blurBox({id:this.id,cornerRadius:15,alpha:0},[{type:"image",props:{symbol:this.type,hidden:!this.hasIcon,tintColor:$color("lightGray")},layout:(e,t)=>{e.top.inset($895b2d75ea56b5f0$var$Toast.edges),e.size.equalTo($895b2d75ea56b5f0$var$Toast.iconSize),e.centerX.equalTo(t.super)}},{type:"label",props:{font:this.font,text:this.message,align:$align.center,lines:this.labelLines,color:$color("lightGray")},layout:(e,t)=>{e.bottom.equalTo(t.supper).offset(-$895b2d75ea56b5f0$var$Toast.edges),e.width.equalTo(this.labelWidth),e.height.equalTo(this.fontHeight),e.centerX.equalTo(t.super)}}]);return e.events={tapped:()=>{this.remove()}},e}show(){$ui.controller.view.insertAtIndex($ui.create(this.blurBox),0);const e=$(this.id);e.layout(((e,t)=>{e.center.equalTo(t.super),e.size.equalTo($size(this.width,this.height))})),e.moveToFront(),$ui.animate({duration:.2,animation:()=>{e.alpha=1}})}remove(){const e=$(this.id);e&&$ui.animate({duration:.2,animation:()=>{e.alpha=0},completion:()=>{e.remove()}})}static toast({message:e,type:t=$895b2d75ea56b5f0$var$Toast.type.info,displayTime:i=2,labelLines:a=2,font:r=$font("default",26)}){const s=new $895b2d75ea56b5f0$var$Toast(e,t,a,r);s.show(),$delay(i,(()=>{s.remove()}))}static info(e,t={}){$895b2d75ea56b5f0$var$Toast.toast(Object.assign({message:e,type:$895b2d75ea56b5f0$var$Toast.type.info},t))}static success(e,t={}){$895b2d75ea56b5f0$var$Toast.toast(Object.assign({message:e,type:$895b2d75ea56b5f0$var$Toast.type.success},t))}static warning(e,t={}){$895b2d75ea56b5f0$var$Toast.toast(Object.assign({message:e,type:$895b2d75ea56b5f0$var$Toast.type.warning},t))}static error(e,t={}){$895b2d75ea56b5f0$var$Toast.toast(Object.assign({message:e,type:$895b2d75ea56b5f0$var$Toast.type.error},t))}}$895b2d75ea56b5f0$exports={Toast:$895b2d75ea56b5f0$var$Toast};var $bb0fea222fc5aea5$require$Toast=$895b2d75ea56b5f0$exports.Toast,$45Ip7=parcelRequire("45Ip7"),$bb0fea222fc5aea5$require$UIKit=$45Ip7.UIKit,$86d2ffde19fb8791$exports={};class $86d2ffde19fb8791$var$UILoading{#K;text="";interval;fullScreen=!1;#_=()=>{};constructor(){this.#K=$text.uuid}updateText(e){$(this.#K).text=e}setLoop(e){if("function"!=typeof e)throw"loop must be a function";this.#_=e}done(){clearInterval(this.interval)}load(){$ui.render({props:{navBarHidden:this.fullScreen},views:[{type:"spinner",props:{loading:!0},layout:(e,t)=>{e.centerY.equalTo(t.super).offset(-15),e.width.equalTo(t.super)}},{type:"label",props:{id:this.#K,align:$align.center,text:""},layout:(e,t)=>{e.top.equalTo(t.prev.bottom).offset(10),e.left.right.equalTo(t.super)}}],layout:$layout.fill,events:{appeared:()=>{this.interval=setInterval((()=>{this.#_()}),100)}}})}}$86d2ffde19fb8791$exports={UILoading:$86d2ffde19fb8791$var$UILoading};var $bb0fea222fc5aea5$require$UILoading=$86d2ffde19fb8791$exports.UILoading,$6Xrbz=parcelRequire("6Xrbz"),$bb0fea222fc5aea5$require$ValidationError=$6Xrbz.ValidationError,$liCrE=parcelRequire("liCrE"),$bb0fea222fc5aea5$require$View=$liCrE.View,$bb0fea222fc5aea5$require$PageView=$liCrE.PageView,$gMc1q=parcelRequire("gMc1q"),$bb0fea222fc5aea5$require$ViewController=$gMc1q.ViewController,$12xzj=parcelRequire("12xzj"),$bb0fea222fc5aea5$require$NavigationView=$12xzj.NavigationView,$dcStC=parcelRequire("dcStC"),$bb0fea222fc5aea5$require$NavigationBar=$dcStC.NavigationBar,$bb0fea222fc5aea5$require$NavigationBarController=$dcStC.NavigationBarController,$gAYmG=parcelRequire("gAYmG"),$bb0fea222fc5aea5$require$NavigationBarItems=$gAYmG.NavigationBarItems,$bb0fea222fc5aea5$require$BarButtonItem=$gAYmG.BarButtonItem,$ee5e1f8d12d987dc$exports={},$fYz8N=parcelRequire("fYz8N"),$ee5e1f8d12d987dc$require$Controller=$fYz8N.Controller,$gAYmG=parcelRequire("gAYmG"),$ee5e1f8d12d987dc$require$BarTitleView=$gAYmG.BarTitleView;class $ee5e1f8d12d987dc$var$SearchBar extends $ee5e1f8d12d987dc$require$BarTitleView{height=35;topOffset=15;bottomOffset=10;kbType=$kbType.search;placeholder=$l10n("SEARCH");inputEvents={};keyboardView;accessoryView;constructor(e){super(e),this.setController(new $ee5e1f8d12d987dc$var$SearchBarController),this.controller.setSearchBar(this)}setEvent(e,t){return this.inputEvents[e]=t,this}setPlaceholder(e){return this.placeholder=e,this}setKbType(e){return this.kbType=e,this}setKeyboardView(e){return this.keyboardView=e,this}setAccessoryView(e){return this.accessoryView=e,this}getView(){return this.props={id:this.id,smoothCorners:!0,cornerRadius:6,bgcolor:$color("#EEF1F1","#212121")},this.views=[{type:"input",props:{id:this.id+"-input",type:this.kbType,bgcolor:$color("clear"),placeholder:this.placeholder,keyboardView:this.keyboardView,accessoryView:this.accessoryView},layout:$layout.fill,events:Object.assign({changed:e=>this.controller.callEvent("onChange",e.text),returned:e=>this.controller.callEvent("onReturn",e.text)},this.inputEvents)}],this.layout=(e,t)=>{e.height.equalTo(this.height),e.top.equalTo(t.super.safeArea).offset(this.topOffset),e.left.equalTo(t.super.safeArea).offset(15),e.right.equalTo(t.super.safeArea).offset(-15)},this}}class $ee5e1f8d12d987dc$var$SearchBarController extends $ee5e1f8d12d987dc$require$Controller{setSearchBar(e){return this.searchBar=e,this}updateSelector(){this.selector={inputBox:$(this.searchBar.id),input:$(this.searchBar.id+"-input")}}hide(){this.updateSelector(),this.selector.inputBox.updateLayout((e=>{e.height.equalTo(0)}))}show(){this.updateSelector(),this.selector.inputBox.updateLayout((e=>{e.height.equalTo(this.searchBar.height)}))}didScroll(e){this.updateSelector();let t=this.searchBar.height-e;if(t=t>0?t>this.searchBar.height?this.searchBar.height:t:0,this.selector.inputBox.updateLayout((e=>{e.height.equalTo(t)})),e>0){const t=(this.searchBar.height/2-5-e)/10;this.selector.input.alpha=t}else this.selector.input.alpha=1}didEndDragging(e,t,i){this.updateSelector(),e>=0&&e<=this.searchBar.height&&i($point(0,e>=this.searchBar.height/2?this.searchBar.height:0))}}$ee5e1f8d12d987dc$exports={SearchBar:$ee5e1f8d12d987dc$var$SearchBar,SearchBarController:$ee5e1f8d12d987dc$var$SearchBarController};var $bb0fea222fc5aea5$require$SearchBar=$ee5e1f8d12d987dc$exports.SearchBar,$bb0fea222fc5aea5$require$SearchBarController=$ee5e1f8d12d987dc$exports.SearchBarController;module.exports={VERSION:$bb0fea222fc5aea5$require$VERSION,Controller:$bb0fea222fc5aea5$require$Controller,FileManager:$bb0fea222fc5aea5$require$FileManager,FileStorageParameterError:$bb0fea222fc5aea5$require$FileStorageParameterError,FileStorageFileNotFoundError:$bb0fea222fc5aea5$require$FileStorageFileNotFoundError,FileStorage:$bb0fea222fc5aea5$require$FileStorage,FixedFooterView:$bb0fea222fc5aea5$require$FixedFooterView,Kernel:$bb0fea222fc5aea5$require$Kernel,Matrix:$bb0fea222fc5aea5$require$Matrix,Request:$bb0fea222fc5aea5$require$Request,Setting:$bb0fea222fc5aea5$require$Setting,Sheet:$bb0fea222fc5aea5$require$Sheet,TabBarCellView:$bb0fea222fc5aea5$require$TabBarCellView,TabBarHeaderView:$bb0fea222fc5aea5$require$TabBarHeaderView,TabBarController:$bb0fea222fc5aea5$require$TabBarController,Tasks:$bb0fea222fc5aea5$require$Tasks,Toast:$bb0fea222fc5aea5$require$Toast,UIKit:$bb0fea222fc5aea5$require$UIKit,UILoading:$bb0fea222fc5aea5$require$UILoading,ValidationError:$bb0fea222fc5aea5$require$ValidationError,View:$bb0fea222fc5aea5$require$View,PageView:$bb0fea222fc5aea5$require$PageView,ViewController:$bb0fea222fc5aea5$require$ViewController,NavigationView:$bb0fea222fc5aea5$require$NavigationView,NavigationBar:$bb0fea222fc5aea5$require$NavigationBar,NavigationBarController:$bb0fea222fc5aea5$require$NavigationBarController,NavigationBarItems:$bb0fea222fc5aea5$require$NavigationBarItems,BarButtonItem:$bb0fea222fc5aea5$require$BarButtonItem,SearchBar:$bb0fea222fc5aea5$require$SearchBar,SearchBarController:$bb0fea222fc5aea5$require$SearchBarController}; \ No newline at end of file +var $parcel$global="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},$parcel$modules={},$parcel$inits={},parcelRequire=$parcel$global.parcelRequire94c2;null==parcelRequire&&(parcelRequire=function(e){if(e in $parcel$modules)return $parcel$modules[e].exports;if(e in $parcel$inits){var t=$parcel$inits[e];delete $parcel$inits[e];var i={id:e,exports:{}};return $parcel$modules[e]=i,t.call(i.exports,i,i.exports),i.exports}var a=new Error("Cannot find module '"+e+"'");throw a.code="MODULE_NOT_FOUND",a},parcelRequire.register=function(e,t){$parcel$inits[e]=t},$parcel$global.parcelRequire94c2=parcelRequire),parcelRequire.register("45Ip7",(function(e,t){class i{static#e=$objc("UIApplication").$sharedApplication();static#t=$objc("UINotificationFeedbackGenerator").$new();static feedbackSuccess(){i.#t.$notificationOccurred(0)}static feedbackError(){i.#t.$notificationOccurred(2)}static align={left:0,right:1,top:2,bottom:3};static textColor=$color("primaryText");static linkColor=$color("systemLink");static primaryViewBackgroundColor=$color("primarySurface");static scrollViewBackgroundColor=$color("insetGroupedBackground");static scrollViewList=["list","matrix"];static isLargeScreen=$device.isIpad||$device.isIpadPro;static get windowSize(){return $objc("UIWindow").$keyWindow().jsValue().size}static NavigationBarNormalHeight=$objc("UINavigationController").invoke("alloc.init").$navigationBar().jsValue().frame.height;static NavigationBarLargeTitleHeight=$objc("UITabBarController").invoke("alloc.init").$tabBar().jsValue().frame.height+i.NavigationBarNormalHeight;static get isSplitScreenMode(){return i.isLargeScreen&&$device.info.screen.width!==i.windowSize.width}static get topSafeAreaInsets(){return i.#e?.$keyWindow()?.$safeAreaInsets()?.top??0}static get bottomSafeAreaInsets(){return i.#e?.$keyWindow()?.$safeAreaInsets()?.bottom??0}static get statusBarOrientation(){return i.#e.$statusBarOrientation()}static get consoleBarHeight(){if($app.isDebugging){let e=i.#e.$statusBarFrame().height+26;return $device.isIphoneX&&(e+=30),e}return 0}static get isHorizontal(){return 3===i.statusBarOrientation||4===i.statusBarOrientation}static loading(){const e=$ui.create(i.blurBox({cornerRadius:15},[{type:"spinner",props:{loading:!0,style:0},layout:(e,t)=>{e.size.equalTo(t.prev),e.center.equalTo(t.super)}}]));return{start:()=>{$ui.controller.view.insertAtIndex(e,0),e.layout(((e,t)=>{e.center.equalTo(t.super);const a=Math.min(.6*Math.min(i.windowSize.width,i.windowSize.height),260);e.size.equalTo($size(a,a))})),e.moveToFront()},end:()=>{e.remove()}}}static defaultBackgroundColor(e){return i.scrollViewList.indexOf(e)>-1?i.scrollViewBackgroundColor:i.primaryViewBackgroundColor}static separatorLine(e={},t=i.align.bottom){return{type:"canvas",props:e,layout:(e,a)=>{void 0===a.prev?e.top.equalTo(a.super):t===i.align.bottom?e.top.equalTo(a.prev.bottom):e.top.equalTo(a.prev.top),e.height.equalTo(1/$device.info.screen.scale),e.left.right.inset(0)},events:{draw:(t,i)=>{i.strokeColor=e.bgcolor??$color("separatorColor"),i.setLineWidth(1),i.moveToPoint(0,0),i.addLineToPoint(t.frame.width,0),i.strokePath()}}}}static blurBox(e={},t=[],i=$layout.fill){return{type:"blur",props:Object.assign({style:$blurStyle.thinMaterial},e),views:t,layout:i}}static getContentSize(e,t="A",a=i.windowSize.width,r){const s={text:t,width:a,font:e};return void 0!==r&&(s.lineSpacing=r),$text.sizeThatFits(s)}static push({views:e,statusBarStyle:t=0,title:i="",navButtons:a=[{title:""}],bgcolor:r=e[0]?.props?.bgcolor??"primarySurface",disappeared:s}={}){$ui.push({props:{statusBarStyle:t,navButtons:a,title:i,bgcolor:"string"==typeof r?$color(r):r},events:{disappeared:()=>{void 0!==s&&s()}},views:[{type:"view",views:e,layout:(e,t)=>{e.top.equalTo(t.super.safeArea),e.bottom.equalTo(t.super),e.left.right.equalTo(t.super.safeArea)}}]})}}e.exports={UIKit:i}})),parcelRequire.register("7D8Kb",(function(module,exports){var $fYz8N=parcelRequire("fYz8N"),$58e2f5443faff7c0$require$Controller=$fYz8N.Controller,$8aDdQ=parcelRequire("8aDdQ"),$58e2f5443faff7c0$require$FileStorageFileNotFoundError=$8aDdQ.FileStorageFileNotFoundError,$58e2f5443faff7c0$require$FileStorage=$8aDdQ.FileStorage,$cgaQ6=parcelRequire("cgaQ6"),$58e2f5443faff7c0$require$Kernel=$cgaQ6.Kernel,$45Ip7=parcelRequire("45Ip7"),$58e2f5443faff7c0$require$UIKit=$45Ip7.UIKit,$aXWmO=parcelRequire("aXWmO"),$58e2f5443faff7c0$require$Sheet=$aXWmO.Sheet,$12xzj=parcelRequire("12xzj"),$58e2f5443faff7c0$require$NavigationView=$12xzj.NavigationView,$dcStC=parcelRequire("dcStC"),$58e2f5443faff7c0$require$NavigationBar=$dcStC.NavigationBar,$gMc1q=parcelRequire("gMc1q"),$58e2f5443faff7c0$require$ViewController=$gMc1q.ViewController;class SettingLoadConfigError extends Error{constructor(){super("Call loadConfig() first."),this.name="SettingLoadConfigError"}}class SettingReadonlyError extends Error{constructor(){super("Attempted to assign to readonly property."),this.name="SettingReadonlyError"}}class Setting extends $58e2f5443faff7c0$require$Controller{name;setting={};userData;fileStorage;imagePath;viewController=new $58e2f5443faff7c0$require$ViewController;method={readme:()=>{const e=(()=>{const e=$device.info?.language?.startsWith("zh")?"README_CN.md":"README.md";try{return __README__[e]??__README__["README.md"]}catch{return $file.read(e)?.string??$file.read("README.md")?.string}})();(new $58e2f5443faff7c0$require$Sheet).setView({type:"markdown",props:{content:e},layout:(e,t)=>{e.size.equalTo(t.super)}}).init().present()}};rowHeight=50;edgeOffset=10;iconSize=30;#i={};#a=!1;#r=!1;#s;constructor(e={}){super(),"function"==typeof e.set&&"function"==typeof e.get?(this.set=e.set,this.get=e.get,this.userData=e.userData):(this.fileStorage=e.fileStorage??new $58e2f5443faff7c0$require$FileStorage,this.dataFile=e.dataFile??"setting.json"),e.structure?this.setStructure(e.structure):this.setStructurePath(e.structurePath??"setting.json"),this.isUseJsboxNav=e.isUseJsboxNav??!1,this.imagePath=(e.name??"default")+".image/",this.setName(e.name??$text.uuid),this.loadL10n()}useJsboxNav(){return this.isUseJsboxNav=!0,this}#o(){if(!this.#r)throw new SettingLoadConfigError}loadConfig(){const e=["script","info"],t=this.userData??this.fileStorage.readAsJSON(this.dataFile,{});return this.setting=function i(a){const r={};for(let s of a)for(let a of s.items)if("child"===a.type){const e=i(a.children);Object.assign(r,e)}else-1===e.indexOf(a.type)?r[a.key]=a.key in t?t[a.key]:a.value:r[a.key]=a.value;return r}(this.structure),this.#r=!0,this}hasSectionTitle(e){return this.#o(),!!e[0]?.title}loadL10n(){$58e2f5443faff7c0$require$Kernel.l10n("zh-Hans",{OK:"好",DONE:"完成",CANCEL:"取消",CLEAR:"清除",BACK:"返回",ERROR:"发生错误",SUCCESS:"成功",LOADING:"加载中",INVALID_VALUE:"非法参数",CONFIRM_CHANGES:"数据已变化,确认修改?",SETTING:"设置",GENERAL:"一般",ADVANCED:"高级",TIPS:"小贴士",COLOR:"颜色",COPY:"复制",COPIED:"复制成功",JSBOX_ICON:"JSBox 内置图标",SF_SYMBOLS:"SF Symbols",IMAGE_BASE64:"图片 / base64",PREVIEW:"预览",SELECT_IMAGE:"选择图片",CLEAR_IMAGE:"清除图片",NO_IMAGE:"无图片",ABOUT:"关于",VERSION:"Version",AUTHOR:"作者",AT_BOTTOM:"已经到底啦~"},!1),$58e2f5443faff7c0$require$Kernel.l10n("en",{OK:"OK",DONE:"Done",CANCEL:"Cancel",CLEAR:"Clear",BACK:"Back",ERROR:"Error",SUCCESS:"Success",LOADING:"Loading",INVALID_VALUE:"Invalid value",CONFIRM_CHANGES:"The data has changed, confirm the modification?",SETTING:"Setting",GENERAL:"General",ADVANCED:"Advanced",TIPS:"Tips",COLOR:"Color",COPY:"Copy",COPIED:"Copide",JSBOX_ICON:"JSBox in app icon",SF_SYMBOLS:"SF Symbols",IMAGE_BASE64:"Image / base64",PREVIEW:"Preview",SELECT_IMAGE:"Select Image",CLEAR_IMAGE:"Clear Image",NO_IMAGE:"No Image",ABOUT:"About",VERSION:"Version",AUTHOR:"Author",AT_BOTTOM:"It's the end~"},!1)}setUserData(e){this.userData=e}setStructure(e){return this.structure=e,this}setStructurePath(e){return this.structure||this.setStructure($58e2f5443faff7c0$require$FileStorage.readFromRootAsJSON(e)),this}setName(e){return this.name=e,this}setFooter(e){return this.#s=e,this}set footer(e){this.#s=e}get footer(){if(void 0===this.#s){let e=$58e2f5443faff7c0$require$FileStorage.readFromRootAsJSON("config.json",{}).info??{};if(!e.version||!e.author)try{e=__INFO__}catch{}this.#s={},e.version&&e.author&&(this.#s={type:"view",props:{height:70},views:[{type:"label",props:{font:$font(14),text:`${$l10n("VERSION")} ${e.version} ♥ ${e.author}`,textColor:$color({light:"#C0C0C0",dark:"#545454"}),align:$align.center},layout:e=>{e.left.right.inset(0),e.top.inset(10)}}]})}return this.#s}setReadonly(){return this.#a=!0,this}set(e,t){if(this.#a)throw new SettingReadonlyError;return this.#o(),this.setting[e]=t,this.fileStorage.write(this.dataFile,$data({string:JSON.stringify(this.setting)})),this.callEvent("onSet",e,t),!0}get(e,t=null){return this.#o(),Object.prototype.hasOwnProperty.call(this.setting,e)?this.setting[e]:t}getColor(e){return"string"==typeof e?$color(e):$rgba(e.red,e.green,e.blue,e.alpha)}getImagePath(e,t=!1){let i=$text.MD5(e)+".jpg";return t&&(i="compress."+i),this.imagePath+i}getImage(e,t=!1){try{return this.fileStorage.readSync(this.getImagePath(e,t)).image}catch(e){if(e instanceof $58e2f5443faff7c0$require$FileStorageFileNotFoundError)return null;throw e}}getId(e){return`setting-${this.name}-${e}`}#n(e){$(e).bgcolor=$color("systemFill")}#l(e,t=.3){0===t?$(e).bgcolor=$color("clear"):$ui.animate({duration:t,animation:()=>{$(e).bgcolor=$color("clear")}})}#h(e,t,i=!1,a=0){if(t=Object.assign(t,{touchesBegan:()=>{this.#n(e),this.#i[e]=$delay(1,(()=>this.#l(e,0)))},touchesMoved:()=>{this.#i[e]?.cancel(),this.#l(e,0)}}),i){const i=t.tapped;t.tapped=()=>{this.#n(e),setTimeout((()=>this.#l(e)),1e3*a),"function"==typeof i&&i()}}return t}createLineLabel(e,t){return t[1]||(t[1]="#00CC00"),"object"!=typeof t[1]&&(t[1]=[t[1],t[1]]),"object"!=typeof t[0]&&(t[0]=[t[0],t[0]]),{type:"view",views:[{type:"view",props:{bgcolor:$color(t[1][0],t[1][1]),cornerRadius:5,smoothCorners:!0},views:[{type:"image",props:{tintColor:$color("white"),image:$image(t[0][0],t[0][1])},layout:(e,t)=>{e.center.equalTo(t.super),e.size.equalTo(20)}}],layout:(e,t)=>{e.centerY.equalTo(t.super),e.size.equalTo(this.iconSize),e.left.inset(this.edgeOffset)}},{type:"label",props:{text:e,lines:1,textColor:this.textColor,align:$align.left},layout:(e,t)=>{e.centerY.equalTo(t.super),e.height.equalTo(t.super),e.left.equalTo(t.prev.right).offset(this.edgeOffset),e.width.greaterThanOrEqualTo(10)}}],layout:(e,t)=>{e.height.centerY.equalTo(t.super),e.left.inset(0)}}}createInfo(e,t,i){const a=Array.isArray(i),r=a?i[0]:i,s=a?i[1]:i;return{type:"view",props:{selectable:!0},views:[this.createLineLabel(t,e),{type:"label",props:{text:r,align:$align.right,textColor:$color("darkGray")},layout:(e,t)=>{e.centerY.equalTo(t.prev),e.right.inset(this.edgeOffset),e.width.equalTo(180)}},{type:"view",events:{tapped:()=>{$ui.alert({title:t,message:s,actions:[{title:$l10n("COPY"),handler:()=>{$clipboard.text=s,$ui.toast($l10n("COPIED"))}},{title:$l10n("OK")}]})}},layout:(e,t)=>{e.right.inset(0),e.size.equalTo(t.super)}}],layout:$layout.fill}}createSwitch(e,t,i){return{type:"view",props:{id:this.getId(e),selectable:!0},views:[this.createLineLabel(i,t),{type:"switch",props:{on:this.get(e),onColor:$color("#00CC00")},events:{changed:t=>{try{this.set(e,t.on)}catch(e){throw t.on=!t.on,e}}},layout:(e,t)=>{e.centerY.equalTo(t.prev),e.right.inset(this.edgeOffset)}}],layout:$layout.fill}}createString(e,t,i){return{type:"view",props:{id:this.getId(e),selectable:!0},views:[this.createLineLabel(i,t),{type:"button",props:{symbol:"square.and.pencil",bgcolor:$color("clear"),tintColor:$color("primaryText")},events:{tapped:t=>{const i=$ui.popover({sourceView:t,sourceRect:t.bounds,directions:$popoverDirection.down,size:$size(320,150),views:[{type:"text",props:{id:`${this.name}-string-${e}`,align:$align.left,text:this.get(e)},layout:e=>{e.left.right.inset(10),e.top.inset(20),e.height.equalTo(90)}},{type:"button",props:{symbol:"checkmark",bgcolor:$color("clear"),titleEdgeInsets:10,contentEdgeInsets:0},layout:e=>{e.right.inset(10),e.bottom.inset(25),e.size.equalTo(30)},events:{tapped:()=>{this.set(e,$(`${this.name}-string-${e}`).text),i.dismiss()}}}]})}},layout:(e,t)=>{e.centerY.equalTo(t.prev),e.right.inset(0),e.size.equalTo(50)}}],layout:$layout.fill}}createStepper(e,t,i,a,r){const s=this.getId(e),o=`${s}-label`;return{type:"view",props:{id:s,selectable:!0},views:[this.createLineLabel(i,t),{type:"label",props:{id:o,text:this.get(e),textColor:this.textColor,align:$align.left},layout:(e,t)=>{e.height.equalTo(t.super),e.right.inset(120)}},{type:"stepper",props:{min:a,max:r,value:this.get(e)},events:{changed:t=>{$(o).text=t.value;try{this.set(e,t.value)}catch(t){throw $(o).text=this.get(e),t}}},layout:(e,t)=>{e.centerY.equalTo(t.prev),e.right.inset(this.edgeOffset)}}],layout:$layout.fill}}createScript(key,icon,title,script){const id=this.getId(key),buttonId=`${id}-button`,start=()=>{$(buttonId).alpha=0,$(`${buttonId}-spinner`).alpha=1,this.#n(id)},cancel=()=>{$(buttonId).alpha=1,$(`${buttonId}-spinner`).alpha=0,this.#l(id)},done=(e=!0,t=$l10n("ERROR"))=>{$(`${buttonId}-spinner`).alpha=0,this.#l(id);const i=$(buttonId);if(!e)return $ui.toast(t),void(i.alpha=1);i.symbol="checkmark",$ui.animate({duration:.6,animation:()=>{i.alpha=1},completion:()=>{setTimeout((()=>{$ui.animate({duration:.4,animation:()=>{i.alpha=0},completion:()=>{i.symbol="chevron.right",$ui.animate({duration:.4,animation:()=>{i.alpha=1},completion:()=>{i.alpha=1}})}})}),600)}})};return{type:"view",props:{id:id},views:[this.createLineLabel(title,icon),{type:"view",views:[{type:"image",props:{id:buttonId,symbol:"chevron.right",tintColor:$color("secondaryText")},layout:(e,t)=>{e.centerY.equalTo(t.super),e.right.inset(0),e.size.equalTo(15)}},{type:"spinner",props:{id:`${buttonId}-spinner`,loading:!0,alpha:0},layout:(e,t)=>{e.size.equalTo(t.prev),e.left.top.equalTo(t.prev)}}],layout:(e,t)=>{e.right.inset(this.edgeOffset),e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],events:this.#h(id,{tapped:()=>{const animate={start:start,cancel:cancel,done:done,touchHighlightStart:()=>this.#n(id),touchHighlightEnd:()=>this.#l(id)};"function"==typeof script?script(animate):script.startsWith("this")?eval(`(()=>{return ${script}(animate)})()`):eval(script)}}),layout:$layout.fill}}createTab(key,icon,title,items,values){"string"==typeof items?items=eval(`(()=>{return ${items}()})()`):"function"==typeof items&&(items=items()),"string"==typeof values?values=eval(`(()=>{return ${values}()})()`):"function"==typeof values&&(values=values());const id=this.getId(key),isCustomizeValues=items?.length>0&&values?.length===items?.length;return{type:"view",props:{id:id,selectable:!0},views:[this.createLineLabel(title,icon),{type:"tab",props:{items:items??[],index:isCustomizeValues?values.indexOf(this.get(key)):this.get(key),dynamicWidth:!0},layout:(e,t)=>{e.right.inset(this.edgeOffset),e.centerY.equalTo(t.prev)},events:{changed:e=>{isCustomizeValues?this.set(key,values[e.index]):this.set(key,e.index)}}}],layout:$layout.fill}}createMenu(key,icon,title,items,values){const id=this.getId(key),labelId=`${id}-label`,getItems=()=>{let res;return res="string"==typeof items?eval(`(()=>{return ${items}()})()`):"function"==typeof items?items():items??[],res},getValues=()=>{let res;return res="string"==typeof values?eval(`(()=>{return ${values}()})()`):"function"==typeof values?values():values,res},tmpItems=getItems(),tmpValues=getValues(),isCustomizeValues=tmpItems?.length>0&&tmpValues?.length===tmpItems?.length;return{type:"view",props:{id:id,selectable:!0},views:[this.createLineLabel(title,icon),{type:"view",views:[{type:"label",props:{text:isCustomizeValues?tmpItems[tmpValues.indexOf(this.get(key))]:tmpItems[this.get(key)],color:$color("secondaryText"),id:labelId},layout:(e,t)=>{e.right.inset(0),e.height.equalTo(t.super)}}],layout:(e,t)=>{e.right.inset(this.edgeOffset),e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],events:{tapped:()=>{const e=getItems(),t=getValues();$ui.menu({items:e,handler:(e,i)=>{isCustomizeValues?this.set(key,t[i]):this.set(key,i),$(labelId).text=$l10n(e)}})}},layout:$layout.fill}}createColor(e,t,i){const a=this.getId(e),r=`${a}-color`;return{type:"view",props:{id:a,selectable:!0},views:[this.createLineLabel(i,t),{type:"view",views:[{type:"view",props:{id:r,bgcolor:this.getColor(this.get(e)),circular:!0,borderWidth:1,borderColor:$color("#e3e3e3")},layout:(e,t)=>{e.centerY.equalTo(t.super),e.right.inset(this.edgeOffset),e.size.equalTo(20)}},{type:"view",events:{tapped:async()=>{const t=await $picker.color({color:this.getColor(this.get(e))});this.set(e,t.components),$(r).bgcolor=$rgba(t.components.red,t.components.green,t.components.blue,t.components.alpha)}},layout:(e,t)=>{e.right.inset(0),e.height.width.equalTo(t.super.height)}}],layout:(e,t)=>{e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],layout:$layout.fill}}createDate(e,t,i,a=2){const r=this.getId(e),s=e=>{let t="";switch("number"==typeof e&&(e=new Date(e)),a){case 0:t=e.toLocaleTimeString();break;case 1:t=e.toLocaleDateString();break;case 2:t=e.toLocaleString()}return t};return{type:"view",props:{id:r,selectable:!0},views:[this.createLineLabel(i,t),{type:"view",views:[{type:"label",props:{id:`${r}-label`,color:$color("secondaryText"),text:this.get(e)?s(this.get(e)):"None"},layout:(e,t)=>{e.right.inset(0),e.height.equalTo(t.super)}}],events:{tapped:async()=>{const t=this.get(e),i=await $picker.date({props:{mode:a,date:t||Date.now()}});this.set(e,i.getTime()),$(`${r}-label`).text=s(i)}},layout:(e,t)=>{e.right.inset(this.edgeOffset),e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],layout:$layout.fill}}createNumber(e,t,i){return this.createInput(e,t,i,!1,$kbType.decimal,(t=>""!==t&&/^[0-9]+.?[0-9]*$/.test(t)?this.set(e,Number(t)):($ui.toast($l10n("INVALID_VALUE")),!1)))}createInput(e,t,i,a=!1,r=$kbType.default,s){void 0===s&&(s=t=>this.set(e,t));const o=this.getId(e),n=o+"-input";return{type:"view",props:{id:o,selectable:!0},views:[this.createLineLabel(i,t),{type:"input",props:{id:n,type:r,align:$align.right,bgcolor:$color("clear"),textColor:$color("secondaryText"),text:this.get(e),font:$font(16),secure:a,accessoryView:$58e2f5443faff7c0$require$UIKit.blurBox({height:44},[$58e2f5443faff7c0$require$UIKit.separatorLine({},$58e2f5443faff7c0$require$UIKit.align.top),{type:"button",props:{title:$l10n("DONE"),bgcolor:$color("clear"),titleColor:$color("primaryText")},layout:(e,t)=>{e.right.inset(this.edgeOffset),e.centerY.equalTo(t.super)},events:{tapped:()=>{$(n).blur()}}},{type:"button",props:{title:$l10n("CANCEL"),bgcolor:$color("clear"),titleColor:$color("primaryText")},layout:(e,t)=>{e.left.inset(this.edgeOffset),e.centerY.equalTo(t.super)},events:{tapped:()=>{const t=$(n),i=this.get(e,"");t.text!==i&&(t.text=i),t.blur()}}}])},layout:(t,i)=>{t.left.equalTo(i.prev.get("label").right).offset(this.edgeOffset),t.right.inset(this.edgeOffset);const a=$58e2f5443faff7c0$require$UIKit.getContentSize($font(16),this.get(e)).width;t.width.greaterThanOrEqualTo(a+30),t.height.equalTo(i.super)},events:{didBeginEditing:e=>{e.secure=!1,$app.autoKeyboardEnabled||($app.autoKeyboardEnabled=!0)},returned:e=>{e.blur()},didEndEditing:async t=>{const i=this.get(e,"");s(t.text)||(t.text=i),a&&(t.secure=a)}}}],layout:$layout.fill}}createIcon(e,t,i,a="#000000"){const r=this.getId(e),s=`${r}-image`;return{type:"view",props:{id:r,selectable:!0},views:[this.createLineLabel(i,t),{type:"view",views:[{type:"image",props:{cornerRadius:8,bgcolor:"string"==typeof a?$color(a):a,smoothCorners:!0},layout:(e,t)=>{e.right.inset(this.edgeOffset),e.centerY.equalTo(t.super),e.size.equalTo($size(30,30))}},{type:"image",props:{id:s,image:$image(this.get(e)),icon:$icon(this.get(e).slice(5,this.get(e).indexOf(".")),$color("#ffffff")),tintColor:$color("#ffffff")},layout:(e,t)=>{e.right.equalTo(t.prev).offset(-5),e.centerY.equalTo(t.super),e.size.equalTo($size(20,20))}}],events:{tapped:()=>{$ui.menu({items:[$l10n("JSBOX_ICON"),$l10n("SF_SYMBOLS"),$l10n("IMAGE_BASE64")],handler:async(t,i)=>{if(0===i){const t=await $ui.selectIcon();this.set(e,t),$(s).icon=$icon(t.slice(5,t.indexOf(".")),$color("#ffffff"))}else 1!==i&&2!==i||$input.text({text:"",placeholder:t,handler:t=>{""!==t?(this.set(e,t),1===i?$(s).symbol=t:$(s).image=$image(t)):$ui.toast($l10n("INVALID_VALUE"))}})}})}},layout:(e,t)=>{e.right.inset(0),e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],layout:$layout.fill}}createPush(key,icon,title,view,tapped){const id=this.getId(key);return{type:"view",layout:$layout.fill,props:{id:id,selectable:!0},views:[this.createLineLabel(title,icon),{type:"image",props:{symbol:"chevron.right",tintColor:$color("secondaryText")},layout:(e,t)=>{e.centerY.equalTo(t.super),e.right.inset(this.edgeOffset),e.size.equalTo(15)}}],events:{tapped:()=>{const push=view=>{if("string"==typeof view&&view.startsWith("this.method")?view=eval(`(()=>{return ${view}()})()`):"function"==typeof view&&(view=view()),this.isUseJsboxNav)$58e2f5443faff7c0$require$UIKit.push({title:title,props:view.props??{},views:[view]});else{const e=new $58e2f5443faff7c0$require$NavigationView;e.setView(view).navigationBarTitle(title),e.navigationBarItems.addPopButton(),e.navigationBar.setLargeTitleDisplayMode($58e2f5443faff7c0$require$NavigationBar.largeTitleDisplayModeNever),this.hasSectionTitle(view)&&e.navigationBar.setContentViewHeightOffset(-10),this.viewController.push(e)}};"function"==typeof tapped?tapped(push):push(view)}}}}createChild(e,t,i,a){return this.createPush(e,t,i,void 0,(e=>{this.events?.onChildPush?this.callEvent("onChildPush",this.getListView(a,{}),i):e(this.getListView(a,{}))}))}createImage(e,t,i){const a=this.getId(e),r=`${a}-image`,s=$image("questionmark.square.dashed");return{type:"view",props:{id:a,selectable:!0},views:[this.createLineLabel(i,t),{type:"view",views:[{type:"image",props:{id:r,image:this.getImage(e,!0)??s},layout:(e,t)=>{e.right.inset(this.edgeOffset),e.centerY.equalTo(t.super),e.size.equalTo($size(30,30))}}],events:{tapped:()=>{this.#n(a),$ui.menu({items:[$l10n("PREVIEW"),$l10n("SELECT_IMAGE"),$l10n("CLEAR_IMAGE")],handler:(t,i)=>{if(0===i){const t=this.getImage(e);t?$quicklook.open({image:t}):$ui.toast($l10n("NO_IMAGE"))}else 1===i?$photo.pick({format:"data"}).then((t=>{if($ui.toast($l10n("LOADING")),!t.status||!t.data)return void("canceled"!==t?.error?.description&&$ui.toast($l10n("ERROR")));const i=$58e2f5443faff7c0$require$Kernel.compressImage(t.data.image);this.fileStorage.write(this.getImagePath(e,!0),i.jpg(.8)),this.fileStorage.write(this.getImagePath(e),t.data),$(r).image=i,$ui.success($l10n("SUCCESS"))})):2===i&&(this.fileStorage.delete(this.getImagePath(e,!0)),this.fileStorage.delete(this.getImagePath(e)),$(r).image=s,$ui.success($l10n("SUCCESS")))},finished:()=>{this.#l(a)}})}},layout:(e,t)=>{e.right.inset(0),e.height.equalTo(this.rowHeight),e.width.equalTo(t.super)}}],layout:$layout.fill}}#c(e){const t=[];for(let i of e){const e=[];for(let t of i.items){const i=this.get(t.key);let a=null;switch(t.icon||(t.icon=["square.grid.2x2.fill","#00CC00"]),"object"==typeof t.items&&(t.items=t.items.map((e=>$l10n(e)))),t.title=$l10n(t.title),t.type){case"switch":a=this.createSwitch(t.key,t.icon,t.title);break;case"stepper":a=this.createStepper(t.key,t.icon,t.title,t.min??1,t.max??12);break;case"string":a=this.createString(t.key,t.icon,t.title);break;case"info":a=this.createInfo(t.icon,t.title,i);break;case"script":a=this.createScript(t.key,t.icon,t.title,i);break;case"tab":a=this.createTab(t.key,t.icon,t.title,t.items,t.values);break;case"menu":a=this.createMenu(t.key,t.icon,t.title,t.items,t.values);break;case"color":a=this.createColor(t.key,t.icon,t.title);break;case"date":a=this.createDate(t.key,t.icon,t.title,t.mode);break;case"number":a=this.createNumber(t.key,t.icon,t.title);break;case"input":a=this.createInput(t.key,t.icon,t.title,t.secure);break;case"icon":a=this.createIcon(t.key,t.icon,t.title,t.bgcolor);break;case"push":a=this.createPush(t.key,t.icon,t.title,t.view);break;case"child":a=this.createChild(t.key,t.icon,t.title,t.children);break;case"image":a=this.createImage(t.key,t.icon,t.title);break;default:continue}e.push(a)}t.push({title:$l10n(i.title??""),rows:e})}return t}getListView(e,t=this.footer){return{type:"list",props:{id:this.name,style:2,separatorInset:$insets(0,this.iconSize+2*this.edgeOffset,0,this.edgeOffset),bgcolor:$58e2f5443faff7c0$require$UIKit.scrollViewBackgroundColor,footer:t,data:this.#c(e??this.structure)},layout:$layout.fill,events:{rowHeight:(e,t)=>(e.object(t)?.props?.info??{}).rowHeight??this.rowHeight}}}getNavigationView(){const e=new $58e2f5443faff7c0$require$NavigationView;return e.setView(this.getListView(this.structure)).navigationBarTitle($l10n("SETTING")),this.hasSectionTitle(this.structure)&&e.navigationBar.setContentViewHeightOffset(-10),e}getPage(){return this.getNavigationView().getPage()}}module.exports={Setting:Setting}})),parcelRequire.register("fYz8N",(function(e,t){e.exports={Controller:class{events={};setEvents(e){return Object.keys(e).forEach((t=>this.setEvent(t,e[t]))),this}setEvent(e,t){return this.events[e]=t,this}callEvent(e,...t){"function"==typeof this.events[e]&&this.events[e](...t)}}}})),parcelRequire.register("8aDdQ",(function(e,t){class i extends Error{constructor(e){super(`Parameter [${e}] is required.`),this.name="FileStorageParameterError"}}class a extends Error{constructor(e){super(`File not found: ${e}`),this.name="FileStorageFileNotFoundError"}}class r{basePath;constructor({basePath:e="storage"}={}){this.basePath=e,this.#u(this.basePath)}#u(e){$file.isDirectory(e)||$file.mkdir(e)}filePath(e="",t=!0){e.startsWith("/")&&(e=e.substring(1));let i="";if(!(e=`${this.basePath}/${e}`).endsWith("/")){const t=e.lastIndexOf("/");e.lastIndexOf(".")>t&&(i=e.substring(t+1),e=e.substring(0,t+1))}return t&&this.#u(e),e+i}exists(e=""){return e=this.filePath(e,!1),!!$file.exists(e)}write(e="",t){return new Promise(((i,a)=>{try{const r=this.writeSync(e,t);r?i(r):a(r)}catch(e){a(e)}}))}writeSync(e="",t){if(!t)throw new i("data");return $file.write({data:t,path:this.filePath(e)})}read(e=""){return new Promise(((t,i)=>{try{const a=this.readSync(e);a?t(a):i()}catch(e){i(e)}}))}readSync(e=""){if(e=this.filePath(e),!$file.exists(e))throw new a(e);return $file.isDirectory(e)?$file.list(e):$file.read(e)}readAsJSON(e="",t=null){try{const t=this.readSync(e)?.string;return JSON.parse(t)}catch(e){return t}}static readFromRoot(e=""){return new Promise(((t,i)=>{try{const a=r.readFromRootSync(e);a?t(a):i()}catch(e){i(e)}}))}static readFromRootSync(e=""){if(!e)throw new i("path");if(!$file.exists(e))throw new a(e);return $file.isDirectory(e)?$file.list(e):$file.read(e)}static readFromRootAsJSON(e="",t=null){try{const t=r.readFromRootSync(e)?.string;return JSON.parse(t)}catch(e){return t}}delete(e=""){return $file.delete(this.filePath(e,!1))}copy(e,t){e=this.filePath(e),t=this.filePath(t),$file.copy({src:e,dst:t})}move(e,t){e=this.filePath(e),t=this.filePath(t),$file.move({src:e,dst:t})}}e.exports={FileStorageParameterError:i,FileStorageFileNotFoundError:a,FileStorage:r}})),parcelRequire.register("cgaQ6",(function(e,t){var i=parcelRequire("czAIJ").VERSION;class a{startTime=Date.now();isUseJsboxNav=!1;title=$addin?.current?.name;constructor(){$app.isDebugging&&this.debug()}static isTaio=$app.info.bundleID.includes("taio");static l10n(e,t,i=!0){if("string"==typeof t){const e={};t.split(";").forEach((t=>{if(""!==(t=t.trim())){const i=t.split("=");e[i[0].trim().slice(1,-1)]=i[1].trim().slice(1,-1)}})),t=e}const a=$app.strings;a[e]=i?Object.assign($app.strings[e],t):Object.assign(t,$app.strings[e]),$app.strings=a}static compressImage(e,t=921600){const i=$imagekit.info(e);if(i.height*i.width>t){const a=t/(i.height*i.width);e=$imagekit.scaleBy(e,a)}return e}static objectEqual(e,t){let i=Object.getOwnPropertyNames(e),r=Object.getOwnPropertyNames(t);if(i.length!==r.length)return!1;for(let r=0;re?i[e]:0,r=isNaN(Number(t))?t.charCodeAt():Number(t),o=a.length>e?a[e]:0,n=isNaN(Number(o))?o.charCodeAt():Number(o);if(rn){s=1;break}}return s}static deleteConfirm(e,t){$ui.alert({title:$l10n("DELETE_CONFIRM_TITLE"),message:e,actions:[{title:$l10n("DELETE"),style:$alertActionType.destructive,handler:()=>{t()}},{title:$l10n("CANCEL")}]})}static bytesToSize(e){if(0===e)return"0 B";const t=Math.floor(Math.log(e)/Math.log(1024));return(e/Math.pow(1024,t)).toPrecision(3)+" "+["B","KB","MB","GB","TB","PB","EB","ZB","YB"][t]}debug(e,t){this.debugMode=!0,$app.idleTimerDisabled=!0,"function"==typeof e&&(this.debugPrint=e),"function"==typeof t&&(this.debugError=t),this.print("You are running EasyJsBox in debug mode.")}print(e){this.debugMode&&("function"==typeof this.debugPrint?this.debugPrint(e):console.log(e))}error(e){this.debugMode&&("function"==typeof this.debugError?this.debugError(e):console.error(e))}useJsboxNav(){return this.isUseJsboxNav=!0,this}setTitle(e){this.isUseJsboxNav&&($ui.title=e),this.title=e}setNavButtons(e){this.navButtons=e}openInJsbox(){$app.openURL(`jsbox://run?name=${this.title}`)}UIRender(e){try{e.props=Object.assign({title:this.title,navBarHidden:!this.isUseJsboxNav,navButtons:this.navButtons??[],statusBarStyle:0},e.props),e.events||(e.events={});const t=e.events.layoutSubviews,{UIKit:i}=parcelRequire("45Ip7");e.events.layoutSubviews=()=>{$app.notify({name:"interfaceOrientationEvent",object:{statusBarOrientation:i.statusBarOrientation,isHorizontal:i.isHorizontal}}),"function"==typeof t&&t()},$ui.render(e)}catch(e){this.print(e)}}async checkUpdate(){const e=await $http.get("https://raw.githubusercontent.com/ipuppet/EasyJsBox/dev/src/version.js");if(e.error)throw e.error;const t=srcRes.data.match(/.*VERSION.?\"([0-9\.]+)\"/)[1];if(this.print(`easy-jsbox latest version: ${t}`),a.versionCompare(t,i)>0){const e=await $http.get("https://raw.githubusercontent.com/ipuppet/EasyJsBox/dev/dist/easy-jsbox.js");if(e.error)throw e.error;return e.data}return!1}}a.l10n("zh-Hans",{DELETE_CONFIRM_TITLE:"删除前确认"},!1),a.l10n("en",{DELETE_CONFIRM_TITLE:"Delete Confirmation"},!1),e.exports={Kernel:a}})),parcelRequire.register("czAIJ",(function(e,t){e.exports={VERSION:"1.4.0"}})),parcelRequire.register("aXWmO",(function(e,t){var i=parcelRequire("6Xrbz").ValidationError,a=parcelRequire("liCrE").View,r=parcelRequire("45Ip7").UIKit,s=parcelRequire("12xzj").NavigationView,o=parcelRequire("dcStC").NavigationBar,n=parcelRequire("gAYmG").BarButtonItem;class l extends Error{constructor(){super("Please call setView(view) first."),this.name="SheetAddNavBarError"}}class h extends i{constructor(e,t){super(e,t),this.name="SheetViewTypeError"}}class c extends a{#p=()=>{};#d=()=>{};style=c.UIModalPresentationStyle.PageSheet;#g=!1;static UIModalPresentationStyle={Automatic:-2,FullScreen:0,PageSheet:1,FormSheet:2,CurrentContext:3,Custom:4,OverFullScreen:5,OverCurrentContext:6,Popover:7,BlurOverFullScreen:8};navigationView;init(){const{width:e,height:t}=$device.info.screen,i=$objc("UIView").invoke("initWithFrame",$rect(0,0,e,t)),a=$objc("UIViewController").invoke("alloc.init"),s=a.$view();return s.$setBackgroundColor(r.primaryViewBackgroundColor),s.$addSubview(i),a.$setModalPresentationStyle(this.style),a.$setModalInPresentation(this.#g),this.#p=()=>{s.jsValue().add(this.navigationView?.getPage().definition??this.view),$ui.vc.ocValue().invoke("presentViewController:animated:completion:",a,!0,void 0)},this.#d=()=>a.invoke("dismissViewControllerAnimated:completion:",!0,void 0),this}preventDismiss(){return this.#g=!0,this}setStyle(e){return this.style=e,this}setView(e={}){if("object"!=typeof e)throw new h("view","object");return this.view=e,this}addNavBar({title:e="",popButton:t={title:$l10n("DONE")},rightButtons:i=[]}={}){if(void 0===this.view)throw new l;this.navigationView=new s;const a=new n;a.setEvents(Object.assign({tapped:()=>{this.dismiss(),"function"==typeof t.tapped&&t.tapped()}},t.events)).setAlign(r.align.left).setSymbol(t.symbol).setTitle(t.title).setColor(t.color).setMenu(t.menu);const h=a.definition.views[0];return h.layout=(e,t)=>{e.left.equalTo(t.super.safeArea).offset(15),e.centerY.equalTo(t.super.safeArea)},this.navigationView.navigationBar.setLargeTitleDisplayMode(o.largeTitleDisplayModeNever).pageSheetMode(),this.navigationView.navigationBarItems.addPopButton("",h).setRightButtons(i),this.navigationView.setView(this.view).navigationBarTitle(e),this.view.props?.bgcolor&&this.navigationView?.getPage().setProp("bgcolor",this.view.props?.bgcolor),this}present(){this.#p()}dismiss(){this.#d()}}e.exports={Sheet:c}})),parcelRequire.register("6Xrbz",(function(e,t){class i extends Error{constructor(e,t){super(`The type of the parameter '${e}' must be '${t}'`),this.name="ValidationError"}}e.exports={ValidationError:i}})),parcelRequire.register("liCrE",(function(e,t){var i=parcelRequire("45Ip7").UIKit;class a{id=$text.uuid;type;props;views;events;layout;#$=void 0;#f=null;constructor({type:e="view",props:t={},views:i=[],events:a={},layout:r=$layout.fill}={}){this.type=e,this.props=t,this.views=i,this.events=a,this.layout=r,this.props.id?this.id=this.props.id:this.props.id=this.id}static create(e){return new this(e)}static createFromViews(e){return new this({views:e})}get scrollableView(){return this.scrollable?this.#f:null}set scrollableView(e){this.#f=e}get scrollable(){if(void 0===this.#$)if(this.#$=!1,i.scrollViewList.indexOf(this.type)>-1)this.scrollableView=this,this.#$=!0;else if(this.views.length>0){const e=t=>{if(!this.#$&&t?.length>0)for(let r=0;r-1)return typeof t[r]!==a&&(t[r]=a.create(t[r])),this.scrollableView=t[r],void(this.#$=!0);e(t[r].views)}};e(this.views)}return this.#$}set scrollable(e){throw new Error("[scrollable] is readonly prop.")}setProps(e){return Object.keys(e).forEach((t=>this.setProp(t,e[t]))),this}setProp(e,t){return"id"===e&&(this.id=t),this.props[e]=t,this}setViews(e){return this.views=e,this.#$=void 0,this}setEvents(e){return Object.keys(e).forEach((t=>this.setEvent(t,e[t]))),this}setEvent(e,t){return this.events[e]=t,this}eventMiddleware(e,t){const i=this.events[e];return this.events[e]=(...e)=>{"function"==typeof i&&t(i,...e)},this}assignEvent(e,t){const i=this.events[e];return this.events[e]=(...e)=>{"function"==typeof i&&i(...e),t(...e)},this}setLayout(e){return this.layout=e,this}getView(){return this}get definition(){return this.getView()}}e.exports={View:a,PageView:class extends a{constructor(e={}){super(e),this.activeStatus=!0}show(){$(this.props.id).hidden=!1,this.activeStatus=!0}hide(){$(this.props.id).hidden=!0,this.activeStatus=!1}setHorizontalSafeArea(e){return this.horizontalSafeArea=e,this}#b(e,t){e.top.bottom.equalTo(t.super),this.horizontalSafeArea?e.left.right.equalTo(t.super.safeArea):e.left.right.equalTo(t.super)}getView(){return this.layout=this.#b,this.props.clipsToBounds=!0,this.props.hidden=!this.activeStatus,super.getView()}}}})),parcelRequire.register("12xzj",(function(e,t){var i=parcelRequire("fYz8N").Controller,a=parcelRequire("liCrE"),r=a.View,s=a.PageView,o=parcelRequire("6Xrbz").ValidationError,n=parcelRequire("cgaQ6").Kernel,l=parcelRequire("45Ip7").UIKit,h=parcelRequire("dcStC"),c=h.NavigationBar,u=h.NavigationBarController,p=parcelRequire("gAYmG").NavigationBarItems;class d extends o{constructor(e,t){super(e,t),this.name="NavigationViewTypeError"}}e.exports={NavigationView:class extends i{page;navigationController=new u;navigationBar=new c;navigationBarItems=new p;constructor(){super(),this.navigationBar.navigationBarItems=this.navigationBarItems,this.navigationController.navigationBar=this.navigationBar}navigationBarTitle(e){return this.navigationBar.setTitle(e),this}setView(e){if("object"!=typeof e)throw new d("view","object");return this.view=r.create(e),this}#v(){if(!(this.view instanceof r))throw new d("view","View");const e=this.view.scrollableView,t=$app.isDebugging||n.isTaio?0:l.topSafeAreaInsets,i=this.navigationBar.largeTitleDisplayMode===c.largeTitleDisplayModeNever?this.navigationBar.navigationBarNormalHeight:this.navigationBar.navigationBarLargeTitleHeight;let a=this.navigationBar.contentViewHeightOffset+i;if(this.navigationBarItems.titleView&&(a+=this.navigationBarItems.titleView.topOffset,a+=this.navigationBarItems.titleView.height,a+=this.navigationBarItems.titleView.bottomOffset),!this.view.scrollable||!1===e.props.associateWithNavigationBar)return void(this.view.layout=(e,i)=>{e.left.right.equalTo(i.super.safeArea),e.bottom.equalTo(i.super);let r=a-this.navigationBar.contentViewHeightOffset;l.isHorizontal&&!l.isLargeScreen||!this.navigationBar.topSafeArea||(r+=t),e.top.equalTo(r)});e.props.stickyHeader&&(a-=i,a+=this.navigationBar.largeTitleFontHeight),e.props.header?e.props.header={type:"view",props:{height:a+(e.props.header?.props?.height??0)},views:[{type:"view",props:{clipsToBounds:!0},views:[e.props.header],layout:(e,t)=>{e.top.equalTo(a),e.bottom.width.equalTo(t.super)}}]}:e.props.header={props:{height:a}},e.props.footer=Object.assign({props:{}},e.props.footer??{}),e.props.footer.props.height=(this.navigationBarItems.fixedFooterView?.height??0)+(e.props.footer.props?.height??0);const s=this.navigationBarItems.isPinTitleView?this.navigationBarItems.titleView.height+this.navigationBarItems.titleView.bottomOffset+this.navigationBar.contentViewHeightOffset:0;if(e.props.indicatorInsets){const t=e.props.indicatorInsets;e.props.indicatorInsets=$insets(t.top+this.navigationBar.navigationBarNormalHeight+s,t.left,t.bottom+(this.navigationBarItems.fixedFooterView?.height??0),t.right)}else e.props.indicatorInsets=$insets(this.navigationBar.navigationBarNormalHeight+s,0,this.navigationBarItems.fixedFooterView?.height??0,0);e.layout=(t,i)=>{e.props.stickyHeader?t.top.equalTo(i.super.safeArea).offset(this.navigationBar.navigationBarNormalHeight):t.top.equalTo(i.super),t.left.right.equalTo(i.super.safeArea),t.bottom.equalTo(i.super)},e.assignEvent("didScroll",(i=>{let a=i.contentOffset.y;l.isHorizontal&&!l.isLargeScreen||!this.navigationBar.topSafeArea||e.props.stickyHeader||(a+=t),this.navigationController.didScroll(a)})).assignEvent("didEndDragging",((i,a)=>{let r=i.contentOffset.y,s=0;l.isHorizontal&&!l.isLargeScreen||!this.navigationBar.topSafeArea||e.props.stickyHeader||(r+=t,s=t),this.navigationController.didEndDragging(r,a,((...e)=>i.scrollToOffset(...e)),s)})).assignEvent("didEndDecelerating",((...t)=>{t[0].tracking||e.events?.didEndDragging(...t)}))}#w(){if(this.navigationBar.prefersLargeTitles){this.#v();let e={};if(this.navigationBarItems.titleView){const t=this.navigationBar.largeTitleDisplayMode===c.largeTitleDisplayModeNever?1:0;e=r.create({views:[this.navigationBar.backgroundColor?{type:"view",props:{alpha:t,bgcolor:this.navigationBar.backgroundColor,id:this.navigationBar.id+"-title-view-background"},layout:$layout.fill}:l.blurBox({alpha:t,id:this.navigationBar.id+"-title-view-background"}),l.separatorLine({id:this.navigationBar.id+"-title-view-underline",alpha:t}),this.navigationBarItems.titleView.definition],layout:(e,t)=>{e.top.equalTo(t.prev.bottom),e.width.equalTo(t.super),e.height.equalTo(this.navigationBarItems.titleView.topOffset+this.navigationBarItems.titleView.height+this.navigationBarItems.titleView.bottomOffset)}})}this.page=s.createFromViews([this.view,this.navigationBar.getLargeTitleView(),e,this.navigationBar.getNavigationBarView(),this.navigationBarItems.fixedFooterView?.definition??{}])}else this.page=s.createFromViews([this.view]);this.view.props?.bgcolor?this.page.setProp("bgcolor",this.view.props.bgcolor):this.page.setProp("bgcolor",l.defaultBackgroundColor(this.view.type))}getPage(){return this.page||this.#w(),this.page}}}})),parcelRequire.register("dcStC",(function(e,t){var i=parcelRequire("liCrE").View,a=parcelRequire("fYz8N").Controller,r=parcelRequire("45Ip7").UIKit;parcelRequire("gAYmG").BarButtonItem;class s extends i{static largeTitleDisplayModeAutomatic=0;static largeTitleDisplayModeAlways=1;static largeTitleDisplayModeNever=2;static pageSheetNavigationBarHeight=56;navigationBarItems;title="";prefersLargeTitles=!0;largeTitleDisplayMode=s.largeTitleDisplayModeAutomatic;largeTitleFontSize=34;largeTitleFontFamily="bold";largeTitleFontHeight=$text.sizeThatFits({text:"A",width:100,font:$font(this.largeTitleFontFamily,this.largeTitleFontSize)}).height;navigationBarTitleFontSize=17;topSafeArea=!0;contentViewHeightOffset=10;navigationBarNormalHeight=r.NavigationBarNormalHeight;navigationBarLargeTitleHeight=r.NavigationBarLargeTitleHeight;pageSheetMode(){return this.navigationBarLargeTitleHeight-=this.navigationBarNormalHeight,this.navigationBarNormalHeight=s.pageSheetNavigationBarHeight,this.navigationBarLargeTitleHeight+=this.navigationBarNormalHeight,this.topSafeArea=!1,this}setTopSafeArea(){return this.topSafeArea=!0,this}removeTopSafeArea(){return this.topSafeArea=!1,this}setLargeTitleDisplayMode(e){return this.largeTitleDisplayMode=e,this}setBackgroundColor(e){return this.backgroundColor=e,this}setTitle(e){return this.title=e,this}setPrefersLargeTitles(e){return this.prefersLargeTitles=e,this}setContentViewHeightOffset(e){return this.contentViewHeightOffset=e,this}getLargeTitleView(){return this.prefersLargeTitles&&this.largeTitleDisplayMode!==s.largeTitleDisplayModeNever?{type:"label",props:{id:this.id+"-large-title",text:this.title,textColor:r.textColor,align:$align.left,font:$font(this.largeTitleFontFamily,this.largeTitleFontSize),line:1},layout:(e,t)=>{e.left.equalTo(t.super.safeArea).offset(15),e.height.equalTo(this.largeTitleFontHeight),e.top.equalTo(t.super.safeAreaTop).offset(this.navigationBarNormalHeight)}}:{props:{id:this.id+"-large-title"},layout:(e,t)=>{e.left.top.right.inset(0),e.bottom.equalTo(t.super.safeAreaTop).offset(this.navigationBarNormalHeight)}}}getNavigationBarView(){const e=(e,t)=>{let i=0;const a=[];return e.forEach((e=>{i+=e.width,a.push(e.definition)})),i+=e[0]?.edges??0,e.length>0?{type:"view",views:a,layout:(e,a)=>{e.top.equalTo(a.super.safeAreaTop),e.bottom.equalTo(a.super.safeAreaTop).offset(this.navigationBarNormalHeight),t===r.align.left?e.left.equalTo(a.super.safeArea):e.right.equalTo(a.super.safeArea),e.width.equalTo(i)}}:{}},t=e(this.navigationBarItems.rightButtons,r.align.right),i=this.navigationBarItems.popButtonView??e(this.navigationBarItems.leftButtons,r.align.left),a=this.prefersLargeTitles,o=!this.prefersLargeTitles||this.largeTitleDisplayMode===s.largeTitleDisplayModeNever;return{type:"view",props:{id:this.id+"-navigation",bgcolor:$color("clear")},layout:(e,t)=>{e.left.top.right.inset(0),e.bottom.equalTo(t.super.safeAreaTop).offset(this.navigationBarNormalHeight)},views:[this.backgroundColor?{type:"view",props:{hidden:a,bgcolor:this.backgroundColor,id:this.id+"-background"},layout:$layout.fill}:r.blurBox({hidden:a,id:this.id+"-background"}),r.separatorLine({id:this.id+"-underline",alpha:a?0:1}),{type:"view",props:{alpha:0,bgcolor:$color("clear"),id:this.id+"-large-title-mask"},events:{ready:e=>{e.bgcolor=$(this.id+"-large-title")?.prev.bgcolor}},layout:$layout.fill},{type:"label",props:{id:this.id+"-small-title",alpha:o?1:0,text:this.title,font:$font(this.largeTitleFontFamily,this.navigationBarTitleFontSize),align:$align.center,bgcolor:$color("clear"),textColor:r.textColor},layout:(e,t)=>{e.left.right.inset(0),e.height.equalTo(20),e.centerY.equalTo(t.super.safeArea)}}].concat(t,i)}}}class o extends a{static largeTitleViewSmallMode=0;static largeTitleViewLargeMode=1;navigationBar;updateSelector(){this.selector={navigation:$(this.navigationBar.id+"-navigation"),largeTitleView:$(this.navigationBar.id+"-large-title"),smallTitleView:$(this.navigationBar.id+"-small-title"),underlineView:this.navigationBar.navigationBarItems.isPinTitleView?$(this.navigationBar.id+"-title-view-underline"):$(this.navigationBar.id+"-underline"),largeTitleMaskView:$(this.navigationBar.id+"-large-title-mask"),backgroundView:$(this.navigationBar.id+"-background"),titleViewBackgroundView:$(this.navigationBar.id+"-title-view-background")}}toNormal(e=!0){this.updateSelector(),this.selector.backgroundView.hidden=!1,$ui.animate({duration:.2,animation:()=>{this.selector.underlineView.alpha=1,this.selector.smallTitleView.alpha=1,this.selector.largeTitleView.alpha=0}}),e&&this.navigationBar.navigationBarItems&&(this.navigationBar.largeTitleDisplayMode=s.largeTitleDisplayModeNever)}toLargeTitle(e=!0){this.updateSelector(),this.selector.backgroundView.hidden=!0,$ui.animate({duration:.2,animation:()=>{this.selector.underlineView.alpha=0,this.selector.smallTitleView.alpha=0,this.selector.largeTitleView.alpha=1}}),e&&this.navigationBar.navigationBarItems&&(this.navigationBar.largeTitleDisplayMode=s.largeTitleDisplayModeAlways)}#m(e){const t=e===o.largeTitleViewSmallMode;this.selector.largeTitleView.alpha=t?0:1,$ui.animate({duration:.2,animation:()=>{this.selector.smallTitleView.alpha=t?1:0}})}#y(e){if(this.selector.largeTitleView.updateLayout(((t,i)=>{this.navigationBar.navigationBarNormalHeight-e>0?t.top.equalTo(i.super.safeAreaTop).offset(this.navigationBar.navigationBarNormalHeight-e):t.top.equalTo(i.super.safeAreaTop).offset(0)})),e>0)e>=this.navigationBar.navigationBarNormalHeight?this.#m(o.largeTitleViewSmallMode):this.#m(o.largeTitleViewLargeMode);else{this.#m(o.largeTitleViewLargeMode);let t=this.navigationBar.largeTitleFontSize-.04*e;t>40&&(t=40),this.selector.largeTitleView.font=$font(this.navigationBar.largeTitleFontFamily,t)}}#T(e){const t=this.navigationBar.largeTitleDisplayMode===s.largeTitleDisplayModeNever?5:this.navigationBar.navigationBarNormalHeight,i=void 0!==this.selector.titleViewBackgroundView;if(e>t){this.selector.backgroundView.hidden=!1;const a=()=>{i&&this.navigationBar.navigationBarItems.isPinTitleView&&(this.selector.titleViewBackgroundView.alpha=1),this.selector.largeTitleMaskView.alpha=0,this.selector.underlineView.alpha=1};(e-t)/3>=1?a():$ui.animate({duration:.2,animation:()=>{a()}})}else this.selector.largeTitleMaskView.alpha=e>0?1:0,this.selector.underlineView.alpha=0,i&&(this.selector.titleViewBackgroundView.alpha=0),this.selector.backgroundView.hidden=!0}didScroll(e){if(!this.navigationBar.prefersLargeTitles)return;const t=this.navigationBar.largeTitleDisplayMode;if(t!==s.largeTitleDisplayModeAlways)if(this.updateSelector(),t===s.largeTitleDisplayModeAutomatic){if(!this.navigationBar.navigationBarItems?.isPinTitleView&&(this.navigationBar.navigationBarItems?.titleView?.controller.didScroll(e),e>0)){(e-=this.navigationBar.navigationBarItems?.titleView?.height??0)<0&&(e=0)}this.#y(e),this.#T(e)}else t===s.largeTitleDisplayModeNever&&this.#T(e)}didEndDragging(e,t,i,a){if(!this.navigationBar.prefersLargeTitles)return;const r=this.navigationBar.largeTitleDisplayMode;if(r!==s.largeTitleDisplayModeAlways&&(this.updateSelector(),r===s.largeTitleDisplayModeAutomatic)){let r=0;this.navigationBar.navigationBarItems?.isPinTitleView||(this.navigationBar.navigationBarItems?.titleView?.controller.didEndDragging(e,t,i,a),r=this.navigationBar.navigationBarItems?.titleView?.height??0,e-=r),e>=0&&e<=this.navigationBar.largeTitleFontHeight&&i($point(0,e>=this.navigationBar.largeTitleFontHeight/2?this.navigationBar.navigationBarNormalHeight+r-a:r-a))}}}e.exports={NavigationBar:s,NavigationBarController:o}})),parcelRequire.register("gAYmG",(function(e,t){var i=parcelRequire("liCrE").View,a=parcelRequire("45Ip7").UIKit;class r extends i{static#q;edges=15;iconSize=$size(23,23);fontSize=16;color=a.textColor;title;symbol;align=a.align.right;get width(){if(this.title){const e=$text.sizeThatFits({text:this.title,width:a.windowSize.width,font:$font(this.fontSize)});return Math.ceil(e.width)+this.edges}return this.iconSize.width+this.edges}static get style(){return void 0===this.#q&&(this.#q=new r),this.#q}setEdges(e){return this.edges=e,this}setFontSize(e){return this.fontSize=e,this}setColor(e=a.textColor){return this.color=e,this}setTitle(e){return this.title=e,this}setSymbol(e){return this.symbol=e,this}setMenu(e){return this.menu=e,this}setAlign(e){return this.align=e,this}setLoading(e){e?($(this.id).hidden=!0,$("spinner-"+this.id).hidden=!1):($(this.id).hidden=!1,$("spinner-"+this.id).hidden=!0)}#B(){const e=$(`icon-button-${this.id}`),t=$(`icon-checkmark-${this.id}`);e.alpha=0,$(this.id).hidden=!1,$("spinner-"+this.id).hidden=!0,$ui.animate({duration:.6,animation:()=>{t.alpha=1},completion:()=>{$delay(.3,(()=>$ui.animate({duration:.6,animation:()=>{t.alpha=0},completion:()=>{$ui.animate({duration:.4,animation:()=>{e.alpha=1},completion:()=>{e.alpha=1}})}})))}})}getView(){const e=this.events.tapped;return this.events.tapped=t=>{e&&e({start:()=>this.setLoading(!0),done:()=>this.#B(),cancel:()=>this.setLoading(!1)},t)},{type:"view",props:{info:{align:this.align}},views:[{type:"button",props:Object.assign({id:this.id,bgcolor:$color("clear"),font:$font(this.fontSize),titleColor:this.color,contentEdgeInsets:$insets(0,0,0,0),titleEdgeInsets:$insets(0,0,0,0),imageEdgeInsets:$insets(0,0,0,0)},this.menu?{menu:this.menu}:{},this.title?{title:this.title}:{},this.props),views:[{type:"image",props:Object.assign({id:`icon-button-${this.id}`,hidden:void 0===this.symbol,tintColor:this.color},void 0===this.symbol?{}:"string"==typeof this.symbol?{symbol:this.symbol}:{data:this.symbol.png}),layout:(e,t)=>{e.center.equalTo(t.super),e.size.equalTo(this.iconSize)}},{type:"image",props:{id:`icon-checkmark-${this.id}`,alpha:0,tintColor:this.color,symbol:"checkmark"},layout:(e,t)=>{e.center.equalTo(t.super),e.size.equalTo(this.iconSize)}}],events:this.events,layout:$layout.fill},{type:"spinner",props:{id:"spinner-"+this.id,loading:!0,hidden:!0},layout:$layout.fill}],layout:(e,t)=>{if(e.size.equalTo($size(this.width,a.NavigationBarNormalHeight)),e.centerY.equalTo(t.super),t.prev&&t.prev?.info?.align===this.align)this.align===a.align.right?e.right.equalTo(t.prev.left):e.left.equalTo(t.prev.right);else{const t=this.edges/2;this.align===a.align.right?e.right.inset(t):e.left.inset(t)}}}}static creat({id:e,symbol:t,title:i,tapped:s,menu:o,events:n,color:l,align:h=a.align.right}={}){const c=new r;return c.setEvents(Object.assign({tapped:s},n)).setAlign(h).setSymbol(t).setTitle(i).setColor(l).setMenu(o),e&&c.setProp("id",e),c}}e.exports={BarTitleView:class extends i{controller={};setController(e){return this.controller=e,this}},BarButtonItem:r,NavigationBarItems:class{rightButtons=[];leftButtons=[];#S={};hasbutton=!1;isPinTitleView=!1;setTitleView(e){return this.titleView=e,this}pinTitleView(){return this.isPinTitleView=!0,this}setFixedFooterView(e){return this.fixedFooterView=e,this}setRightButtons(e){return e.forEach((e=>this.addRightButton(e))),this.hasbutton||(this.hasbutton=!0),this}setLeftButtons(e){return e.forEach((e=>this.addLeftButton(e))),this.hasbutton||(this.hasbutton=!0),this}addRightButton({id:e,symbol:t,title:i,tapped:s,menu:o,events:n,color:l}={}){const h=r.creat({id:e,symbol:t,title:i,tapped:s,menu:o,events:n,color:l,align:a.align.right});return this.rightButtons.push(h),this.#S[e??h.id]=h,this.hasbutton||(this.hasbutton=!0),this}addLeftButton({id:e,symbol:t,title:i,tapped:s,menu:o,events:n,color:l}={}){const h=r.creat({id:e,symbol:t,title:i,tapped:s,menu:o,events:n,color:l,align:a.align.left});return this.leftButtons.push(h),this.#S[e??h.id]=h,this.hasbutton||(this.hasbutton=!0),this}getButton(e){return this.#S[e]}addPopButton(e,t,i){return e||(e=$l10n("BACK")),this.popButtonView=t??{type:"button",props:{bgcolor:$color("clear"),symbol:"chevron.left",tintColor:a.linkColor,title:` ${e}`,titleColor:a.linkColor,font:$font("bold",16)},layout:(e,t)=>{e.left.equalTo(t.super.safeArea).offset(r.style.edges),e.centerY.equalTo(t.super.safeArea)},events:{tapped:()=>{$ui.pop(),"function"==typeof i&&i()}}},this}removePopButton(){return this.popButtonView=void 0,this}}}})),parcelRequire.register("gMc1q",(function(e,t){var i=parcelRequire("fYz8N").Controller;e.exports={ViewController:class extends i{#C=[];#I(e){e.callEvent("onPop"),this.callEvent("onPop",e),this.#C.pop()}push(e){const t=this.#C[this.#C.length-1];e.navigationBarItems.addPopButton(t?.navigationBar.title),this.#C.push(e),$ui.push({props:{statusBarStyle:0,navBarHidden:!0},events:{dealloc:()=>{this.#I(e)}},views:[e.getPage().definition],layout:$layout.fill})}}}})),String.prototype.trim=function(e,t){return e?"l"===t?this.replace(new RegExp("^\\"+e+"+","g"),""):"r"===t?this.replace(new RegExp("\\"+e+"+$","g"),""):this.replace(new RegExp("^\\"+e+"+|\\"+e+"+$","g"),""):this.replace(/^\s+|\s+$/g,"")};var $czAIJ=parcelRequire("czAIJ"),$bb0fea222fc5aea5$require$VERSION=$czAIJ.VERSION,$fYz8N=parcelRequire("fYz8N"),$bb0fea222fc5aea5$require$Controller=$fYz8N.Controller,$272f042430a952c6$exports={},$45Ip7=parcelRequire("45Ip7"),$272f042430a952c6$require$UIKit=$45Ip7.UIKit,$aXWmO=parcelRequire("aXWmO"),$272f042430a952c6$require$Sheet=$aXWmO.Sheet,$cgaQ6=parcelRequire("cgaQ6"),$272f042430a952c6$require$Kernel=$cgaQ6.Kernel,$12xzj=parcelRequire("12xzj"),$272f042430a952c6$require$NavigationView=$12xzj.NavigationView,$dcStC=parcelRequire("dcStC"),$272f042430a952c6$require$NavigationBar=$dcStC.NavigationBar;class $272f042430a952c6$var$FileManager{viewController;constructor(){this.listId="file-manager-list",this.edges=10,this.iconSize=25,this.loadL10n()}loadL10n(){$272f042430a952c6$require$Kernel.l10n("zh-Hans",{FILE_MANAGER_DELETE_CONFIRM_MSG:"确认要删除吗",DELETE:"删除",CANCEL:"取消",CLOSE:"关闭",SHARE:"分享",SAVE:"保存",SAVE_SUCCESS:"保存成功"},!1),$272f042430a952c6$require$Kernel.l10n("en",{FILE_MANAGER_DELETE_CONFIRM_MSG:"Are you sure you want to delete",DELETE:"Delete",CANCEL:"Cancel",CLOSE:"Close",SHARE:"Share",SAVE:"Save",SAVE_SUCCESS:"Save Success"},!1)}setViewController(e){this.viewController=e}get menu(){return{items:[{title:$l10n("SHARE"),symbol:"square.and.arrow.up",handler:async(e,t)=>{const i=e.object(t).info.info;$share.sheet([$file.absolutePath(i.path)])}}]}}delete(e){$file.delete(e.path)}edit(e){const t=$file.read(e.path);if(t.image)$quicklook.open({image:t.image});else{const i=new $272f042430a952c6$require$Sheet,a=$text.uuid;i.setView({type:"code",layout:$layout.fill,props:{id:a,lineNumbers:!0,theme:$device.isDarkMode?"atom-one-dark":"atom-one-light",text:t.string,insets:$insets(15,15,15,15)}}).addNavBar({title:e.file,popButton:{title:$l10n("CLOSE")},rightButtons:[{title:$l10n("SAVE"),tapped:()=>{$file.write({data:$data({string:$(a).text}),path:e.path}),$ui.success($l10n("SAVE_SUCCESS"))}}]}),i.init().present()}}getFiles(e=""){return $file.list(e).map((t=>{const i=e+"/"+t,a=$file.isDirectory(i);return{info:{info:{path:i,file:t,isDirectory:a}},icon:{symbol:a?"folder.fill":"doc"},name:{text:t},size:{text:a?"":"--"}}})).sort(((e,t)=>e.info.info.isDirectory!==t.info.info.isDirectory?e.info.info.isDirectory?-1:1:e.info.info.isDirectory===t.info.info.isDirectory?e.info.info.file.localeCompare(t.info.info.file):void 0))}async loadFileSize(e){return e.map(((t,i)=>{const a=t.info.info;if(!a.isDirectory)try{e[i].size.text=$272f042430a952c6$require$Kernel.bytesToSize($file.read(a.path).info.size)}catch(t){e[i].size.text=t}})),e}get listTemplate(){return{props:{bgcolor:$color("clear")},views:[{props:{id:"info"}},{type:"image",props:{id:"icon"},layout:(e,t)=>{e.centerY.equalTo(t.super),e.left.inset(this.edges),e.size.equalTo(this.iconSize)}},{type:"label",props:{id:"name",lines:1},layout:(e,t)=>{e.centerY.equalTo(t.super),e.left.equalTo(t.prev.right).offset(this.edges)}},{type:"label",props:{id:"size",color:$color("secondaryText"),lines:1},layout:(e,t)=>{e.centerY.equalTo(t.super),e.right.inset(this.edges)}}]}}#V(e,t){if(this.viewController){const i=new $272f042430a952c6$require$NavigationView;i.setView(t).navigationBarTitle(e),i.navigationBar.setLargeTitleDisplayMode($272f042430a952c6$require$NavigationBar.largeTitleDisplayModeNever),this.viewController.push(i)}else $272f042430a952c6$require$UIKit.push({title:e,views:[t]})}getListView(e=""){return{type:"list",props:{id:this.listId,menu:this.menu,info:{basePath:e},bgcolor:$272f042430a952c6$require$UIKit.primaryViewBackgroundColor,separatorInset:$insets(0,this.edges,0,0),data:[],template:this.listTemplate,actions:[{title:" "+$l10n("DELETE")+" ",color:$color("red"),handler:(e,t)=>{const i=e.object(t).info.info;$272f042430a952c6$require$Kernel.deleteConfirm($l10n("FILE_MANAGER_DELETE_CONFIRM_MSG")+' "'+i.file+'" ?',(()=>{this.delete(i),e.delete(t)}))}}]},layout:$layout.fill,events:{ready:()=>{const t=this.getFiles(e);$(this.listId).data=t,this.loadFileSize(t).then((e=>{$(this.listId).data=e}))},pulled:async e=>{const t=this.getFiles($(this.listId).info.basePath);$(this.listId).data=t,$(this.listId).data=await this.loadFileSize(t),$delay(.5,(()=>{e.endRefreshing()}))},didSelect:(e,t,i)=>{const a=i.info.info;a.isDirectory?this.#V(a.file,this.getListView(a.path)):this.edit(a)}}}}push(e=""){const t=e.substring(e.lastIndexOf("/"));this.#V(t,this.getListView(e))}}$272f042430a952c6$exports={FileManager:$272f042430a952c6$var$FileManager};var $bb0fea222fc5aea5$require$FileManager=$272f042430a952c6$exports.FileManager,$8aDdQ=parcelRequire("8aDdQ"),$bb0fea222fc5aea5$require$FileStorageParameterError=$8aDdQ.FileStorageParameterError,$bb0fea222fc5aea5$require$FileStorageFileNotFoundError=$8aDdQ.FileStorageFileNotFoundError,$bb0fea222fc5aea5$require$FileStorage=$8aDdQ.FileStorage,$4c192cc93140b629$exports={},$liCrE=parcelRequire("liCrE"),$4c192cc93140b629$require$View=$liCrE.View,$45Ip7=parcelRequire("45Ip7"),$4c192cc93140b629$require$UIKit=$45Ip7.UIKit;class $4c192cc93140b629$var$FixedFooterView extends $4c192cc93140b629$require$View{height=60;getView(){return this.type="view",this.setProp("bgcolor",$4c192cc93140b629$require$UIKit.primaryViewBackgroundColor),this.layout=(e,t)=>{e.left.right.bottom.equalTo(t.super),e.top.equalTo(t.super.safeAreaBottom).offset(-this.height)},this.views=[$4c192cc93140b629$require$View.create({props:this.props,views:this.views,layout:(e,t)=>{e.left.right.top.equalTo(t.super),e.height.equalTo(this.height)}})],this}}$4c192cc93140b629$exports={FixedFooterView:$4c192cc93140b629$var$FixedFooterView};var $bb0fea222fc5aea5$require$FixedFooterView=$4c192cc93140b629$exports.FixedFooterView,$cgaQ6=parcelRequire("cgaQ6"),$bb0fea222fc5aea5$require$Kernel=$cgaQ6.Kernel,$50aa538fe0dbd3b0$exports={},$liCrE=parcelRequire("liCrE"),$50aa538fe0dbd3b0$require$View=$liCrE.View;class $50aa538fe0dbd3b0$var$Matrix extends $50aa538fe0dbd3b0$require$View{titleStyle={font:$font("bold",21),height:30};#E;#x;templateIdByIndex(e){return void 0===this.props.template.views[e]?.props?.id&&(void 0===this.props.template.views[e].props&&(this.props.template.views[e].props={}),this.props.template.views[e].props.id=$text.uuid),this.props.template.views[e].props.id}get templateHiddenStatus(){if(!this.#x){this.#x={};for(let e=0;e(e.items=e.items.map((e=>(Object.keys(e).forEach((t=>{e[t].hidden=this.templateHiddenStatus[t]??!1})),Object.keys(this.templateHiddenStatus).forEach((t=>{e[t]||(e[t]={}),e[t].hidden=this.templateHiddenStatus[t]})),e.__templateProps={hidden:!1},e.__title={hidden:!0},e))),e.title&&e.items.unshift(this.#k(e.title)),e)))}rebuildTemplate(){let e={};void 0!==this.props.template.props&&(e=Object.assign(this.props.template.props,{id:"__templateProps",hidden:!1})),this.props.template.props={};const t=[{type:"view",props:e,layout:$layout.fill},{type:"label",props:{id:"__title",hidden:!0,font:this.titleStyle.font},layout:(e,t)=>{e.top.inset(-this.titleStyle.height/4*3),e.height.equalTo(this.titleStyle.height),e.width.equalTo(t.super.safeArea)}}].concat(this.props.template.views);this.props.template.views=t}insert(e,t=!0){return e.indexPath=this.indexPath(e.indexPath,t),$(this.id).insert(e)}delete(e,t=!0){return e=this.indexPath(e,t),$(this.id).delete(e)}object(e,t=!0){return e=this.indexPath(e,t),$(this.id).object(e)}cell(e,t=!0){return e=this.indexPath(e,t),$(this.id).cell(e)}indexPath(e,t){let i=t?0:1;return"number"==typeof e&&(e=$indexPath(0,e)),e=$indexPath(e.section,e.row+i)}update(e){this.props.data=this.rebuildData(e),$(this.id).data=this.props.data}getView(){return this.props.data=this.rebuildData(this.props.data),this.rebuildTemplate(),this.setEvent("itemSize",((e,t)=>{const i=e.object(t)?.__title?.info;if(i?.title)return $size(Math.max($device.info.screen.width,$device.info.screen.height),0);const a=this.props.columns??2,r=this.props.spacing??15,s=this.props.itemWidth??this.props.itemSize?.width??(e.super.frame.width-r*(a+1))/a,o=this.props.itemHeight??this.props.itemSize?.height??100;return $size(s,o)})),this}}$50aa538fe0dbd3b0$exports={Matrix:$50aa538fe0dbd3b0$var$Matrix};var $bb0fea222fc5aea5$require$Matrix=$50aa538fe0dbd3b0$exports.Matrix,$619319e3f3656d3f$exports={};class $619319e3f3656d3f$var$Request{static method={get:"GET",post:"POST",delete:"DELETE",patch:"PATCH",head:"HEAD"};cacheContainerKey=$addin?.current?.name+".request.cache";#N=!1;#O=!1;cacheLife=2592e6;isLogRequest=!1;timeout=5;logger;constructor(e){"function"==typeof e&&(this.logger=e)}get cache(){return $cache.get(this.cacheContainerKey)??{}}#A(e){this.isLogRequest&&"function"==typeof logger&&this.logger(e)}logRequest(e){return this.isLogRequest=!0,"function"==typeof e&&(this.logger=e),this}getCacheKey(e){return $text.MD5(e)}getCache(e,t=null){return this.cache[e]??t}setCache(e,t){if(!t)return;const i=this.cache;i[e]=t,$cache.set(this.cacheContainerKey,i)}removeCache(e){let t=this.cache;delete t[e],$cache.set(this.cacheContainerKey,t)}clearCache(){$cache.remove(this.cacheContainerKey)}useCache(){return this.#N=!0,this}ignoreCacheExp(){this.#O=!0}async request(e,t,i={},a={},r=this.cacheLife){let s;const o=this.#N&&t===$619319e3f3656d3f$var$Request.method.get;if(o){s=this.getCacheKey(e);const t=this.getCache(s);if(t&&(this.#O||t.exp>Date.now()))return this.#A("get data from cache: "+e),t.data}try{this.#A(`sending request [${t}]: ${e}`);const n=await $http.request({header:a,url:e,method:t,body:i,timeout:this.timeout});if(n.error)throw n.error;if(n?.response?.statusCode>=400){let e=n.data;throw"object"==typeof e&&(e=JSON.stringify(e)),new Error("http error: ["+n.response.statusCode+"] "+e)}return o&&this.setCache(s,{exp:Date.now()+r,data:n}),n}catch(e){throw e.code&&(e=new Error("network error: ["+e.code+"] "+e.localizedDescription)),e}}}$619319e3f3656d3f$exports={Request:$619319e3f3656d3f$var$Request};var $bb0fea222fc5aea5$require$Request=$619319e3f3656d3f$exports.Request,$7D8Kb=parcelRequire("7D8Kb"),$bb0fea222fc5aea5$require$Setting=$7D8Kb.Setting,$aXWmO=parcelRequire("aXWmO"),$bb0fea222fc5aea5$require$Sheet=$aXWmO.Sheet,$7dfcabb1e936a92c$exports={},$liCrE=parcelRequire("liCrE"),$7dfcabb1e936a92c$require$View=$liCrE.View,$7dfcabb1e936a92c$require$PageView=$liCrE.PageView,$fYz8N=parcelRequire("fYz8N"),$7dfcabb1e936a92c$require$Controller=$fYz8N.Controller,$45Ip7=parcelRequire("45Ip7"),$7dfcabb1e936a92c$require$UIKit=$45Ip7.UIKit;class $7dfcabb1e936a92c$var$TabBarCellView extends $7dfcabb1e936a92c$require$View{constructor(e={}){super(e),this.setIcon(e.icon),this.setTitle(e.title),void 0!==e.activeStatus&&(this.activeStatus=e.activeStatus)}setIcon(e){return this.icon=e instanceof Array?e:[e,e],this}setTitle(e){return this.title=e,this}active(){$(`${this.props.id}-icon`).image=$image(this.icon[1]),$(`${this.props.id}-icon`).tintColor=$color("systemLink"),$(`${this.props.id}-title`).textColor=$color("systemLink"),this.activeStatus=!0}inactive(){$(`${this.props.id}-icon`).image=$image(this.icon[0]),$(`${this.props.id}-icon`).tintColor=$color("lightGray"),$(`${this.props.id}-title`).textColor=$color("lightGray"),this.activeStatus=!1}getView(){return this.views=[{type:"image",props:{id:`${this.props.id}-icon`,image:$image(this.activeStatus?this.icon[1]:this.icon[0]),bgcolor:$color("clear"),tintColor:$color(this.activeStatus?"systemLink":"lightGray")},layout:(e,t)=>{e.centerX.equalTo(t.super);const i=$7dfcabb1e936a92c$var$TabBarController.tabBarHeight/2;e.size.equalTo(i),e.top.inset(($7dfcabb1e936a92c$var$TabBarController.tabBarHeight-i-13)/2)}},{type:"label",props:{id:`${this.props.id}-title`,text:this.title,font:$font(10),textColor:$color(this.activeStatus?"systemLink":"lightGray")},layout:(e,t)=>{e.centerX.equalTo(t.prev),e.top.equalTo(t.prev.bottom).offset(3)}}],this}}class $7dfcabb1e936a92c$var$TabBarHeaderView extends $7dfcabb1e936a92c$require$View{height=60;getView(){return this.type="view",this.setProp("bgcolor",this.props.bgcolor??$7dfcabb1e936a92c$require$UIKit.primaryViewBackgroundColor),this.layout=(e,t)=>{e.left.right.bottom.equalTo(t.super),e.top.equalTo(t.super.safeAreaBottom).offset(-this.height-$7dfcabb1e936a92c$var$TabBarController.tabBarHeight)},this.views=[$7dfcabb1e936a92c$require$View.create({props:this.props,views:this.views,layout:(e,t)=>{e.left.right.top.equalTo(t.super),e.height.equalTo(this.height)}})],this}}class $7dfcabb1e936a92c$var$TabBarController extends $7dfcabb1e936a92c$require$Controller{static tabBarHeight=50;#L={};#R={};#F;#D;#z=$text.uuid;#P=$text.uuid;bottomSafeAreaInsets=$app.isDebugging?0:$7dfcabb1e936a92c$require$UIKit.bottomSafeAreaInsets;get selected(){return this.#D}set selected(e){this.switchPageTo(e)}get contentOffset(){return $7dfcabb1e936a92c$var$TabBarController.tabBarHeight+(this.#F?.height??0)}setPages(e={}){return Object.keys(e).forEach((t=>this.setPage(t,e[t]))),this}setPage(e,t){return void 0===this.#D&&(this.#D=e),this.#L[e]=t instanceof $7dfcabb1e936a92c$require$PageView?t:$7dfcabb1e936a92c$require$PageView.create(t),this.#D!==e&&(this.#L[e].activeStatus=!1),this}switchPageTo(e){if(this.#L[e]){if(this.#D===e)return;$ui.animate({duration:.4,animation:()=>{this.#R[e].active()}}),this.#R[this.#D].inactive(),this.#L[this.#D].hide(),this.#L[e].show(),this.callEvent("onChange",this.#D,e),this.#D=e,this.initBackground()}}hideBackground(e=!0){$(this.#P).hidden=!0,$ui.animate({duration:e?.2:1e-4,animation:()=>{$(this.#z).alpha=0}})}showBackground(e=!0){$(this.#P).hidden=!1,$ui.animate({duration:e?.2:1e-4,animation:()=>{$(this.#z).alpha=1}})}initBackground(){const e=this.#L[this.selected];e.scrollable&&$delay(0,(()=>{const t=$(e.id).get(e.scrollableView.id),i=t.contentOffset.y;t.contentSize.height+this.bottomSafeAreaInsets-t.frame.height-i<=0?this.hideBackground(!1):this.showBackground(!1)}))}setCells(e={}){return Object.keys(e).forEach((t=>this.setCell(t,e[t]))),this}setCell(e,t){return void 0===this.#D&&(this.#D=e),t instanceof $7dfcabb1e936a92c$var$TabBarCellView||(t=new $7dfcabb1e936a92c$var$TabBarCellView({props:{info:{key:e}},icon:t.icon,title:t.title,activeStatus:this.#D===e})),this.#R[e]=t,this}setHeader(e){return this.#F=e,this}#M(){const e=[];return Object.values(this.#R).forEach((t=>{t.setEvent("tapped",(e=>{const t=e.info.key;this.switchPageTo(t)})),e.push(t.getView())})),e}#H(){return Object.values(this.#L).map((e=>{if(e.scrollable){const t=e.scrollableView;if(t.props.indicatorInsets){const e=t.props.indicatorInsets;t.props.indicatorInsets=$insets(e.top,e.left,e.bottom+this.contentOffset,e.right)}else t.props.indicatorInsets=$insets(0,0,this.contentOffset,0);t.props.footer=Object.assign({props:{}},t.props.footer??{}),t.props.footer.props.height?t.props.footer.props.height+=this.contentOffset:t.props.footer.props.height=this.contentOffset,"function"==typeof t.assignEvent&&t.assignEvent("didScroll",(e=>{const t=e.contentOffset.y;e.contentSize.height+this.bottomSafeAreaInsets-e.frame.height-t<=1?this.hideBackground():this.showBackground()}))}return e.definition}))}generateView(){const e={type:"view",layout:(e,t)=>{e.centerX.equalTo(t.super),e.width.equalTo(t.super),e.top.equalTo(t.super.safeAreaBottom).offset(-$7dfcabb1e936a92c$var$TabBarController.tabBarHeight),e.bottom.equalTo(t.super)},views:[$7dfcabb1e936a92c$require$UIKit.blurBox({id:this.#z}),{type:"stack",layout:$layout.fillSafeArea,props:{axis:$stackViewAxis.horizontal,distribution:$stackViewDistribution.fillEqually,spacing:0,stack:{views:this.#M()}}},$7dfcabb1e936a92c$require$UIKit.separatorLine({id:this.#P},$7dfcabb1e936a92c$require$UIKit.align.top)],events:{ready:()=>this.initBackground()}};return $7dfcabb1e936a92c$require$View.createFromViews(this.#H().concat(this.#F?.definition??[],e))}}$7dfcabb1e936a92c$exports={TabBarCellView:$7dfcabb1e936a92c$var$TabBarCellView,TabBarHeaderView:$7dfcabb1e936a92c$var$TabBarHeaderView,TabBarController:$7dfcabb1e936a92c$var$TabBarController};var $bb0fea222fc5aea5$require$TabBarCellView=$7dfcabb1e936a92c$exports.TabBarCellView,$bb0fea222fc5aea5$require$TabBarHeaderView=$7dfcabb1e936a92c$exports.TabBarHeaderView,$bb0fea222fc5aea5$require$TabBarController=$7dfcabb1e936a92c$exports.TabBarController,$3839e9f9bae78bdd$exports={};class $3839e9f9bae78bdd$var$Tasks{#j={};addTask(e,t=0){const i=$text.uuid;return this.#j[i]=$delay(t,(async()=>{await e(),delete this.#j[i]})),i}cancelTask(e){this.#j[e].cancel()}clearTasks(){Object.values(this.#j).forEach((e=>e.cancel()))}}$3839e9f9bae78bdd$exports={Tasks:$3839e9f9bae78bdd$var$Tasks};var $bb0fea222fc5aea5$require$Tasks=$3839e9f9bae78bdd$exports.Tasks,$895b2d75ea56b5f0$exports={},$45Ip7=parcelRequire("45Ip7"),$895b2d75ea56b5f0$require$UIKit=$45Ip7.UIKit;class $895b2d75ea56b5f0$var$Toast{static type={info:void 0,success:"checkmark",warning:"exclamationmark.triangle",error:"xmark.circle"};static edges=40;static iconSize=100;static labelTopMargin=10;width=Math.min(.6*$895b2d75ea56b5f0$require$UIKit.windowSize.width,260);labelWidth=this.width-2*$895b2d75ea56b5f0$var$Toast.edges;id=$text.uuid;#U="";type=$895b2d75ea56b5f0$var$Toast.type.info;labelLines=2;font=$font("default",26);constructor(e,t=$895b2d75ea56b5f0$var$Toast.type.info,i=2,a=$font("default",26)){this.type=t,this.message=e,this.labelLines=i,this.font=a}get message(){return this.#U}set message(e){this.#U=e,this.fontHeight=$895b2d75ea56b5f0$require$UIKit.getContentSize(this.font,this.message,this.labelWidth,this.labelLines).height,this.height=(this.hasIcon?$895b2d75ea56b5f0$var$Toast.labelTopMargin+$895b2d75ea56b5f0$var$Toast.iconSize:0)+this.fontHeight+2*$895b2d75ea56b5f0$var$Toast.edges}get hasIcon(){return void 0!==this.type}get blurBox(){const e=$895b2d75ea56b5f0$require$UIKit.blurBox({id:this.id,cornerRadius:15,alpha:0},[{type:"image",props:{symbol:this.type,hidden:!this.hasIcon,tintColor:$color("lightGray")},layout:(e,t)=>{e.top.inset($895b2d75ea56b5f0$var$Toast.edges),e.size.equalTo($895b2d75ea56b5f0$var$Toast.iconSize),e.centerX.equalTo(t.super)}},{type:"label",props:{font:this.font,text:this.message,align:$align.center,lines:this.labelLines,color:$color("lightGray")},layout:(e,t)=>{e.bottom.equalTo(t.supper).offset(-$895b2d75ea56b5f0$var$Toast.edges),e.width.equalTo(this.labelWidth),e.height.equalTo(this.fontHeight),e.centerX.equalTo(t.super)}}]);return e.events={tapped:()=>{this.remove()}},e}show(){$ui.controller.view.insertAtIndex($ui.create(this.blurBox),0);const e=$(this.id);e.layout(((e,t)=>{e.center.equalTo(t.super),e.size.equalTo($size(this.width,this.height))})),e.moveToFront(),$ui.animate({duration:.2,animation:()=>{e.alpha=1}})}remove(){const e=$(this.id);e&&$ui.animate({duration:.2,animation:()=>{e.alpha=0},completion:()=>{e.remove()}})}static toast({message:e,type:t=$895b2d75ea56b5f0$var$Toast.type.info,displayTime:i=2,labelLines:a=2,font:r=$font("default",26)}){const s=new $895b2d75ea56b5f0$var$Toast(e,t,a,r);s.show(),$delay(i,(()=>{s.remove()}))}static info(e,t={}){$895b2d75ea56b5f0$var$Toast.toast(Object.assign({message:e,type:$895b2d75ea56b5f0$var$Toast.type.info},t))}static success(e,t={}){$895b2d75ea56b5f0$var$Toast.toast(Object.assign({message:e,type:$895b2d75ea56b5f0$var$Toast.type.success},t))}static warning(e,t={}){$895b2d75ea56b5f0$var$Toast.toast(Object.assign({message:e,type:$895b2d75ea56b5f0$var$Toast.type.warning},t))}static error(e,t={}){$895b2d75ea56b5f0$var$Toast.toast(Object.assign({message:e,type:$895b2d75ea56b5f0$var$Toast.type.error},t))}}$895b2d75ea56b5f0$exports={Toast:$895b2d75ea56b5f0$var$Toast};var $bb0fea222fc5aea5$require$Toast=$895b2d75ea56b5f0$exports.Toast,$45Ip7=parcelRequire("45Ip7"),$bb0fea222fc5aea5$require$UIKit=$45Ip7.UIKit,$86d2ffde19fb8791$exports={};class $86d2ffde19fb8791$var$UILoading{#K;text="";interval;fullScreen=!1;#_=()=>{};constructor(){this.#K=$text.uuid}updateText(e){$(this.#K).text=e}setLoop(e){if("function"!=typeof e)throw"loop must be a function";this.#_=e}done(){clearInterval(this.interval)}load(){$ui.render({props:{navBarHidden:this.fullScreen},views:[{type:"spinner",props:{loading:!0},layout:(e,t)=>{e.centerY.equalTo(t.super).offset(-15),e.width.equalTo(t.super)}},{type:"label",props:{id:this.#K,align:$align.center,text:""},layout:(e,t)=>{e.top.equalTo(t.prev.bottom).offset(10),e.left.right.equalTo(t.super)}}],layout:$layout.fill,events:{appeared:()=>{this.interval=setInterval((()=>{this.#_()}),100)}}})}}$86d2ffde19fb8791$exports={UILoading:$86d2ffde19fb8791$var$UILoading};var $bb0fea222fc5aea5$require$UILoading=$86d2ffde19fb8791$exports.UILoading,$6Xrbz=parcelRequire("6Xrbz"),$bb0fea222fc5aea5$require$ValidationError=$6Xrbz.ValidationError,$liCrE=parcelRequire("liCrE"),$bb0fea222fc5aea5$require$View=$liCrE.View,$bb0fea222fc5aea5$require$PageView=$liCrE.PageView,$gMc1q=parcelRequire("gMc1q"),$bb0fea222fc5aea5$require$ViewController=$gMc1q.ViewController,$12xzj=parcelRequire("12xzj"),$bb0fea222fc5aea5$require$NavigationView=$12xzj.NavigationView,$dcStC=parcelRequire("dcStC"),$bb0fea222fc5aea5$require$NavigationBar=$dcStC.NavigationBar,$bb0fea222fc5aea5$require$NavigationBarController=$dcStC.NavigationBarController,$gAYmG=parcelRequire("gAYmG"),$bb0fea222fc5aea5$require$NavigationBarItems=$gAYmG.NavigationBarItems,$bb0fea222fc5aea5$require$BarButtonItem=$gAYmG.BarButtonItem,$ee5e1f8d12d987dc$exports={},$fYz8N=parcelRequire("fYz8N"),$ee5e1f8d12d987dc$require$Controller=$fYz8N.Controller,$gAYmG=parcelRequire("gAYmG"),$ee5e1f8d12d987dc$require$BarTitleView=$gAYmG.BarTitleView;class $ee5e1f8d12d987dc$var$SearchBar extends $ee5e1f8d12d987dc$require$BarTitleView{height=35;topOffset=15;bottomOffset=10;kbType=$kbType.search;placeholder=$l10n("SEARCH");inputEvents={};keyboardView;accessoryView;constructor(e){super(e),this.setController(new $ee5e1f8d12d987dc$var$SearchBarController),this.controller.setSearchBar(this)}setEvent(e,t){return this.inputEvents[e]=t,this}setPlaceholder(e){return this.placeholder=e,this}setKbType(e){return this.kbType=e,this}setKeyboardView(e){return this.keyboardView=e,this}setAccessoryView(e){return this.accessoryView=e,this}getView(){return this.props={id:this.id,smoothCorners:!0,cornerRadius:6,bgcolor:$color("#EEF1F1","#212121")},this.views=[{type:"input",props:{id:this.id+"-input",type:this.kbType,bgcolor:$color("clear"),placeholder:this.placeholder,keyboardView:this.keyboardView,accessoryView:this.accessoryView},layout:$layout.fill,events:Object.assign({changed:e=>this.controller.callEvent("onChange",e.text),returned:e=>this.controller.callEvent("onReturn",e.text)},this.inputEvents)}],this.layout=(e,t)=>{e.height.equalTo(this.height),e.top.equalTo(t.super.safeArea).offset(this.topOffset),e.left.equalTo(t.super.safeArea).offset(15),e.right.equalTo(t.super.safeArea).offset(-15)},this}}class $ee5e1f8d12d987dc$var$SearchBarController extends $ee5e1f8d12d987dc$require$Controller{setSearchBar(e){return this.searchBar=e,this}updateSelector(){this.selector={inputBox:$(this.searchBar.id),input:$(this.searchBar.id+"-input")}}hide(){this.updateSelector(),this.selector.inputBox.updateLayout((e=>{e.height.equalTo(0)}))}show(){this.updateSelector(),this.selector.inputBox.updateLayout((e=>{e.height.equalTo(this.searchBar.height)}))}didScroll(e){this.updateSelector();let t=this.searchBar.height-e;if(t=t>0?t>this.searchBar.height?this.searchBar.height:t:0,this.selector.inputBox.updateLayout((e=>{e.height.equalTo(t)})),e>0){const t=(this.searchBar.height/2-5-e)/10;this.selector.input.alpha=t}else this.selector.input.alpha=1}didEndDragging(e,t,i){this.updateSelector(),e>=0&&e<=this.searchBar.height&&i($point(0,e>=this.searchBar.height/2?this.searchBar.height:0))}}$ee5e1f8d12d987dc$exports={SearchBar:$ee5e1f8d12d987dc$var$SearchBar,SearchBarController:$ee5e1f8d12d987dc$var$SearchBarController};var $bb0fea222fc5aea5$require$SearchBar=$ee5e1f8d12d987dc$exports.SearchBar,$bb0fea222fc5aea5$require$SearchBarController=$ee5e1f8d12d987dc$exports.SearchBarController;module.exports={VERSION:$bb0fea222fc5aea5$require$VERSION,Controller:$bb0fea222fc5aea5$require$Controller,FileManager:$bb0fea222fc5aea5$require$FileManager,FileStorageParameterError:$bb0fea222fc5aea5$require$FileStorageParameterError,FileStorageFileNotFoundError:$bb0fea222fc5aea5$require$FileStorageFileNotFoundError,FileStorage:$bb0fea222fc5aea5$require$FileStorage,FixedFooterView:$bb0fea222fc5aea5$require$FixedFooterView,Kernel:$bb0fea222fc5aea5$require$Kernel,Matrix:$bb0fea222fc5aea5$require$Matrix,Request:$bb0fea222fc5aea5$require$Request,Setting:$bb0fea222fc5aea5$require$Setting,Sheet:$bb0fea222fc5aea5$require$Sheet,TabBarCellView:$bb0fea222fc5aea5$require$TabBarCellView,TabBarHeaderView:$bb0fea222fc5aea5$require$TabBarHeaderView,TabBarController:$bb0fea222fc5aea5$require$TabBarController,Tasks:$bb0fea222fc5aea5$require$Tasks,Toast:$bb0fea222fc5aea5$require$Toast,UIKit:$bb0fea222fc5aea5$require$UIKit,UILoading:$bb0fea222fc5aea5$require$UILoading,ValidationError:$bb0fea222fc5aea5$require$ValidationError,View:$bb0fea222fc5aea5$require$View,PageView:$bb0fea222fc5aea5$require$PageView,ViewController:$bb0fea222fc5aea5$require$ViewController,NavigationView:$bb0fea222fc5aea5$require$NavigationView,NavigationBar:$bb0fea222fc5aea5$require$NavigationBar,NavigationBarController:$bb0fea222fc5aea5$require$NavigationBarController,NavigationBarItems:$bb0fea222fc5aea5$require$NavigationBarItems,BarButtonItem:$bb0fea222fc5aea5$require$BarButtonItem,SearchBar:$bb0fea222fc5aea5$require$SearchBar,SearchBarController:$bb0fea222fc5aea5$require$SearchBarController}; \ No newline at end of file diff --git a/scripts/setting-methods.js b/scripts/setting-methods.js index 02878d3d..1ff144a2 100644 --- a/scripts/setting-methods.js +++ b/scripts/setting-methods.js @@ -14,18 +14,18 @@ let kernel function clips() { kernel.setting.method.exportClipboard = animate => { - animate.actionStart() + animate.start() kernel.storage.export(success => { if (success) { - animate.actionDone() + animate.done() } else { - animate.actionCancel() + animate.cancel() } }) } kernel.setting.method.importClipboard = animate => { - animate.actionStart() + animate.start() $ui.alert({ title: $l10n("ALERT_INFO"), message: $l10n("OVERWRITE_ALERT"), @@ -36,14 +36,14 @@ function clips() { $drive.open({ handler: data => { if (data === undefined) { - animate.actionCancel() + animate.cancel() return } if (data.fileName.slice(-2) === "db" || data.fileName.slice(-3) === "zip") { kernel.storage .import(data) .then(() => { - animate.actionDone() + animate.done() $delay(0.3, () => { $addin.restart() }) @@ -51,11 +51,11 @@ function clips() { .catch(error => { $ui.error(error) kernel.print(error) - animate.actionCancel() + animate.cancel() }) } else { $ui.warning($l10n("FILE_TYPE_ERROR")) - animate.actionCancel() + animate.cancel() } } }) @@ -63,21 +63,21 @@ function clips() { }, { title: $l10n("CANCEL"), - handler: () => animate.actionCancel() + handler: () => animate.cancel() } ] }) } kernel.setting.method.rebuildDatabase = animate => { - animate.actionStart() + animate.start() const rebuildDatabase = () => { try { kernel.storage.rebuild() - animate.actionDone() + animate.done() $delay(0.8, () => $addin.restart()) } catch (error) { - animate.actionCancel() + animate.cancel() $ui.alert(error) } } @@ -94,7 +94,7 @@ function clips() { { title: $l10n("CANCEL"), handler: () => { - animate.actionCancel() + animate.cancel() } } ] @@ -102,7 +102,7 @@ function clips() { } kernel.setting.method.deleteAllData = animate => { - animate.actionStart() + animate.start() $ui.alert({ title: $l10n("DELETE_ALL_DATA_ALERT"), actions: [ @@ -111,14 +111,14 @@ function clips() { style: $alertActionType.destructive, handler: () => { kernel.storage.deleteAllData() - animate.actionDone() + animate.done() $delay(0.5, () => $addin.restart()) } }, { title: $l10n("CANCEL"), handler: () => { - animate.actionCancel() + animate.cancel() } } ] @@ -128,7 +128,7 @@ function clips() { function action() { kernel.setting.method.exportAction = animate => { - animate.actionStart() + animate.start() // 备份动作 const fileName = "actions.zip" const tempPath = `/${fileName}` @@ -146,9 +146,9 @@ function action() { ], handler: success => { if (success) { - animate.actionDone() + animate.done() } else { - animate.actionCancel() + animate.cancel() } kernel.fileStorage.delete(tempPath) } @@ -158,11 +158,11 @@ function action() { } kernel.setting.method.importAction = animate => { - animate.actionStart() + animate.start() $drive.open({ handler: data => { if (data === undefined) { - animate.actionCancel() + animate.cancel() return } if (data.fileName.slice(-3) === "zip") { @@ -180,25 +180,25 @@ function action() { } }) $file.delete(path) - animate.actionDone() + animate.done() } }) } else { $ui.warning($l10n("FILE_TYPE_ERROR")) - animate.actionCancel() + animate.cancel() } } }) } kernel.setting.method.importExampleAction = animate => { - animate.actionStart() + animate.start() kernel.actionManager.importExampleAction() - animate.actionDone() + animate.done() } kernel.setting.method.rebuildAction = animate => { - animate.actionStart() + animate.start() $ui.alert({ title: $l10n("REBUILD_ACTION_DATABASE_ALERT_TITLE"), message: $l10n("REBUILD_ACTION_DATABASE_ALERT_MESSAGE"), @@ -209,11 +209,11 @@ function action() { handler: () => { $file.delete(kernel.actionManager.userActionPath) $file.delete(kernel.actionManager.iCloudPath) - animate.actionDone() + animate.done() $delay(0.8, () => $addin.restart()) } }, - { title: $l10n("CANCEL"), handler: () => animate.actionCancel() } + { title: $l10n("CANCEL"), handler: () => animate.cancel() } ] }) } @@ -330,7 +330,7 @@ function settingMethods(appKernel) { kernel = appKernel kernel.setting.method.checkUpdate = async animate => { - animate.actionStart() + animate.start() const easyJsboxPath = "scripts/libs/easy-jsbox.js" if ($file.exists(easyJsboxPath)) { @@ -379,7 +379,7 @@ function settingMethods(appKernel) { } else { $ui.toast("No need to update") } - animate.actionDone() + animate.done() } }) } diff --git a/scripts/ui/clips.js b/scripts/ui/clips.js index afbf1d29..7db2cf17 100644 --- a/scripts/ui/clips.js +++ b/scripts/ui/clips.js @@ -157,7 +157,10 @@ class Clips extends ClipsData { } updateListBackground() { - $(this.listId + "-empty-list-background").hidden = this.clips.length > 0 + const bg = $(this.listId + "-empty-list-background") + if (bg) { + bg.hidden = this.clips.length > 0 + } } updateCopied(copied = {}) { @@ -193,8 +196,8 @@ class Clips extends ClipsData { this.updateCopied(copied) if (isUpdateIndicator) { - const listView = $(this.listId) $delay(0.3, () => { + const listView = $(this.listId) listView.cell($indexPath(0, oldRow)).get("copied").hidden = true listView.cell($indexPath(0, row)).get("copied").hidden = false }) @@ -254,21 +257,21 @@ class Clips extends ClipsData { return false } - add(item, uiUpdate) { + add(item) { try { const data = super.add(item) - if (typeof uiUpdate === "function") { - uiUpdate(data) - } else { - // 在列表中插入行 - $(this.listId).insert({ - indexPath: $indexPath(0, 0), - value: this.lineData(data) - }) - // 被复制的元素向下移动了一个单位 - if (this.copied?.tabIndex === this.tabIndex) { - this.setCopied(this.copied.uuid, this.copied?.row + 1, false) - } + + // 先修改背景,让 list 显示出来 + this.updateListBackground() + + // 在列表中插入行 + $(this.listId).insert({ + indexPath: $indexPath(0, 0), + value: this.lineData(data) + }) + // 被复制的元素向下移动了一个单位 + if (this.copied?.tabIndex === this.tabIndex) { + this.setCopied(this.copied.uuid, this.copied?.row + 1, false) } return data @@ -285,6 +288,8 @@ class Clips extends ClipsData { this.copied = {} $clipboard.clear() } + + this.updateListBackground() } catch (error) { $ui.alert(error) } diff --git a/scripts/ui/components/action-manager.js b/scripts/ui/components/action-manager.js index 8e1ff8ec..a9b48d2f 100644 --- a/scripts/ui/components/action-manager.js +++ b/scripts/ui/components/action-manager.js @@ -11,6 +11,7 @@ class ActionManager extends ActionManagerData { matrix reorder = {} addActionButtonId = "action-manager-button-add" + sortActionButtonId = "action-manager-button-sort" syncLabelId = "action-manager-sync-label" get actionList() { @@ -29,6 +30,31 @@ class ActionManager extends ActionManagerData { }) } + /** + * 监听同步信息 + */ + actionSyncStatus() { + $app.listen({ + actionSyncStatus: args => { + if (args.status === ActionManagerData.syncStatus.syncing) { + this.undateNavButton(true) + this.undateSyncLabel($l10n("SYNCING")) + } else if (args.status === ActionManagerData.syncStatus.success) { + try { + this.matrix.update(this.actionList) + } catch (error) { + this.kernel.error(error) + this.undateSyncLabel(error) + $ui.error(error) + } finally { + this.undateSyncLabel() + this.undateNavButton(false) + } + } + } + }) + } + editActionInfoPageSheet(info, done) { const actionTypes = this.getActionTypes() const actionTypesIndex = {} // 用于反查索引 @@ -339,6 +365,7 @@ class ActionManager extends ActionManagerData { { // 排序 symbol: "arrow.up.arrow.down.circle", + id: this.sortActionButtonId, tapped: (animate, sender) => { $ui.popover({ sourceView: sender, @@ -395,6 +422,26 @@ class ActionManager extends ActionManagerData { } } + undateSyncLabel(message) { + if (!message) { + message = $l10n("LAST_SYNC_AT") + this.getSyncDate().toLocaleString() + } + if ($(this.syncLabelId)) { + $(this.syncLabelId).text = message + } + } + + undateNavButton(loading) { + const addActionButton = this.navigationView?.navigationBarItems?.getButton(this.addActionButtonId) + if (addActionButton) { + addActionButton.setLoading(loading) + } + const sortActionButton = this.navigationView?.navigationBarItems?.getButton(this.sortActionButtonId) + if (sortActionButton) { + sortActionButton.setLoading(loading) + } + } + getActionListView(didSelect, props = {}, events = {}) { if (didSelect) { events.didSelect = (sender, indexPath, data) => { @@ -469,15 +516,6 @@ class ActionManager extends ActionManagerData { } } - undateSyncLabel(message) { - if (!message) { - message = $l10n("LAST_SYNC_AT") + this.getSyncDate().toLocaleString() - } - if ($(this.syncLabelId)) { - $(this.syncLabelId).text = message - } - } - getMatrixView({ columns = 2, spacing = 15, itemHeight = 100 } = {}) { this.matrix = Matrix.create({ type: "matrix", @@ -575,7 +613,7 @@ class ActionManager extends ActionManagerData { type: "view", props: { hidden: !this.kernel.setting.get("experimental.syncAction"), - height: this.kernel.setting.get("experimental.syncAction") ? 40 : 0 + height: this.kernel.setting.get("experimental.syncAction") ? 50 : 0 }, views: [ { @@ -606,36 +644,20 @@ class ActionManager extends ActionManagerData { this.getActionHandler(info.type, info.dir)(actionData) }, pulled: sender => { - $delay(0.5, () => { - sender.endRefreshing() + $delay(0.5, async () => { + this.undateNavButton(true) + await this.sync() + this.actionsNeedReload() this.matrix.update(this.actionList) this.undateSyncLabel() + this.undateNavButton(false) + sender.endRefreshing() }) } } }) - // 监听同步信息 - $app.listen({ - actionSyncStatus: args => { - const button = this.navigationView?.navigationBarItems?.getButton(this.addActionButtonId) ?? {} - if (args.status === ActionManagerData.syncStatus.syncing) { - button.setLoading(true) - this.undateSyncLabel($l10n("SYNCING")) - } else if (args.status === ActionManagerData.syncStatus.success) { - try { - this.matrix.update(this.actionList) - } catch (error) { - this.kernel.error(error) - this.undateSyncLabel(error) - $ui.error(error) - } finally { - this.undateSyncLabel() - button.setLoading(false) - } - } - } - }) + this.actionSyncStatus() return this.matrix.definition } @@ -649,17 +671,32 @@ class ActionManager extends ActionManagerData { present() { const actionSheet = new Sheet() - actionSheet - .setView(this.getMatrixView()) - .addNavBar({ - title: $l10n("ACTIONS"), - popButton: { - symbol: "xmark.circle" - }, - rightButtons: this.getNavButtons() + const rightButtons = this.getNavButtons() + if (this.kernel.setting.get("experimental.syncAction")) { + rightButtons.push({ + // 同步 + symbol: "arrow.triangle.2.circlepath.circle", + tapped: async (animate, sender) => { + animate.start() + this.undateNavButton(true) + await this.sync() + this.actionsNeedReload() + this.matrix.update(this.actionList) + this.undateSyncLabel() + animate.done() + this.undateNavButton(false) + } }) - .init() - .present() + } + actionSheet.setView(this.getMatrixView()).addNavBar({ + title: $l10n("ACTIONS"), + popButton: { symbol: "xmark.circle" }, + rightButtons: rightButtons + }) + + this.navigationView = actionSheet.navigationView + + actionSheet.init().present() } } diff --git a/scripts/ui/keyboard.js b/scripts/ui/keyboard.js index b821ec10..a61cd3f3 100644 --- a/scripts/ui/keyboard.js +++ b/scripts/ui/keyboard.js @@ -10,9 +10,12 @@ const KeyboardScripts = require("./components/keyboard-scripts") class Keyboard extends Clips { #readClipboardTimer + listId = "keyboard-clips-list" + keyboardSwitchLockId = "keyboard-switch-lock" + keyboardSwitchLockKey = "caio.keyboard.switch.lock" + deleteTimer = undefined continuousDeleteTimer = undefined - deleteDelay = this.kernel.setting.get("keyboard.deleteDelay") continuousDeleteDelay = 0.5 // 剪贴板列个性化设置 @@ -30,9 +33,6 @@ class Keyboard extends Clips { */ constructor(kernel) { super(kernel) - this.listId = "keyboard-clips-list" - this.keyboardSwitchLockId = "keyboard-switch-lock" - this.keyboardSwitchLockKey = "caio.keyboard.switch.lock" this.backgroundImage = this.kernel.setting.getImage("keyboard.background.image") this.backgroundColor = this.kernel.setting.getColor(this.kernel.setting.get("keyboard.background.color")) @@ -40,6 +40,8 @@ class Keyboard extends Clips { this.kernel.setting.get("keyboard.background.color.dark") ) + this.deleteDelay = this.kernel.setting.get("keyboard.deleteDelay") + this.keyboardSetting() if (typeof $cache.get(this.keyboardSwitchLockKey) !== "boolean") { @@ -75,7 +77,6 @@ class Keyboard extends Clips { listReady() { this.updateList() - this.appListen() // readClipboard if (this.kernel.setting.get("clipboard.autoSave") && $app.env === $env.keyboard) { this.#readClipboardTimer = $timer.schedule({